Dear all,

in my application I would like to have a "Help" button in every dialog that opens the common help window. The problem is that the Dialog window has the "grab_set" activated so when I open the help window, all the events are still redirected to the Dialog. The Help window appears on screen but is inactive. Is there a way to specify that the Help window is for example a separate thread and still handles the events in parallel of the Dialog which has the grab_set for the rest of the program? Below you can find an example on what I am trying to do, if the user first clicks on the "Dialog" button and then from the dialog window clicks on "Help" the Help window is frozen.

from Tkinter import *

class Help:
   def __init__(self, master):
       self.toplevel = Toplevel(master)
       frame = Frame(self.toplevel, bg="Yellow")
       frame.pack(expand=YES, fill=BOTH)
t = Label(frame, text="The quick brown fox jumps\nover the lazy dogs tail")
       t.pack()
       b = Button(frame, text="Quit", padx=50, command=self.quit)
       b.pack()
       self.toplevel.title("Help")
       self.toplevel.protocol("WM_DELETE_WINDOW", self.quit)

   def show(self):
       self.toplevel.wait_visibility()

   def quit(self, event=None):
       self.toplevel.destroy()

class Dialog:
   def __init__(self, master):
       self.toplevel = Toplevel(master)
       frame = Frame(self.toplevel, bg="Blue")
       frame.pack(expand=YES, fill=BOTH)
       b = Button(frame, text="Help", padx=50, command=self.help)
       b.pack()
       b = Button(frame, text="Quit", padx=50, command=self.quit)
       b.pack()
       self.toplevel.title("Dialog")
       self.toplevel.protocol("WM_DELETE_WINDOW", self.quit)

   def show(self):
       self.toplevel.grab_set()
       self.toplevel.wait_window()

   def quit(self, event=None):
       self.toplevel.destroy()

   def help(self, event=None):
       help = Help(root)
       help.show()

def dialog():
   dlg = Dialog(root)
   dlg.show()

def help():
   win = Help(root)
   win.show()

def quit():
   root.destroy()

# -----
root = Tk()
root.title("Root")
Button(root, text="Dialog", padx=50, command=dialog).pack()
Button(root, text="Help", padx=50, command=help).pack()
Button(root, text="Quit", padx=50, command=quit).pack()
root.mainloop()

begin:vcard
fn:Vasilis Vlachoudis
n:Vlachoudis;Vasilis
org:CERN;AB
adr:CERN;;Dep.AB;Geneva-23;;CH-1211;Switzerland
email;internet:[EMAIL PROTECTED]
title:Dr
tel;work:+41-22-767.9851
tel;fax:+41-22-766.9644
tel;cell:+41-76-487.4378
x-mozilla-html:FALSE
url:http://home.cern.ch/bnv
version:2.1
end:vcard

_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to