[Tutor] tkinter.TclError

brandon w thisisonlyatest at gmx.com
Sun Aug 14 07:11:26 CEST 2011


Here is the code:

#!/usr/bin/python

from Tkinter import *
from tkMessageBox import *

def iClicked():
     radioValue = relStatus.get()
     tkMessageBox.showinfo("You clicked", radioValue)
     return

def chLabel():
     name = "Thank you for clicking me. " + your_name.get()
     labelText.set(name)
     your_name.delete(0, END)
     your_name.insert(0, "My name is Simon.")
     return

myapp = Tk()
myapp.title("This is the gui title")
myapp.geometry("500x500+600+600")

labelText = StringVar()
labelText.set("Click button")
label0 = Label(myapp, textvariable=labelText, height=4)
label0.pack()

chkbx = IntVar()
chkbx0 = Checkbutton(myapp, variable=chkbx, text="Hungry?")
chkbx0.pack()

a_name = StringVar()
your_name = Entry(myapp, textvariable=a_name)
your_name.pack()

# Once this section is commented out the window opens but without the 
radio buttons.
# I have attempted many variations of the two lines.
relStatus = StringVar()
relStatus.set(None)
#radio0 = Radiobutton(myapp, text="had breakfast", value="had 
breakfast", variable=relStatus, commmand=iClicked).pack(anchor=W)
#radio0 = Radiobutton(myapp, text="did not eat breakfast", value="did 
not eat breakfast", variable=relStatus, commmand=iClicked).pack(anchor=W)
#radio1 = Radiobutton(myapp, master=None, text="had breakfast", 
value="had breakfast", variable=relStatus, commmand=iClicked).pack()
#radio1 = Radiobutton(myapp, master=None, text="did not eat breakfast", 
value="did not eat breakfast", variable=relStatus, commmand=iClicked).pack()
#radio1 = Radiobutton(myapp, text="had breakfast", value="had 
breakfast", variable=relStatus, commmand=iClicked).pack()
#radio1 = Radiobutton(myapp, text="did not eat breakfast", value="did 
not eat breakfast", variable=relStatus, commmand=iClicked).pack()
#radio0 = Radiobutton(master, text="had breakfast", value="had 
breakfast", variable=myapp, commmand=iClicked).pack()
#radio0 = Radiobutton(master, text="did not eat breakfast", value="did 
not eat breakfast", variable=myapp, commmand=iClicked).pack()
radio1 = Radiobutton(master=myapp, text="had breakfast", value="had 
breakfast", variable=relStatus, commmand=iClicked).pack()
radio1 = Radiobutton(master=myapp, text="did not eat breakfast", 
value="did not eat breakfast", variable=relStatus, commmand=iClicked).pack()
# Something is wrong with the two lines above?

button0 = Button(myapp, text="Click me", width=20, command=chLabel)
button0.pack(side='bottom', padx=15, pady=15)

myapp.mainloop()

Here is the error:

$ python tktest.py

*Traceback (most recent call last):
   File "tkwindow.py", line 54, in <module>
     radio1 = Radiobutton(master=myapp, text="had breakfast", value="had 
breakfast", variable=relStatus, commmand=iClicked).pack()
   File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 2732, in __init__
     Widget.__init__(self, master, 'radiobutton', cnf, kw)
   File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1935, in __init__
     (widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: unknown option "-commmand"*


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110814/52655620/attachment.html>


More information about the Tutor mailing list