O.K. I tried from scratch, and the following snippet produces an 
infinite loop saying:

   File "C:\Python24\lib\lib-tk\Tkinter.py", line 1647, in __getattr__
       return getattr(self.tk, attr)

If I comment out the __init__ method, I get the titled window, and print 
out self.var ('1')


import  os
from Tkinter import *

class MyApp(Tk):
     var=1
     def __init__(self):
       pass
     def getval(self):
       return self.var


app = MyApp()

app.title("An App")
print app.getval()
app.mainloop()


Eric Brunel wrote:
> On Mon, 18 Jul 2005 16:57:51 GMT, William Gill <[EMAIL PROTECTED]> wrote:
> 
>> A short while ago someone posted that(unlike the examples) you should
>> use Tk as the base for your main window in tkinter apps, not Frame.   
>> Thus :
>>
>>    class MyMain(Frame):
>>            def __init__(self, master):
>>                self.root = master
>>                self.master=master
>>                self.createWidgets()
>>            def createWidgets():
>>                 ...
>>        root = Tk()
>>        app = MyMain(root)
>>        app.master.title("Object Editor")
>>        root.mainloop()
>>
>> would become:
>>
>>     class MyMain(Tk):
>>        ...
>>        ...
>>     app = MyMain()
>>     app.title("My App")
>>     app.mainloop()
>>
>> When I try converting to this approach I run into a problem with the
>> __init__() method.  It appears to go into an infinite loop in
>> tkinter.__getattr__().
> 
> [...]
> 
> I never ran into this problem. Can you please post a short script 
> showing this behavior? Without knowing what you exactly do in your 
> __init__ and createWidgets method, it's quite hard to figure out what 
> happens...
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to