Hello,
I need help with creating 6 buttons can I do that using some loop and how can that be done?
each button has a different image and different text...their bg, and dimensions are the same
Also after creating all the buttons I want to make a callback function for each the function is the same as the one I have created for the first button except for the text in the label.
Please help me, I am merely a beginner.
Thank you very much,
your help is appreciated.
Here is my code: #note:the 3 radiobuttons are in the function. anything after that is not in the function; i couldn't fix the spacing
import ImageTk
from Tkinter import*
root=Tk()
root.title("Replicate DNA yourself!")
position=IntVar()
def fhelicase():
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=tophelicase.destroy).pack()
bh2=Radiobutton(tophelicase,text='2',variable=position,value=2,bg="green",command=tophelicase.destroy).pack()
bh3=Radiobutton(tophelicase,text='3',variable=position,value=3,bg="green",command=tophelicase.destroy).pack()
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)
gyrase=ImageTk.PhotoImage(file="gyrase.gif")
Gyrase=Button(root,text="gyrase",height=70,width=85,image=gyrase,compound="top",bg="white")
Gyrase.image=gyrase
Gyrase.grid(row=1)
ligase=ImageTk.PhotoImage(file="ligase.gif")
Ligase=Button(root,text="Ligase",height=70,width=85,image=ligase,compound="top",bg="white")
Ligase.image=ligase
Ligase.grid(row=2)
ssb=ImageTk.PhotoImage(file="ssbb.gif")
Ssb=Button(root,text="ssb",height=70,width=85,image=ssb,compound="top",bg="white")
Ssb.image=ssb
Ssb.grid(row=3)
primase=ImageTk.PhotoImage(file="primase.gif")
Primase=Button(root,text="primase",height=70,width=85,image=primase,compound="top",bg="white")
Primase.image=primase
Primase.grid(row=4)
helicase=ImageTk.PhotoImage(file="helicase.gif")
Helicase=Button(root,text="Helicase",height=70,width=85,image=helicase,compound="top",bg="white")
Helicase.image=helicase
Helicase.grid(row=5)
pol1=ImageTk.PhotoImage(file="pol1.gif")
Pol1=Button(root,text="DNA PolymeraseI",height=70,width=85,image=pol1,compound="top",bg="white")
Pol1.image=pol1
Pol1.grid(row=6)
window.mainloop()