Я в растерянности. Мои радиокнопки по умолчанию не проверяются, хотя я следовал различным инструкциям для радиокнопок. Не уверен, что я делаю неправильно, я устанавливаю переключатель по умолчанию на кнопку False.
Вот мой код:
import tkinter as tk
import tkinter.ttk as ttk
from tkinter.colorchooser 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)
shape_fill_true.pack(side=tk.LEFT, padx = 10)
shape_fill_frame.grid(row=0, column=0, stick="w")
self.grid_columnconfigure(0, weight=1)
if __name__ == "__main__":
root = tk.Tk()
view = ExampleView(root)
view.pack(side="top", fill="both", expand=True)
root.wm_geometry("400x200")
root.mainloop()
А вот как выглядит мой виджет tkinter:
