TK question

James Stroud jstroud at mbi.ucla.edu
Thu Oct 20 22:41:21 EDT 2005


optWin() will create a callable object which is an instance of the class 
optWin. Calling this callable object will call the __call__() method with the 
behavior you anticipate. You also need to import Tk from Tkinter and call Tk 
"Tk" and not "tk".

Meditate on the following :


from Tkinter import *

class optWin:

    def __init__(self):
        return None

    def __call__(self):
        self.root = Tk()
        self.root.title("My title")
        self.root.mainloop()
        return None

ow = optWin()
ow()


James

On Thursday 20 October 2005 19:16, MBW wrote:
> class optWin:
>
>     def __init__(self):
>         return None
>
>     def __call__(self):
>         self.root = tk()
>         self.root.title("My title")
>         self.root.mainloop()
>         return None

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/



More information about the Python-list mailing list