tkinter mainloop

ast nomail at
Thu Nov 20 10:50:22 CET 2014

"Rick Johnson" <rantingrickjohnson at> a écrit dans le message de 
news:3385be62-e21c-4efe-802e-8f7351155aa4 at

> You don't need to call "mainloop()" when building Tkinter
> widgets on the command-line, but for *real* scripts i believe
> you'll need to. For instance, if you run the following code
> you will see a window with a label inside:

You are right
In fact, I used to open *.py programs with IDLE and then I run
programs from IDLE menu. With this way, mainloop( ) is not
I tried to double click on a *.py to run a program. Without
mainloop( ), the console appears a split seconds, then
deseapears, and that's all. With mainloop( ) it works.

>> > Second question, is it possible to cancel a mainloop() ?
> I don't think you meant to say "cancel", did you really mean
> "pause"?
>> > I neeed this feature because I have a main window "root
>> > = Tk()" which opens a Toplevel secondary window "top =
>> > Toplevel()" and I would like root window to be frozen
>> > while the user fills the top window.
> Sounds like you're trying to create a modal dialog, yes?
> Tkinter has a few methods for handling such cases. One is
> called "wait_window" and another is called "quit", with
> "wait_window" being preferred over "quit" for most tasks.
> There are also methods for setting the input "focus" and
> "grab". A good example for you to look at is the
> tkSimpleDialog.Dialog class.

tkinter.simpledialog.askstring is exactly what I need


More information about the Python-list mailing list