Python20, tcl8.3.2 , IDLE 0.6, mainloop doesn't terminate

Anton Vredegoor anton at vredegoor.doge.nl
Thu May 3 17:12:44 EDT 2001


On Thu, 03 May 2001 10:00:44 GMT, stefan2k1de at yahoo.de (stefan kusch)
wrote:

>Hi folks,
>I've got the following problem running a python20/ tcl8.3.2 Tkinter
>application 
>in python shell IDLE 0.6 under windows 2000SP1.
>
>My programm generates a window with a button.
>When pushing the button the program should terminate, but
>tk.mainloop() doesn't.
>The problem only appear running the program under python shell IDLE
>0.6. 
>Running the program with the command line interpreter is working
>correctly.
>
>where is the error?
>who knows an answer?

Your program and Idle are sharing some tk-resources.

>
>Thanks a lot
>Stefan
>
>------ Sample Code ----------
>import Tkinter
>from Tkconstants import *
>tk = Tkinter.Tk()
>frame = Tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
>frame.pack(fill=BOTH,expand=1)
>button = Tkinter.Button(frame,text="Exit",command=tk.destroy)
>button.pack(side=BOTTOM)
>tk.mainloop()
>-----------------------------

Try this :

import Tkinter
from Tkconstants import *
import sys, types

_inidle = type(sys.stdin) == types.InstanceType and \
	  sys.stdin.__class__.__name__ == 'PyShell'

tk = Tkinter.Tk()
frame = Tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
frame.pack(fill=BOTH,expand=1)
button = Tkinter.Button(frame,text="Exit",command=tk.destroy)
button.pack(side=BOTTOM)

if not _inidle:
    tk.mainloop()





More information about the Python-list mailing list