Tkinter: IDLE can't get out of mainloop

Discussion in 'Python' started by Frederic Rentsch, Mar 31, 2012.

  1. Hi all,

    Is is a bad idea to develop Tkinter applications in IDLE? I understand
    that IDLE is itself a Tkinter application, supposedly in a mainloop and
    mainloops apparently don't nest.

    I tried to install a root-destroy-protocol:

    def destroy_root ():
    print 'Destroying root'
    root.destroy ()

    root.protocol ("WM_DELETE_WINDOW", destroy_root)

    I see the tracing message 'Destroying root', but stay stuck unable to
    get the IDLE prompt back. Ctr-C doesn't work. The only way out I know is
    killing IDLE. When I do, a warning says that a program is still running.
    That must be IDLE's own WM_DELETE_WINDOW protocol. Is there a way to get
    the prompt back without killing IDLE? Is there a way to nest a
    mainloop?
    Up to now I have been able to get by without a mainloop. I suppose
    this is because I have only been doing layouts. Starting now to do
    events I observe what in the absence of a mainloop looks like
    synchronization problems with bindings responding to other events than
    their own.
    If I run from a terminal things seem to work out. Is it standard
    development practice to run code from a terminals ($ python program.py)?
    What's the 'program.pyc' for if the source is compiled every time?
    I use Python 2.6 on Ubuntu 10.04 LTS.

    Thankful for any suggestion

    Frederic
    Frederic Rentsch, Mar 31, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Roth

    Re: Tk mainloop()

    John Roth, Jul 20, 2003, in forum: Python
    Replies:
    0
    Views:
    370
    John Roth
    Jul 20, 2003
  2. dan

    Re: Tk mainloop()

    dan, Jul 20, 2003, in forum: Python
    Replies:
    0
    Views:
    449
  3. k2riddim

    Problem with tkinter mainloop

    k2riddim, Nov 30, 2004, in forum: Python
    Replies:
    2
    Views:
    1,381
    k2riddim
    Nov 30, 2004
  4. Replies:
    0
    Views:
    472
  5. Peter Otten
    Replies:
    2
    Views:
    767
    John McMonagle
    Mar 15, 2009
Loading...

Share This Page