I tried to create those 6 radiobuttons(bh1,bh2,bh3,bh4,bh5,bh6) using a for and placing them in a dictionary but I get the following error whenever they should be displayed! I have attached a folder with the images. Any help please is highly appreciated!
Thank you

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:Python27liblib-tkTkinter.py", line 1410, in __call__
    return self.func(*args)
  File "C:Documents and SettingsadmenDesktopTKtktktk.py", line 255, in fhelicase
    generalenz()
  File "C:Documents and SettingsadmenDesktopTKtktktk.py", line 243, in generalenz
    button.grid(in_=instructions,row=i,column=1)
  File "C:Python27liblib-tkTkinter.py", line 1901, in grid_configure
    + self._options(cnf, kw))
TclError: can't put .23728656.23728856 inside .23729376

.

import ImageTk
import tkMessageBox
from Tkinter import*
from turtle import *
import time

root = Tk()#main window
root.title("Test Yourself_DNA Replication")#title of my main window

########################################################## GLOBAL VARIABLES #######################################################################

global position, info,  step, answ, statement, advice
position = IntVar()#choice of position of enzyme-variable used in RadioButtons
info = StringVar()#string of instructions dispalyed to the user in the label in the frame at the bottom of the window
info.set("choose enzyme^")
step = 1# a count for the step of DNA replication we are in
answ = StringVar()#a variable to store users answers to some popup questions-used in another set of radiobuttons
statement = StringVar()#a variable that holds the text in a label in popup windows
advice = StringVar()#a variable to hold the hint for the different steps

##################################################################################################################################################
window = Canvas(root, width=800, height=480, bg="white")#my canvas is named window
window.grid(column=1, rowspan=6, row=0, columnspan=5)
title = Label(root, text="Replicate DNA yourself!", bg="white", font=("Helvetica", 23))#a title at the top of my canvas
title.grid(column=2, row=0)
instructions = Frame(root, bg="purple", relief="sunken", height=200, width=800, bd=5, padx=10, pady=5)#frame at the bottom of rootwindow-will contain instructions
instructions.grid(column=1, columnspan=3, row=6, rowspan=1)
instructions.columnconfigure(0, weight=1)#arranging the grid of the frame 
instructions.columnconfigure(1, weight=1)#arranging the grid of the frame 
instructions.columnconfigure(2, weight=1)#arranging the grid of the frame 
instructions.rowconfigure(0, weight=1)#arranging the grid of the frame 
instructions.grid_propagate(False)#so that the frame does not shrink to the size of its contents
label = Label(instructions, bg="green", fg="white", anchor="center", textvariable=info, justify="center", font=("Helvetica", 23))#label in frame
label.grid(in_=instructions, row=0, rowspan=1, column=1, columnspan=1, sticky="n")
Help = Label(root, bg="black", fg="white", textvariable=advice, justify="left",
            font=("Comic Sans Ms", 11), height=34, width=25, padx=10, anchor="ne", wraplength=195)#create label in root window on the right
Help.grid_propagate(False)#so that the label does not shrink to the size of its contents
Help.grid(row=0, rowspan=7, column=6, columnspan=2)

############################################################ OTHER GLOBALS ########################################################################
global radioButtons, lsst #global radio buttons and a global list of those buttons
lsst=['bh1','bh2','bh3','bh4','bh5','bh6']
radioButtons={}
i=1
for button in lsst:
    radioButtons[button]=Radiobutton(instructions,text=str(i),variable=position,value=i,bg="blue")
    i+=1

###################################################################################################################################################

title = Label(root, text="Replicate DNA yourself!", bg="white", font=("Helvetica", 23))#a title at the top of my canvas
title.grid(column=2, row=0)
instructions = Frame(root, bg="purple", relief="sunken", height=200, width=800, bd=5, padx=10, pady=5)#frame at the bottom of rootwindow-will contain instructions
instructions.grid(column=1, columnspan=3, row=6, rowspan=1)
instructions.columnconfigure(0, weight=1)#arranging the grid of the frame 
instructions.columnconfigure(1, weight=1)#arranging the grid of the frame 
instructions.columnconfigure(2, weight=1)#arranging the grid of the frame 
instructions.rowconfigure(0, weight=1)#arranging the grid of the frame 
instructions.grid_propagate(False)#so that the frame does not shrink to the size of its contents
label = Label(instructions, bg="green", fg="white", anchor="center", textvariable=info, justify="center", font=("Helvetica", 23))#label in frame
label.grid(in_=instructions, row=0, rowspan=1, column=1, columnspan=1, sticky="n")
Help = Label(root, bg="black", fg="white", textvariable=advice, justify="left",
            font=("Comic Sans Ms", 11), height=34, width=25, padx=10, anchor="ne", wraplength=195)#create label in root window on the right
