Tkinter help - Why this behavior ? (py3)

Terry Reedy tjreedy at udel.edu
Wed Jun 9 16:40:23 EDT 2010


On 6/9/2010 1:13 PM, Dodo wrote:

>> import Tkinter as tk
>> from Tkconstants import *
>> import tkSimpleDialog
>>
>> class MyDialog(tkSimpleDialog.Dialog):
>> def body(self, master):
>> prompt = "Hello from my custom dialog!\nAlthough with
>> something this simple i should have used tkMessageBox."
>> tk.Label(self, text=prompt).pack()
>>
>> def validate(self):
>> print 'I need to put some code here, maybe'
>> return True
>>
>> def apply(self):
>> print 'I need to put some code here, maybe'
>>
>>
>> class App(tk.Tk):
>> def __init__(self):
>> tk.Tk.__init__(self)
>> b=tk.Button(self, text='Show Dialog', command=self.showDialog)
>> b.pack(padx=5, pady=5)
>>
>> def showDialog(self):
>> d = MyDialog(self)
>>
>> if __name__ == '__main__':
>> app = App()
>> app.mainloop()
>
> Could you please explain to me what's the big difference?

What Rick wrote is pretty standard and similar to the example in Lib Ref 
24.1.2.2. A Simple Hello World Program and others you can find. It get 
the right things done in the right place, and just once.




More information about the Python-list mailing list