[Python-bugs-list] [ python-Bugs-472727 ] Tkinter.mainloop() confuses IDLE (original) (raw)

noreply@sourceforge.net noreply@sourceforge.net
Fri, 19 Oct 2001 04:19:06 -0700


Bugs item #472727, was opened at 2001-10-19 04:18 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=472727&group_id=5470

Category: IDLE Group: None Status: Open Resolution: None Priority: 5 Submitted By: Edward Loper (edloper) Assigned to: Guido van Rossum (gvanrossum) Summary: Tkinter.mainloop() confuses IDLE

Initial Comment: Cause:

  1. create a Tk window
  2. call Tkinter.mainloop()
  3. close the Tk window created in (1)

Result:

  1. IDLE doesn't return to a Python prompt.
  2. IDLE won't close, unless you kill it from the task manager.

Code sample:

import Tkinter Tkinter.tk() Tkinter.mainloop()

Presumably, this happens because IDLE is using Tk itself, and is not isolating the Python interactive shell from itself well enough. It's possible that solving this problem would require changes to kinter?
But at the very least, it should be ocumented. A workaround (posted by stefan kusch) is to use the following test to see if you're running in IDLE with:

_inidle = type(sys.stdin) == types.InstanceType and
sys.stdin.class.name == 'PyShell'

and not call mainloop() if you're in IDLE.

But, of course, a real fix is preferable to a workaround :)

A web search turned up several mentions of this, but I didn't see a bug report for it, so I figured I'd submit one.


You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=472727&group_id=5470