[Tkinter-discuss] Re: Modal dialog behavior
Michael Lange
klappnase at web.de
Wed Mar 23 11:33:56 CET 2005
Martin, Jeff, Russell,
thanks for the replies,
> Could you share a small snippet of code that exhibits this behavior? I
> use XFCE4 by default but can test with at least GNOME (I think I still
> have KDE on an older machine somewhere...) I also have a couple of
> version of Tk installed so we can at least narrow it down
A minimal code example that shows this behavior:
###############################
#!/usr/bin/env python
from Tkinter import *
class ModalDialog(Toplevel):
def __init__(self, master=None, **kw):
Toplevel.__init__(self, master, **kw)
self.withdraw()
def show(self):
self.deiconify()
self.transient(self.master)
self.grab_set()
def main():
root = Tk()
top = ModalDialog(root)
b = Button(root, text='Show', command=lambda:root.after(3000, top.show))
b.pack()
root.mainloop()
if __name__ == '__main__':
main()
#################################
> Several things you can try:
> - Update to the current Tk (8.4.9). (You could search the tk bug
> database first.)
> - Roll your own dialog box. How are you creating it anyway?
> tkMessageBox? There are some "interesting" differences between Tkinter's
> dialog boxes and the code suggested in Welch's "Practical Programming in
> Tcl and Tk". I don't remember the details at the moment, but after
> running into nasty problems with tkSimpleDialog.askfloat I ended up
> writing my own dialog boxes*, mostly following Welch but with a few
> changes that proved desirable for MacOS X aqua.
>
I use Pmw.Dialog.activate() for modal dialogs. Unfortunately updating Tk is not much of
an option, because I want it to work with any Tk >= 8.3.3 .
Maybe the quick workaround to make the one dialog in my program where this is likely to
happen non-modal will be the best for now.
Thanks and best regards
Michael
More information about the Tkinter-discuss
mailing list