Is it necessary to call Tk() when writing a GUI app with Tkinter?
johnjsal at gmail.com
Thu Mar 1 06:40:14 CET 2012
> Yes, but i think the REAL problem is faulty code logic. Remove the
> last line "root.destroy()" and the problem is solved. Obviously the
> author does not have an in-depth knowledge of Tkinter.
The faulty code is not my own, which is part of the reason I asked the question. The book I'm reading (The Quick Python Book) does not use it, but I saw in the Python docs that it is there, under "tkinter" in the Global Module Docs, "126.96.36.199. A Simple Hello World Program":
from tkinter import *
print("hi there, everyone!")
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.hi_there = Button(self)
self.hi_there["text"] = "Hello",
self.hi_there["command"] = self.say_hi
def __init__(self, master=None):
root = Tk()
app = Application(master=root)
More information about the Python-list