【发布时间】:2017-02-28 17:56:11
【问题描述】:
我有这个 python 脚本。我找不到我犯了什么错误。谁能告诉我我在这个程序中犯了什么错误?
from tkinter import *
root=Tk()
v=IntVar()
s=IntVar()
def sel():
x=v.get()
if x==1:
l2.config(text="correct")
else:
l2.config(text="wrong")
z=s.get()
if z==1:
l3.config(text="correct")
else:
l3.config(text="wrong")
l=Label(root,text="what is 2 + 2 ?")
l.pack(anchor=W)
R1=Radiobutton(root,text="4",variable=v,value=1)
R1.pack(anchor=W)
R2=Radiobutton(root,text="5",variable=v,value=2)
R2.pack(anchor=W)
l2=Label(root)
l2.pack()
l2=Label(root,text="what is 5 + 9?")
l2.pack(anchor=W)
R3=Radiobutton(root,text="14",variable=s,value=1)
R3.pack(anchor=W)
R4=Radiobutton(root,text="5",variable=s,value=2)
R4.pack(anchor=W)
l3=Label(root)
l3.pack()
root.mainloop()
【问题讨论】:
-
你的计划目标是什么?
-
我想在每个问题之后打印在标签“写/错误”上..但是当我点击单选按钮时它不打印
-
为什么单选按钮在被点击时知道调用哪个函数?
标签: python-2.7 python-3.x tkinter