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
#4
The reason result.val() is always False is because you create the BooleanVar and never bind it to a control. result is used as an arg to the callback, but there is no control bound to result and no way to change the value of result.
        result = tk.BooleanVar()
        search_members_button = ttk.Button(centersearch, text="Search", command=lambda: self.get_display_options_selected(result), state='active')
        search_members_button.grid(row=7, column=5, columnspan=2, pady=15)
The reason your function always prints False is because you always print the value of the unbound BooleanVal result when what you really want is the value of the display_member_name Checkbutton IntVariable display_name_val.
    def get_display_options_selected(self,result):
        self.result = result
        print("inside def before getting value", result.get()) # Using input arg
        self.result = self.display_name_val.get()
        print("inside def after getting value", result.get()) # Still using input arg
        return (self.result)
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Button clicked not working catlessness 10 8,303 Oct-21-2021, 12:36 PM
Last Post: catlessness
  [Tkinter] Hide clicked buttons Rubberduck 6 3,590 Jun-02-2021, 12:44 PM
Last Post: Rubberduck
  Checkbutton writing selection to file blakefindlay 1 2,129 Jan-28-2021, 01:56 PM
Last Post: deanhystad
Question [Tkinter] Checkbutton clicks events does not update visually. nicolaask 1 3,017 Dec-20-2020, 06:11 PM
Last Post: nicolaask
  [Tkinter] How to insert 'Checkbutton' to 'Treeview' and associate each item? water 2 13,268 Dec-19-2020, 05:24 PM
Last Post: water
  Find Checkbutton State PEGylated_User 3 3,136 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,375 May-05-2020, 12:54 PM
Last Post: mart79
  [Tkinter] ttk.Checkbutton set on/off ifigazsi 5 10,548 Apr-04-2020, 07:34 PM
Last Post: deanhystad
  [Tkinter] Displaying Data from a database and run a function when clicked? PythonNPC 1 2,076 Mar-11-2020, 08:16 PM
Last Post: Larz60+
  tkinter checkbutton if checked MC2020 2 6,021 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