Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tkinter listboxes

Status
Not open for further replies.

brotherjustice

Programmer
Joined
Jun 19, 2003
Messages
5
Location
CA
I keep getting this message. I'm sure i've just left out a
bracket somewhere or something but I've been beating my head of my monitor for while now. Any help would be greatly appreciated

here is my code:
class displayclicbox:

def __init__(self,boxname,col,rowd):

Label(HeroEntry,text=boxname,font = ("arial", 16)).grid(row=0,column=col,columnspan=2)

valuebox=Listbox(HeroEntry,height=19,width=2,selectmode=SINGLE,exportselection=0)
valuebox.grid(column=col,row=rowd)
valuechoices=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
for item in valuechoices:
valuebox.insert(END,item)

colorbox=Listbox(HeroEntry,height=10,width=10,selectmode=SINGLE,exportselection=0)
colorbox.grid(column=col+1,row=rowd)
colorchoices=["PURPLE","BROWN","DARK BLUE","GREEN","BLUE","ORANGE","YELLOW","RED","GREY","BLACK"]
for item in colorchoices:
colorbox.insert(END,item)
valuebox.activate(1)
colorbox.activate(1)

def getvalue(displayclicbox):
x=displayclicbox
return x.valuebox.get(1)

from Tkinter import *

HeroEntry=Tk()
HeroEntry.title("Hero Enty Form")
speed=displayclicbox("SPEED",1,2)
attack=displayclicbox("ATTACK",5,2)
defense=displayclicbox("DEFENSE",9,2)
damage=displayclicbox("DAMAGE",13,2)

here is my error message:

Traceback (most recent call last):
File "F:\Python22\displayclicbox.py", line 34, in ?
print getvalue(damage)
File "F:\Python22\displayclicbox.py", line 23, in getvalue
return x.valuebox.get(1)
AttributeError: displayclicbox instance has no attribute 'valuebox'
 
In your class initialization, I think instead of:

valuebox=Listbox

you should have:

self.valuebox=Listbox

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top