Cant check multiple Checkbuttons in a tkinter frame

202 views Asked by At

I am trying to code a self writing DnD character sheet, on this character sheet I have multiple buttons within frames something like this:

from tkinter import *


root = Tk()
root.title("Character Sheet")

var= IntVar()


pro_bonus= Entry(extras_frame, width=5)
pro_bonus.grid(row=2, column=0)

str_ab_label= LabelFrame()
str_ab_label.grid(row=4, column=1, ipady=50, ipadx=9)

str_save_check= Checkbutton(str_ab_label, variable=var, onvalue=pro_bonus.get, offvalue=0)
str_save_check.grid(row=0, column=0)

athletics_check= Checkbutton(str_ab_label, variable=var, onvalue=pro_bonus.get, offvalue=0)
athletics_check.grid(row=1, column=0)

at current I can only check one or the other of those two options and not both, how would I go about fixing this ?

1

There are 1 answers

0
Bryan Oakley On

Checkbuttons are designed to use a unique variable for each checkbutton. Because your checkbuttons share the same variable, by definition they must be set to the same value. You can't have one variable set to two different values.