This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tkinter.mainloop() confuses IDLE
Type: Stage:
Components: IDLE Versions:
process
Status: closed Resolution: later
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: edloper, gvanrossum
Priority: normal Keywords:

Created on 2001-10-19 11:18 by edloper, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (2)
msg7056 - (view) Author: Edward Loper (edloper) * (Python triager) Date: 2001-10-19 11:18
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.
msg7057 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-10-19 13:42
Logged In: YES 
user_id=6380

There's nothing you can do about this without a serious
restructuring of IDLE, to run the Python code in a separate
process. We're thinking about that, and for scripts (as
opposed to the >>> shell window) it's alread implemented in
the "idlefork" project on SF, where most of the development
on IDLE is going on.

I'm going to close this bug report with a "Later"
annotation.
History
Date User Action Args
2022-04-10 16:04:32adminsetgithub: 35356
2001-10-19 11:18:58edlopercreate