Help.grid_propagate(False)#so that the label does not shrink to the size of its contents
Help.grid(row=0, rowspan=7, column=6, columnspan=2)

def clear():#called when the button in the label on the right is clicked, it clears the label 
    global advice, okay
    advice.set("")#removes all text in label
    okay.grid_remove()#removes the button in label

def hint():#called when button [give me a hint] is pressed, it changes the text in the label depending on the point at which the button is pressed
    global advice
    if step==1:
        advice.set("helicase,aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel aseel ")
    elif step==2:
        advice.set("gyrase")
    elif step==3:
        advice.set("ssb")
    elif step==4 or step==5:
        advice.set("primase")
    elif step==6:
        advice.set("Pol3")
    elif step==7:
        advice.set("Pol1")
    else:
        advice.set("We are done")
    global okay
    okay = Button(Help, bg="yellow", fg="black", text="ok", font=("Times", 10,"bold"),
                  activebackground="orange", command=clear)#button in the label on right
    okay.grid(in_=Help, row=50, column=2)

Hint = Button(root, bg="blue", text="Give me a hint", font=("Times", 10,"bold"), fg="white",
              height=3, activebackground="green", command=hint)#create button [give me hint]
Hint.grid(row=6, column=0)


########################################################################################################################################################
def generalradio():#this function increments the step and removes the radiobuttons in the frame at the bottom and changes label in that frame
    global step, radioButtons #the purpose of it is to avoid writing those steps in 7 other functions
    step+=1
    info.set('choose next enzyme')
    for button in radioButtons.values():
        button.grid_remove()

def radioh():
    global position
    if position.get()==1:
        window.delete(ALL)
        window.create_image(400,300,image=after_helicase)
        generalradio()
    else:
        info.set('wrong position')

def radiog():
    global position
    if position.get()==2:
        window.delete(ALL)
        window.create_image(400,300,image=after_gyrase)
        generalradio()
    else:
        info.set('wrong position')

def radios():
    global position
    if position.get()==3:
        window.delete(ALL)
        window.create_image(400,300,image=after_ssb)
        generalradio()
    else:
        info.set('wrong position')

def radiop11():
    window.delete(ALL)     
    window.create_image(400,300,image=after_prymase1b)
    generalradio()

def radiop1():
    global position
    if position.get()==4:
        window.create_image(400,300,image=after_prymase1a)
        window.after (1000,func=radiop11)
    else:
        info.set('wrong position')
def radiop222():
    window.delete(ALL)
    window.create_image(400,300,image=after_prymase2c)
    generalradio()

def radiop22():
    window.delete(ALL)
    window.create_image(400,300,image=after_prymase2b)
    window.after (1000,func=radiop222)

def radiop2():
    global position
    if position.get()==4:
        window.create_image(400,300,image=after_prymase2a)
        window.after (1000,func=radiop22)
    else:
        info.set('wrong position')

def radio3dd():
    window.delete(ALL)
    window.create_image(400,300,image=after_pol3e)
    generalradio()

def radio3d():
    global position
    if position.get()==2:
        window.delete(ALL)
        window.create_image(400,300,image=after_pol3d)
        window.after (1000,func=radio3dd)
    else: info.set('try again!')

def radio3cc():
    window.delete(ALL)
    window.create_image(400,300,image=choose_pol3d)
    global radioButtons
    for button in radioButtons.values():
        button.configure(command=radio3d)

def radio3c():
    global position
    if position.get()==1:
        window.delete(ALL)
        window.create_image(400,300,image=after_pol3c)
        window.after (1000,func=radio3cc)
    else: info.set("try again!")

def radio3bb():
    window.delete(ALL)
    window.create_image(400,300,image=choose_pol3c)
    global radioButtons
    for button in radioButtons.values():
        button.configure(command=radio3c)

def radio3b():
    global position
    if position.get()==5:
        window.delete(ALL)
        window.create_image(400,300,image=after_pol3b)
        window.after (1000,func=radio3bb)
    else:info.set("try again!")

