On Fri, 24 Jun 2005 10:21:01 -0400, Shankar Iyer ([EMAIL PROTECTED]) <[EMAIL 
PROTECTED]> wrote:

> Hi,
>
> I am still new to Python and Tkinter, so I apologize in advance if I do not
> word my question optimally.  I am trying to use a frame widget as the parent
> for other widgets.  There is a class with the header "class 
> classtitle(Frame):"
> in a script called classtitle.py.  Having imported classtitle, I create a 
> Frame
> widget within my gui using the command "w = Frame(self)."  Then, I grid this
> widget and issue the command "classinstance = classtitle.classtitle(w)."  When
> I attempt to execute this code, I receive an error claiming that w lacks
> geometry and title attributes that the code in classtitle.py attempts to 
> access.
> Does this mean that I cannot use a Frame widget as w in this situation?  
> Thanks
> for your help.

Please post a short script showing the behavior you get. Without this, we 
cannot help you much. The only thing I can tell you right now is that you 
obviously don't need to create a Frame via "w = Frame(self)": since you defined 
your classtitle class as a sub-class of frame, every instance of classtitle is 
also an instance of Frame, so you can use it as such:

>>> from Tkinter import *
>>>root = Tk()
>>> class MyClass(Frame):
...     pass
...
>>> o = MyClass(root)
>>> o.grid()

just works. If you have to add anything in the constructor, do not forget to 
call the constructor for Frame in it, as in:

>>> class MyClass(Frame):
...     def __init__(self, *args, **options):
...             Frame.__init__(self, *args, **options)
...             ## Other stuff...
...

If you do that, everything should be OK.

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in 
'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to