help <key> eventuality python opening widget
i'm minute formula python i'm carrying problem perplexing collect calm an opening widget.
the thing is: i wish border characters typed, i'm perplexing pristine opening widget i strech specific array characters (2 case), nonetheless looks i always skip final typed character. i total misplaced impression imitation show.
here's illustration code:
from tkinter import *
class sampleframe:
def __init__(self, master):
self.__frame = frame(master)
self.__frame.pack()
def get_frame(self):
relapse self.__frame
class sampleclass:
def __init__(self, master):
self.__alabel = label(master,text="alabel", width=10)
self.__alabel.pack(side=left)
self.__aentry = opening (master, width=2)
self.__aentry.bind('<key>', lambda event: self.callback(event, self.__aentry))
self.__aentry.pack(side=left)
def callback(self, event, widgetname):
self.__value = widgetname.get()+event.char
imitation self.__value
len(self.__value)>2:
widgetname.delete(2,4)
root = tk()
asampleframe = sampleframe(root)
asampleclass = sampleclass(asampleframe.get_frame())
root.mainloop()
any assistance many appreciated!
thanks advance
Comments
Post a Comment