tkinter doubt

Chris Rebert clp2 at rebertia.com
Thu Jun 10 04:22:09 EDT 2010


On Thu, Jun 10, 2010 at 12:48 AM, Thomas Jollans <thomas at jollans.com> wrote:
> On 06/10/2010 08:50 AM, madhuri vio wrote:
>> # File: hello2.py
>>
>> from Tkinter import *
>>
>> class App:
>>
>>     def __init__(self, master):
>>
>>         frame = Frame(master)
>>         frame.pack()
>>
>>         self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
>>
>>         self.button.pack(side=LEFT)
>>
>>         self.hi_there = Button(frame, text="Hello", command=self.say_hi)
>>         self.hi_there.pack(side=LEFT)
>>
>>     def say_hi(self):
>>         print "hi there, everyone!"
>>
>>
>> root = Tk()
>>
>> app = App(root)
>>
>> root.mainloop()
>>
>> in this program i wanted to  get a clear idea about this
>>
>>
>> def __init__(self, master):
>>
>>         frame = Frame(master)
>>
>>         frame.pack()
>>
>>         self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
>>         self.button.pack(side=LEFT)
>>
>>         self.hi_there = Button(frame, text="Hello", command=self.say_hi)
>>
>>         self.hi_there.pack(side=LEFT)
>>
>> what is _init_...self and master...
> read up on object-orientation with Python

In particular, see the official tutorial's section on objects & classes:
http://docs.python.org/tutorial/classes.html

Read it after you're done with
http://www.catb.org/~esr/faqs/smart-questions.html

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list