【发布时间】:2023-01-11 12:01:30
【问题描述】:
我尝试显示单选按钮的当前变量,但它似乎仍保持为零的初始值。
我的代码如下:
single_magnet_plot_style=IntVar(value=0)
单选按钮变量赋值:
scatter_rbtn=Radiobutton(window, text="Scatter Plot", variable=single_magnet_plot_style,value=1)
scatter_rbtn.place(relx=0.4,y=600)
line_rbtn=Radiobutton(window, text="Line Plot", variable=single_magnet_plot_style,value=2)
line_rbtn.place(relx=0.6, y=600)
标签显示:
new_label=Label(window, text=single_magnet_plot_style.get(), fg='red', font=("Helvetica", 13))
new_label.place(relx=0.5, y=550,anchor=CENTER)
在我的窗口,标签一直保持在 0 值。
从单选按钮值返回 new_label 有什么建议吗?
【问题讨论】: