Python单选按钮没有显示?

时间:2016-07-20 17:16:27

标签: python user-interface tkinter radio-button

我在YouTube上通过Python教程跟踪GUI,我无法在消息框中显示单选按钮,它对视频作者起作用。我没有收到任何错误消息,是否有一段我的代码不正确或我做错了什么?

#create radio buttons; input equal to a value of a string and will come up checked
dayStatus = StringVar()
dayStatus.set(None)
radio1 = Radiobutton(app, text="I'm feeling good", value="I'm feeling good", variable = dayStatus, command=beenClicked).pack
#clicked radio calls the been clicked command
radio1 = Radiobutton(app, text="I'm feeling crummy", value="I'm feeling crummy", variable = dayStatus, command=beenClicked).pack

button1 = Button(app, text="Click Here", width=20,command=changeLabel)
button1.pack(side='bottom',padx=15,pady=15)

1 个答案:

答案 0 :(得分:0)

您需要通过在行尾添加大括号()来更正这两行:

radio1 = Radiobutton(app, text="I'm feeling good", value="I'm feeling good", variable = dayStatus, command=beenClicked).pack()
radio1 = Radiobutton(app, text="I'm feeling crummy", value="I'm feeling crummy", variable = dayStatus, command=beenClicked).pack()