jeudi 10 avril 2014

Python 2.7 - attribut erreur lorsque vous essayez de modifier une liste - Stack Overflow


Hi Got stuck since I am new to python.


I am trying to create a list of objects and I get an attribute error


here is my code for the this


class App(tk.Tk):

G_Lbl_text = []
G_Lbl = []

def __init__(self,*args,**kwargs):

tk.Tk.__init__(self,*args,**Kwargs)

self.init_labels()

self.G_Lbl_Text[0] = "Hello"
self.G_Lbl.insert(0,tk.Label(self,text=self.G_Lbl_Text[0]))
self.G_Lbl[0].pack()

def init_labels(self):

for x in range(0,100):
self.G_Lbl_Text.insert(x,"How are you!!")

Get following error message


file "VMS1.py" , line 388 , in <module>
app = App()
file "VMS1.py",line 93 ,in __init__
self.G_Lbl_Text[0] = "hello"
file "/usr/lib/python2.7/lib-tk/Tkinter.py" , line 1791 ,in __getattr__
return getattr(self.tk, attr)
AttributeError: G_Lbl_Text

Can someone help me please


Best Regards



Hi Got stuck since I am new to python.


I am trying to create a list of objects and I get an attribute error


here is my code for the this


class App(tk.Tk):

G_Lbl_text = []
G_Lbl = []

def __init__(self,*args,**kwargs):

tk.Tk.__init__(self,*args,**Kwargs)

self.init_labels()

self.G_Lbl_Text[0] = "Hello"
self.G_Lbl.insert(0,tk.Label(self,text=self.G_Lbl_Text[0]))
self.G_Lbl[0].pack()

def init_labels(self):

for x in range(0,100):
self.G_Lbl_Text.insert(x,"How are you!!")

Get following error message


file "VMS1.py" , line 388 , in <module>
app = App()
file "VMS1.py",line 93 ,in __init__
self.G_Lbl_Text[0] = "hello"
file "/usr/lib/python2.7/lib-tk/Tkinter.py" , line 1791 ,in __getattr__
return getattr(self.tk, attr)
AttributeError: G_Lbl_Text

Can someone help me please


Best Regards


0 commentaires:

Enregistrer un commentaire