Python Forum
[tkinter] not getting checkbutton value when clicked
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[tkinter] not getting checkbutton value when clicked
#6
I would not use callbacks for the Checkbuttons at all. Checkbuttons have a value, so there is no reason to make another variable just to keep the checkbutton's value. The value of the Checkbutton is avialable through the tkinter variable you bound to the Checkbutton's var. Keep those in a list and use the list to get (or set) the values for all the Checkbuttons.

When you press the search button the callback would scan through all the checkbutton variables and add the associated name to the search when the checkbutton is pressed. Maybe it would be better to make the checkbuttons True/False and bind to a BooleanVar.
for index, checked in enumerate(checkbutton_vars):
    if checked.get():
        add_name_to_search(index)
Reply


Messages In This Thread
RE: [tkinter] not getting checkbutton value when clicked - by deanhystad - Sep-20-2020, 04:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Button clicked not working catlessness 10 8,219 Oct-21-2021, 12:36 PM
Last Post: catlessness
  [Tkinter] Hide clicked buttons Rubberduck 6 3,536 Jun-02-2021, 12:44 PM
Last Post: Rubberduck
  Checkbutton writing selection to file blakefindlay 1 2,108 Jan-28-2021, 01:56 PM
Last Post: deanhystad
Question [Tkinter] Checkbutton clicks events does not update visually. nicolaask 1 2,985 Dec-20-2020, 06:11 PM
Last Post: nicolaask
  [Tkinter] How to insert 'Checkbutton' to 'Treeview' and associate each item? water 2 13,189 Dec-19-2020, 05:24 PM
Last Post: water
  Find Checkbutton State PEGylated_User 3 3,109 Oct-23-2020, 12:43 AM
Last Post: Larz60+
  [PyQt] Avoid clicked event from button when button is not physically selected and clicked mart79 2 2,346 May-05-2020, 12:54 PM
Last Post: mart79
  [Tkinter] ttk.Checkbutton set on/off ifigazsi 5 10,460 Apr-04-2020, 07:34 PM
Last Post: deanhystad
  [Tkinter] Displaying Data from a database and run a function when clicked? PythonNPC 1 2,065 Mar-11-2020, 08:16 PM
Last Post: Larz60+
  tkinter checkbutton if checked MC2020 2 5,986 Jan-21-2020, 07:08 PM
Last Post: joe_momma

Forum Jump:

User Panel Messages

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