import tkinter as tk root = tk.Tk() check_button = tk.Checkbutton(root, text="Option 1") check_var = tk.BooleanVar() check_button.config(variable=check_var, onvalue=True, offvalue=False) check_button.pack() root.mainloop()
import tkinter as tk root = tk.Tk() radio_button1 = tk.Radiobutton(root, text="Option 1", value=1) radio_button2 = tk.Radiobutton(root, text="Option 2", value=2) radio_button3 = tk.Radiobutton(root, text="Option 3", value=3) radio_var = tk.BooleanVar() radio_button1.config(variable=radio_var) radio_button2.config(variable=radio_var) radio_button3.config(variable=radio_var) radio_button1.pack() radio_button2.pack() radio_button3.pack() root.mainloop()In the above examples, we can see that we have imported the "tkinter" package and created objects using the "BooleanVar()" class. Therefore, the package library for Python Tkinter BooleanVar is "tkinter".