Python Forum
Checkbuttons always come up as black boxes regardless of the state
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Checkbuttons always come up as black boxes regardless of the state
#2
state does not do what you think it does. state is used for styling a ttk widget. You use "selected" in combination with "state" to specify how a widget should appear when selected.

The way to get and set the value of ttk.Checkbutton is use tkinter variables.
from tkinter import *
from tkinter import ttk

mw = Tk()
mw.geometry('700x300+400+200')
frame3 = Frame(mw)
framebot = Frame(mw)
frame3.pack(side=TOP,fill=X)
framebot.pack(side=BOTTOM,fill=X)
 
w3 = Label(frame3, text="Checkbuttons: ",font=("Times",16)).grid(row=0,column=0)
check_buttons = []
for i in range(1, 7):
    value = BooleanVar()
    button = ttk.Checkbutton(frame3, text=str(i), variable=value)
    check_buttons.append(value)
    value.set(i % 2 == 0)
    button.grid(row=i,column=0) 
mw.mainloop()
Reply


Messages In This Thread
RE: Checkbuttons always come up as black boxes regardless of the state - by deanhystad - Jul-07-2020, 04:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Draw bounding boxes on live feed Jerome 0 338 Jan-20-2024, 10:50 PM
Last Post: Jerome
  remove all color but red, then replace it with black kucingkembar 14 7,279 Dec-29-2021, 07:50 PM
Last Post: deanhystad
  How to read check boxes from word document srikanthpython 0 2,655 Mar-30-2021, 01:58 PM
Last Post: srikanthpython
  How to use nb-black python cde formatter ErnestTBass 3 6,897 Jun-04-2020, 03:51 PM
Last Post: ErnestTBass
  Finance: Black Scholes Model not working pwt 5 3,988 May-27-2020, 10:14 AM
Last Post: buran
  after using openpyxl to add colors to script, black shows up white online in excel Soundtechscott 1 3,716 Jun-08-2019, 10:33 PM
Last Post: Soundtechscott
  State graph Kaluss 1 2,275 Mar-18-2019, 05:29 PM
Last Post: nilamo
  Because the emoji appears black and white at the exit ? nerd 3 5,656 Jan-28-2019, 11:34 PM
Last Post: nerd
  Help with plot, how to show ranking with boxes icebelt 1 2,482 Jan-25-2019, 10:00 AM
Last Post: Larz60+
  Python interface only black and white........ Wilson 3 6,215 Jul-15-2017, 01:20 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020