John McMonagle wrote:
> Gigs_ wrote:
>> from Tkinter import *
>> from tkFileDialog import askopenfilename
>> from tkColorChooser import askcolor
>> from tkMessageBox import askquestion, showerror
>> from tkSimpleDialog import askfloat
>>
>> demos = {
>> 'Open': askopenfilename,
>> 'Color': askcolor,
>> 'Query': lambda: askquestion('Warning', 'You typed
>> "..."\nConfirm?'),
>> 'Error': lambda: showerror('Error!', "He's dead, Jim"),
>> 'Input': lambda: askfloat('Entry', 'Enter credit card number')
>> }
>>
>>
>> class Demo(Frame):
>> def __init__(self, parent=None):
>> Frame.__init__(self, parent)
>> self.pack()
>> Label(self, text="Basic demos").pack()
>> for (key, value) in demos.items():
>> func = (lambda: self.printit(key))
>> Button(self, text=key, command=func).pack(side=TOP,
>> fill=BOTH)
>> def printit(self, name):
>> print name, 'returns =>', demos[name]()
>>
>>
>> I have tried but cant get it to work properly.
>> I want to instead printit method to put __call__ and call it like that
>> Can someone help me, please?
>
> Add the following lines to the end of your script and all should work as
> expected:
>
> root = Tk()
> app = Demo(root)
> root.mainloop()
>
I have write root window, but forgot to write here
I want to use __call__ method instead printit
--
http://mail.python.org/mailman/listinfo/python-list