Tkinter programming problem
andrew.gregory at npl.co.uk
Mon Aug 4 12:01:53 CEST 2003
Many thanks for such a comprehensive answer.
Altered root.wait_window(mainWin.frame) to root.mainloop()
and found that it runs and closes ok within IDLE. I seem to remember
having crashes on closing within IDLE before.
I did try self.frame.destroy as the function
self.frame.destroy(), but the Quit button still didn't work. The
application can be closed via the window corner X, but I'm still
puzzled as to why it does not respond to Quit.
Any more suggestions?
Updated code below, Andrew.
# Demonstration TK interface Windows application
# Runs ok from within IDLE
from Tkinter import *
class CommonStuff: # to get common access to variables and functions
def __init__(self, frame):
self.frame = frame
print "Hello all"
class MyWidgets(Frame, CommonStuff):
def __init__(self, CS):
self.quitbutton = Button(self, text='Quit', fg='red',
self.hi_there = Button(self, text='Hello', command=CS.say_hi)
def __init__(self, master):
CS = CommonStuff(self.frame)
def quit(self, event):
self.frame.destroy() # Destroy frame and all children
root = Tk()
mainWin = Application(root)
More information about the Python-list