473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Frame widget (title and geometry)

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

Jul 19 '05 #1
1 1816
On Fri, 24 Jun 2005 10:21:01 -0400, Shankar Iyer (si***@Princeton.EDU) <si***@Princeton.EDU> 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+-'])"
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Douglas Alan | last post by:
Is there a way to tell Tkinter that I'd like to allow a window to be resizable, but only down to the point where no widget clipping occurs? I know that to get the effect I want, I can always (1)...
2
by: PGMoscatt | last post by:
Hi All, I am trying to create a dialog which will have a number of components but having trouble with the placement of various widgets. For example, in my code below you will see I am trying...
3
by: D. Alvarado | last post by:
Hello, I am trying to find the <TITLE> element of my document. Normally alert(document.title); works just fine, but when this statement is within a page that is a frame in a larger document,...
2
by: Colin McKinnon | last post by:
Hi all, I've got two frames, one with a form ('main') and one with some clickable images ('tp'). The clickable images call a function in 'main' (code below) which in turn calls the .submit() or...
2
by: Matt | last post by:
all, trying to load an application (notepad for instance) and have it sit inside a Python application window. When the main window maximises or minimises, the (notepad) app follows. I am...
1
by: Gigs_ | last post by:
what is the best way to write tkinter menus? As toplevels or as frame with Menubutton? im doing like this class MyWidget(Frame): def __init__(self, master=None): """ should this master be...
4
Elias Alhanatis
by: Elias Alhanatis | last post by:
Hello everybody!! I would like some help with the following problem: I have the following piece of code: from Tkinter import * root = Tk()
0
by: noobuser | last post by:
Not sure if this question belongs here, so sorry if it doesn't. amature programmer here, trying making a media scale widget (like the one in windows media player) for a media player type program...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.