On 07/14/2010 01:51 PM, Hayathms wrote:
PLease anyone help me ,,
program not running
------------------------------------------------------------------------------------
from tkinter import ttk
from tkinter import *
class Hami(ttk.Frame):
def __init__(self,master=None):
ttk.Frame.__init__(self,master,borderwidth=5)
self.grid(column=0,row=0,sticky=('W,E,N,S'),padx=5,pady=5)
class Honey(ttk.Label):
def __init__(self,master=None,te='Honey'):
ttk.Label.__init__(master,text=te)
self.grid(column=0,row=0)
root=Tk()
root.title('Employee')
root.option_add('*tearOff',FALSE)
sam=Hami(root)
harmain=Honey(master=sam)
root.mainloop()
------------------------------------------------------------------------------------
Error is ---->
Traceback (most recent call last):
File "C:/Python31/hayathhh.py", line 20, in <module>
harmain=Honey(master=sam)
File "C:/Python31/hayathhh.py", line 13, in __init__
self.grid(column=0,row=0)
File "C:\Python31\lib\tkinter\__init__.py", line 1843, in grid_configure
self.tk.call(
AttributeError: 'Honey' object has no attribute 'tk'
>>>
Here is *one* clear problem. Others may exist.
Since Honey is derived from ttk.Label, Honey's constructor must call
Label's constructor, (which you do), *however* when called as
ttk.Label.__init__, you must provide it with the 'self' parameter.
class Honey(ttk.Label):
def __init__(self,master=None,te='Honey'):
ttk.Label.__init__(*self*,master,text=te) # self parameter
added here
self.grid(column=0,row=0)
--
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418
--
http://mail.python.org/mailman/listinfo/python-list