python单选按钮默认不选中_python-Tkinter单选按钮默认未选
中-堆栈内存溢出
我很茫然。 即使我遵循了有关单选按钮的各种教程,默认情况下也不会检查我的单选按钮。 不确定我在做什么错,我将默认单选按钮设置为False按钮。
这是我的代码:
import tkinter as tk
k as ttk
lorchooser import *
class ExampleView(tk.Frame):
def __init__(self, *args, **kwargs):
tk.Frame.__init__(self, *args, **kwargs)
""" create StringVars for our shape fill radio button group """
shape_fill_status = tk.StringVar()
""" create radio button group for turning off shape fill """
shape_fill_frame = tk.Frame(self)
shape_fill_label = tk.Label(shape_fill_frame, text="Fill Shape: ", anchor="w")
shape_fill_label.pack(side=tk.LEFT, padx = 10)
shape_fill_false = tk.Radiobutton(shape_fill_frame, text = "False", variable = shape_fill_status, value = 0)
shape_fill_true = tk.Radiobutton(shape_fill_frame, text = "True", variable = shape_fill_status, value = 1)
shape_fill_status.set(0)
shape_fill_false.pack(side=tk.LEFT, padx = 10)
htmlradio的text出不来shape_fill_true.pack(side=tk.LEFT, padx = 10)
shape_id(row=0, column=0, stick="w")
if __name__ == "__main__":
root = tk.Tk()
view = ExampleView(root)
view.pack(side="top", fill="both", expand=True)
root.wm_geometry("400x200")
root.mainloop()
这是我的tkinter⼩部件的样⼦:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论