[Tutor] TKinter and IDLE problem

Gregor Lingl glingl@aon.at
Tue Dec 10 04:22:02 2002


AFIS, this is a well known problem when using
IDLE with Tkinter. IT has it's origin in the fact,
that IDLE itself is a Tkinter-App, so there is
already an active mainloop there.

Solution: if you use or develop TKinter-programs
with IDLE, comment out (or delete)  the
root.mainloop() statement.

However, if you want to run your app without
IDLE you have to uncomment or insert it again.

A nice idiom, to accomplish this is as follows below:


Dick Moores schrieb:

>
>
> What am I doing wrong?
>
> Thanks,
>
> Dick Moores
> rdm@rcblue.com
>
> ========================
> # File: hello1.py
>
> from Tkinter import *

  usingIDLE = 1   # True

  # code of your app

>
> root = Tk()
>
> w = Label(root, text="Hello, world!")
> w.pack()

  if not usingIDLE:
      root.mainloop()

# you turn mainloop on by setting
# usingIDLE = 0

>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>