Hi! I am a Tkinter rookie, so please bear with me if I'm doing something obviously stupid. I am trying to write a simple Tkinter application, which will show modeless windows with some content as the reaction to button press. I am trying to achieve it with the following code: ---- class MyWin(Toplevel): def __init__(self,master,number): Toplevel.__init__(self,master) self.number = number Label( self , text=str(self.number) ).pack() self.bind("<Escape>", self.cancel) self.wait_window(self) def cancel(self,event=None): print "Canceling",self.number self.destroy() def new_window(): global win_number, root no = win_number win_number = win_number + 1 print "Showing",no t = MyWin(root,no) print "Canceled",no root=Tk() win_number=0 Button(root, text="New Window",command=new_window).pack() root.mainloop() ---- when I run it and create 3 windows (0,1 and 2), and then "<Escape>" them in the order of their creation I get the following: Showing 0 Showing 1 Showing 2 Canceling 0 Canceling 1 Canceling 2 Canceled 2 Canceled 1 Canceled 0 it seems that MyWin(root,x) for a window only returns, after the MyWin() for all the windows created AFTER x have returned (?!) Am I making any sense? Does anyone have an explanation, or - preferably - a fix ? Thanks in advance, Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4