【发布时间】:2018-02-12 23:55:10
【问题描述】:
在这段代码中,我想return 一个超出集合function 的值,但不能。
我该怎么办?
from tkinter import *
temp= 0
def sel():
selection = "You selected the option " + str(var.get())
label.config(text = selection)
temp=selection
return temp
root = Tk()
var = IntVar()
R1 = Radiobutton(root, text="Option 1", variable=var, value=1,
command=sel)
R1.pack( anchor = W )
R2 = Radiobutton(root, text="Option 2", variable=var, value=2,
command=sel)
R2.pack( anchor = W )
R3 = Radiobutton(root, text="Option 3", variable=var, value=3,
command=sel)
R3.pack( anchor = W)
label = Label(root)
label.pack()
print (sel())
root.mainloop()
print 函数为什么不显示结果?
【问题讨论】:
-
我认为您需要先阅读一些教程以了解 tkinter 的工作原理。并请修正语法错误和拼写错误。这很难阅读。
-
还给哪里?