Frame widget (title and geometry)

  • Thread starter Shankar Iyer (siyer
  • Start date
S

Shankar Iyer (siyer

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.

Shankar
 
E

Eric Brunel

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:
.... pass
....
just works. If you have to add anything in the constructor, do not forget to call the constructor for Frame in it, as in:
.... def __init__(self, *args, **options):
.... Frame.__init__(self, *args, **options)
.... ## Other stuff...
....

If you do that, everything should be OK.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,260
Messages
2,571,301
Members
47,944
Latest member
LillianPra

Latest Threads

Top