def radio3aa():
    window.delete(ALL)
    window.create_image(400,300,image=choose_pol3b)
    global radioButtons
    for button in radioButtons.values():
        button.configure(command=radio3b)

def radio3a():
    global position
    if position.get()==3:
        window.delete(ALL)
        window.create_image(400,300,image=after_pol3a)
        window.after (1000,func=radio3aa)
    else:
        info.set('wrong position')

def radio11():
    window.create_image(400,300,image=after_pol1b)
    generalradio()
    info.set("We Are Done =D n dsDNA has been polymerized nusing semiconservative replicationn well done")


def radio1():
    global position
    if position.get()==1:
        window.create_image(400,300,image=after_pol1a)
        window.after (1000,func=radio11)
    else:
        info.set('wrong position')


################################################# FUNCTIONS CALLED WHEN BUTTON IS PRESSED ############################################################
def generalenz():
    info.set("where should it be placed?")
    global lsst
    i=1
    for button in radioButtons.values():
        button.grid(in_=instructions,row=i,column=1)
        if button["text"] != 'bh6':
            button.deselect()
        else:
            button.select()
        i+=1

def fhelicase():
    global step
    if step==1:
        window.delete(ALL)
        window.create_image(400,300,image=choose_helicase)
        generalenz()
        global radioButtons
        for button in radioButtons.values():
            button.configure(command=radioh)    
    else:
        global info
        info.set("try again")

def fgyrase():
    if step==2:
        window.delete(ALL)
        window.create_image(400,300,image=choose_gyrase)
        generalenz()
        global radioButtons
        for button in radioButtons.values():
            button.configure(command=radiog) 
    else:
        info.set("try again")

def fssb():
    if step==3:
        window.delete(ALL)
        window.create_image(400,300,image=choose_ssb)
        generalenz()
        global radioButtons
        for button in radioButtons.values():
            button.configure(command=radios) 
    else:
        info.set("try again")
def clickOk():
    global quest
    quest.destroy()
    window.create_image(400,300,image=choose_prymase1)
    generalenz()
    global radioButtons
    for button in radioButtons.values():
        button.configure(command=radiop1)

def fquest():
    global statement
    if answ.get()=='low':
        statement.set("That's wrong =( n  The upper strand is the leading strand as polymerization is continuous.")
    else:
        statement.set("That's true, well done :) nLet's start by polymerizing it first as it undergoes continuous replication.")
    global quest,bup,blow
    bup.grid_remove()
    blow.grid_remove()
    ok=Button(quest,bg="yellow", text="OK",activebackground="orange", command=clickOk).grid(row=3,column=3)

def fprimase():
    if step==4:
        window.delete(ALL)
        global quest,answ,bup,blow
        quest=Toplevel(root,bg="yellow")
        quest.overrideredirect(True)
        quest.geometry('475x80+350+300')
        poptxt=Label(quest,bg="yellow",textvariable=statement,justify="center",font=("Times",11,"bold")).grid(row=0,column=3)
        statement.set(" Which is the leading strand in this case? The upper or the lower?")
        bup=Radiobutton(quest,bg="yellow",text="upper strand",font=("Times",12),activebackground="orange",variable=answ,value='up',command=fquest)
        bup.grid(row=1,column=3)
        blow=Radiobutton(quest,bg="yellow",text="lower strand",font=("Times",12),activebackground="orange",variable=answ,value='low',command=fquest)
        blow.grid(row=2,column=3)
        bNo=Radiobutton(quest,bg="yellow",text="no strand",font=("Times",12),activebackground="yellow",variable=answ,value='none',command=fquest)
        bup.deselect()
        blow.deselect()
        bNo.select()
    elif step==5:
        window.delete(ALL)
        tkMessageBox.showinfo("","Now that the leading strand is all ready to be polymerized,n it's the lagging strand's turn to get ready!")
        window.create_image(400,300,image=choose_prymase2)
        generalenz()
        global radioButtons
        for button in radioButtons.values():
            button.configure(command=radiop2)
    else:
        info.set("try again")


def fpol3():
    if step==6:
        window.delete(ALL)
        window.create_image(400,300,image=choose_pol3a)
        generalenz()
        global radioButtons
        for button in radioButtons.values():
            button.configure(command=radio3a) 
    else:
        info.set("try again")

