| | |
Help - Frame class in tkinter is playing up
Thread Solved |
Hi,
I want to create a little Frame class that has two labels built in, the code snippet below is the class.
The problem is on line 8, when i try to create the label i get this:
Now, i was under the opinion that including 'Frame' in brackets after naming the class meant all that 'stuff' (tk attribute for example) was there, and my code would work around it. I'm not too certain where to go from here..
thanks
a1eio
I want to create a little Frame class that has two labels built in, the code snippet below is the class.
python Syntax (Toggle Plain Text)
class DescriptionFrame(Frame): def __init__(self, master, title="", text=""): Frame.__init__(master) self.title = title self.text = text self.titleLabel = Label(self, text=self.title, font=("Times", 12, "underline"), fg="darkred") self.titleLabel.grid(row=0, column=0, sticky=W) self.mainLabel = Message(self, text=self.text, font=("Times", 10), fg="darkgreen") self.mainLabel.grid(row=1, column=0, columnspan=1, sticky=EW)
The problem is on line 8, when i try to create the label i get this:
•
•
•
•
Traceback (most recent call last):
File "C:/Python25/Dialouge1.py", line 34, in __init__
self.titleLabel = Label(self, text=self.title, font=("Times", 12, "underline"), fg="darkred")
File "C:\Python25\lib\lib-tk\Tkinter.py", line 2464, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "C:\Python25\lib\lib-tk\Tkinter.py", line 1923, in __init__
BaseWidget._setup(self, master, cnf)
File "C:\Python25\lib\lib-tk\Tkinter.py", line 1901, in _setup
self.tk = master.tk
AttributeError: DescriptionFrame instance has no attribute 'tk'
thanks
a1eio
Last edited by a1eio; Mar 17th, 2007 at 1:10 pm.
•
•
Join Date: Jul 2006
Posts: 608
Reputation:
Solved Threads: 150
Actually, you're very close. Line 3 should read
Jeff
Python Syntax (Toggle Plain Text)
Frame.__init__(self,master)
Jeff
![]() |
Similar Threads
- java and using observable class (Java)
- Tkinter Addressbook (Python)
- Tkinter window background (Python)
- Best GUI toolkit? (Python)
- Tkinter exception (Python)
- Java Internal frames (Java)
- Help w/ constructors (Java)
Other Threads in the Python Forum
- Previous Thread: frame by frame animation in pygame
- Next Thread: Multiple keypresses at once in pygame
| Thread Tools | Search this Thread |
alarm ansi assignment avogadro backend beginner binary bluetooth character cmd code customdialog cx-freeze data decimals dictionary directory dynamic error examples exe file float format function generator gnu graphics gui halp heads homework http ideas import input itunes java leftmouse line linux list lists loop maze module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyglet pyqt python random recursion schedule screensaverloopinactive script scrolledtext slicenotation sqlite ssh statistics string strings sudokusolver sum terminal text thread threading time tlapse tricks tuple tutorial ubuntu unicode urllib urllib2 variable ventrilo vigenere web webservice wikipedia write wxpython xlib





