[Tkinter-discuss] a question on the top level window

V H haofast2006 at hotmail.com
Tue Jun 6 12:24:45 CEST 2006


Hi all,

I use a button  to generate a toplevel window. I hope only one such window 
is existing before I close it manually. But now each time when I click the 
button a new window is created. How can I do?

How do I bind a function to the close of the window by clicking the cross in 
the up-right side?

Following is a example program. You solution or suggetstiong is very 
appreciated .

regards,
Vning



from Tkinter import *
root = Tk()
class App:
  def __init__(self, master):
        c = Button(master, text="Only one")
	c.bind("<Button-1>", lambda e, s=self:s.cb(master))
        c.pack()
  def cb(self,master):#, event):
        win = Toplevel(master)
	win.title("one")
	frame= Frame(win)
        b=Button(frame, text='ok', command=win.quit)
	b.pack()
        frame.pack()
app=App(root)
root.mainloop()

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.com/



More information about the Tkinter-discuss mailing list