Help - Frame class in tkinter is playing up

Thread Solved
Reply

Join Date: Aug 2005
Posts: 138
Reputation: a1eio is an unknown quantity at this point 
Solved Threads: 21
a1eio's Avatar
a1eio a1eio is offline Offline
Junior Poster

Help - Frame class in tkinter is playing up

 
0
  #1
Mar 17th, 2007
Hi,

I want to create a little Frame class that has two labels built in, the code snippet below is the class.
  1. class DescriptionFrame(Frame):
  2. def __init__(self, master, title="", text=""):
  3. Frame.__init__(master)
  4.  
  5. self.title = title
  6. self.text = text
  7.  
  8. self.titleLabel = Label(self, text=self.title, font=("Times", 12, "underline"), fg="darkred")
  9. self.titleLabel.grid(row=0, column=0, sticky=W)
  10.  
  11. self.mainLabel = Message(self, text=self.text, font=("Times", 10), fg="darkgreen")
  12. 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'
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
Last edited by a1eio; Mar 17th, 2007 at 1:10 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 608
Reputation: jrcagle is on a distinguished road 
Solved Threads: 149
jrcagle jrcagle is offline Offline
Practically a Master Poster

Re: Help - Frame class in tkinter is playing up

 
0
  #2
Mar 17th, 2007
Actually, you're very close. Line 3 should read

  1. Frame.__init__(self,master)

Jeff
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 138
Reputation: a1eio is an unknown quantity at this point 
Solved Threads: 21
a1eio's Avatar
a1eio a1eio is offline Offline
Junior Poster

Re: Help - Frame class in tkinter is playing up

 
0
  #3
Mar 17th, 2007
hahahahaha, niice.

thankyou very much, hehe i thought it was probable something simple.

a1eio
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC