When you tkSimpleDialog.askinteger, the program stalls and waits for user input. What are the basics of writing my own method that would have the same effect? I want to make the same kind of dialog box, I just want to be able to request more information. The problem that I'm having is that when I open the new window using Tk.Toplevel, the program does not wait for user input the way tkSimpleDialog.askinteger does.
A:
First off, if you can use some other widget system like PyGtk or PyQt, you should seriously consider it. Tkinter is ancient, and the newer libraries have a lot more functionality (read: more things you don't have to reinvent). I've used PyGtk and like it a lot more than Tkinter, which I used in the old Python 1.x days.
That said, in Tkinter, you need to do this:
widget.wait_window(window)
This ties up the event loop waiting for the user to dismiss the dialog.
Reference: http://www.pythonware.com/library/tkinter/introduction/dialog-windows.htm
Mike DeSimone
2010-03-26 22:55:49
@Mike DeSimone: tk "may die someday"? What evidence do you have of that? It is a mature, robust, actively developed toolkit.
Bryan Oakley
2010-03-27 14:42:39
Sorry, fixed. It was wishful thinking on my part; just looked it up and noticed "CameronLaird calls the yearly decision to keep TkInter "one of the minor traditions of the Python world." (http://wiki.python.org/moin/TkInter)". I still feel that the Gtk or Qt based libraries would be better to develop against. Those times I got a Tkinter program to behave, it ran very slow, due to everything having to be converted to strings for Tcl.
Mike DeSimone
2010-03-27 16:21:27
yes PyQt/wxPython etc are good for a product but for small scripts where you do not want to install anything extra on target machine Tkinter is good enough
Anurag Uniyal
2010-03-31 05:48:22