def fpol1():
    global radioButtons
    if step==7:
        window.delete(ALL)
        window.create_image(400,300,image=choose_pol1)
        i=0
        option=["2,6,7,4","4,1,5,3","2,1,6,5","7,3,5,4","1,4,2,6","2,3,4,5"]
        for button in radioButtons.values():
            button.configure(text=option[i],value=i)
            i+=1
        generalenz()
        for button in radioButtons.values():
            button.configure(command=radio1) 
    else:
        info.set("try again")


#################################### BUTTONS #################################

pol3=ImageTk.PhotoImage(file="pol3.gif")
Pol3=Button(root,height=72,width=89,text="DNA Polymerase III",image=pol3,compound="top",bg="white",command=fpol3)
Pol3.image=pol3
Pol3.grid(row=0)

gyrase=ImageTk.PhotoImage(file="gyrase.gif")
Gyrase=Button(root,text="gyrase",height=72,width=89,image=gyrase,compound="top",bg="white",command=fgyrase)
Gyrase.image=gyrase
Gyrase.grid(row=1)

ssb=ImageTk.PhotoImage(file="ssbb.gif")
Ssb=Button(root,text="ssb",height=72,width=89,image=ssb,compound="top",bg="white",command=fssb)
Ssb.image=ssb
Ssb.grid(row=2)

primase=ImageTk.PhotoImage(file="primase.gif")
Primase=Button(root,text="primase",height=72,width=89,image=primase,compound="top",bg="white",command=fprimase)
Primase.image=primase
Primase.grid(row=3)

helicase=ImageTk.PhotoImage(file="helicase.gif")
Helicase=Button(root,text="Helicase",height=72,width=89,image=helicase,compound="top",bg="white",command=fhelicase)
Helicase.image=helicase
Helicase.grid(row=4)

pol1=ImageTk.PhotoImage(file="pol1.gif")
Pol1=Button(root,text="DNA PolymeraseI",height=72,width=89,image=pol1,compound="top",bg="white",command=fpol1)
Pol1.image=pol1
Pol1.grid(row=5)

##############################################################################


start=ImageTk.PhotoImage(file="start.gif")
choose_helicase=ImageTk.PhotoImage(file="choose_helicase.gif")
after_helicase=ImageTk.PhotoImage(file="after_helicase.gif")
choose_gyrase=ImageTk.PhotoImage(file="choose_gyrase.gif")
after_gyrase=ImageTk.PhotoImage(file="after_gyrase.gif")
choose_ssb=ImageTk.PhotoImage(file="choose_ssb.gif")
after_ssb=ImageTk.PhotoImage(file="after_ssb.gif")
choose_prymase1=ImageTk.PhotoImage(file="choose_prymase1.gif")
after_prymase1a=ImageTk.PhotoImage(file="after_prymase1a.gif")
after_prymase1b=ImageTk.PhotoImage(file="after_prymase1b.gif")
choose_prymase2=ImageTk.PhotoImage(file="choose_prymase2.gif")
after_prymase2a=ImageTk.PhotoImage(file="after_prymase2a.gif")
after_prymase2b=ImageTk.PhotoImage(file="after_prymase2b.gif")
after_prymase2c=ImageTk.PhotoImage(file="after_prymase2c.gif")
choose_pol3a=ImageTk.PhotoImage(file="choose_pol3a.gif")
choose_pol3b=ImageTk.PhotoImage(file="choose_pol3b.gif")
choose_pol3c=ImageTk.PhotoImage(file="choose_pol3c.gif")
choose_pol3d=ImageTk.PhotoImage(file="choose_pol3d.gif")
after_pol3a=ImageTk.PhotoImage(file="after_pol3a.gif")
after_pol3b=ImageTk.PhotoImage(file="after_pol3b.gif")
after_pol3c=ImageTk.PhotoImage(file="after_pol3c.gif")
after_pol3d=ImageTk.PhotoImage(file="after_pol3d.gif")
after_pol3e=ImageTk.PhotoImage(file="after_pol3e.gif")
choose_pol1=ImageTk.PhotoImage(file="choose_pol1.gif")
after_pol1a=ImageTk.PhotoImage(file="after_pol1a.gif")
after_pol1b=ImageTk.PhotoImage(file="after_pol1b.gif")

window.create_image(400,300,image=start)
window.mainloop()

Looks like in_=instructions, is not a grid option, so leave it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.