Nov-06-2019, 07:52 PM
Hello everyone. I'm pretty new to Python, so this is probably basic. I have tried about a million different things, and have gone though everything I can find on google, but can't seem to get this to work. I've got a data entry gui I'm working on, and am trying to check the state of a checkbutton, and can't seem to get it to work. Here's what I've got:
def efs_form():
efs_arr_Time = Entry(efs_ef, width=18)
efs_arr_Time.grid(row=1, column=1, padx=(1, 5), pady=5)
#
# ...
#
global chb_var
chb_var = IntVar()
# Average Checkbox
efs_avg_chb = Checkbutton(efs_ef,
text="Include in Average",
variable=chb_var,
onvalue=1,
offvalue=0,
bg='black',
fg='Light Blue',
selectcolor='black',
font=("Comic Sans MS", 8, "bold"))
efs_avg_chb.grid(row=3, column=1, pady=(20, 10), sticky=W)
efs_avg_chb.toggle()
# Submit Button
efs_sub_btn = Button(efs_ef, text="Submit", command=sub_efs_data, width=18, bg="dark blue", fg="light blue")
efs_sub_btn.grid(row=8, column=4, pady=50, sticky=W)def sub_efs_data():
db_conn = sqlite3.connect('EFS_Samples.db')
c = db_conn.cursor()
if chb_var.get():
cu_avg = "Checked"
else:
cu_avg = "Unchecked"
efs_arr_Time.delete(0, END)
efs_arr_Time.insert(0, cu_avg)For some reason, I can only get it to say "Unchecked". Any suggestions would be greatly appreciated.
