Python Tk\u tkinter.TclError:无效的命令名“.42818376”

2024-06-11 21:38:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我得到的错误提到的标题,我真的只想这一个工作。已经研究这个问题有一段时间了,这很令人沮丧。我的最终目标是获取varables文本、chkvar和v的值

感谢所有能回复和帮助我们的人!!

#!C:/Python27/python.exe

from Tkinter import *
import ImageTk, Image

root = Tk()
root.title('HADOUKEN!')

def killwindow():
  root.destroy()

text = Text(root, height=16, width=40)
scroll = Scrollbar(root, command=text.yview)

text.configure(yscrollcommand=scroll.set)

text.grid(sticky=E)
scroll.grid(row=0,column=1,sticky='ns')

text.focus()

chkvar = IntVar()
chkvar.set(0)
c = Checkbutton(root, text="CaseIt", variable=chkvar)
c.grid(row=1,column=0,sticky=W)

v = ""
radio1 = Radiobutton(root, text="Src", variable=v, value=1)
radio1.grid(row=1,column=0)
radio1.focus()

radio2 = Radiobutton(root, text="Dst", variable=v, value=2)
radio2.grid(row=2,column=0)

b1 = Button(root, text="Submit", command=killwindow)
b1.grid(row=1, column=2)

img = ImageTk.PhotoImage(Image.open("Hadoken.gif"))
panel = Label(root, image = img)
panel.grid(row=0, column=2)

root.mainloop()


tk1 = text.get(text)
tk2 = chkvar.get(chkvar)
tk3 = v.get(v)


print tk1
print tk2
print tk3

Tags: textimageimportgetcolumnrootvariablegrid