can someone please help me I am facing a problem;
I want to draw an image in the canvas depending on the value of the IntVar called position
however I get an error;
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "C:\Documents and Settings\admen\Desktop\tk.py", line 20, in inn
if read() ==1:
File "C:\Documents and Settings\admen\Desktop\tk.py", line 18, in read
return position.get()
AttributeError: 'function' object has no attribute 'get'
Here is my code: #note: the three rdiobuttons are in the function. i couldn't fix the spacing.
def fhelicase():
global tophelicase
tophelicase=Toplevel(bg="green",bd=10)
labhelicase=Label(tophelicase,text="Where should helicase be placed?",bg="green").pack()
bh1=Radiobutton(tophelicase,text='1',variable=position,value=1,bg="green",command=inn).pack()
bh2=Radiobutton(tophelicase,text='2',variable=position,value=2,bg="green",command=inn).pack()
bh3=Radiobutton(tophelicase,text='3',variable=position,value=3,bg="green",command=inn).pack()
def read():
return position.get()
def inn():
if read() ==1:
xx,yy=10,10
elif read()==2:
xx,yy=60,60
elif read()==3:
xx,yy=110,110
window.create_image(xx,yy,image=pol3)
tophelicase.destroy()
pol3=ImageTk.PhotoImage(file="pol3.gif")
Pol3=Button(root,height=70,width=85,text="DNA Plymerase III",image=pol3,compound="top",bg="white",command=fhelicase)
Pol3.image=pol3
Pol3.grid(row=0)
window=Canvas(root,width=800,height=550,bg="white")
window.grid(column=1, rowspan=4,row=0)
window.mainloop()