On 2020-11-03 20:11, David Burnette wrote:
On Wednesday, April 18, 2007 at 12:33:24 AM UTC-7, Chris wrote:
Hi,
I'm puzzled by some strange behavior when my Python/Tkinter
application quits (on linux): the terminal from which I started Python
is messed up.
If start up python, then import the code below, then start the program
with Application(), then click the Quit button, my terminal never
prints anything again (such as commands I type).
<code>
import Tkinter
import sys
class Application(Tkinter.Tk):
def __init__(self,**config):
Tkinter.Tk.__init__(self,**config)
Tkinter.Button(self,text="Quit",command=self.quit_application).pack()
def quit_application(self):
sys.exit()
</code>
Can anyone tell me what I'm doing wrong?
Thanks for your help.
Chris
I notice this same behavior with other tk applications like "tkdiff".
So what is the correct cleanup for a proper exit from a plain Tk application?
Updated to Python 3, it should be more like this:
import tkinter
import sys
class Application(tkinter.Tk):
def __init__(self,**config):
tkinter.Tk.__init__(self, **config)
tkinter.Button(self, text="Quit",
command=self.quit_application).pack()
def quit_application(self):
self.destroy()
Application().mainloop()
--
https://mail.python.org/mailman/listinfo/python-list