Python Forum
[Tkinter] Checkboxes in different frames misbehave
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Checkboxes in different frames misbehave
#1
import tkinter as tk

root = tk.Tk() 
Frame1 = tk.Frame(root)
Frame2 = tk.Frame(root)

Frame1.pack()
Frame2.pack()

tk.Checkbutton(Frame1, text="checkbutton #1").pack()
tk.Checkbutton(Frame2, text="checkbutton #2").pack()

root.mainloop()
Why does it check both checkbuttons if I click only one and how can I make them independent without putting both in the same frame?
Reply
#2
Checkbuttons have an associated IntVar which controls them. A simple search will turn up lots of beginner examples.
Reply
#3
good writeup here: http://infohost.nmt.edu/tcc/help/pubs/tk...utton.html
this manual is also available for everything tkinter as a PDF and html format here:
pdf
web
Reply
#4
(Sep-25-2018, 03:32 PM)octoeder Wrote:
import tkinter as tk

root = tk.Tk() 
Frame1 = tk.Frame(root)
Frame2 = tk.Frame(root)

Frame1.pack()
Frame2.pack()

tk.Checkbutton(Frame1, text="checkbutton #1").pack()
tk.Checkbutton(Frame2, text="checkbutton #2").pack()

root.mainloop()
Why does it check both checkbuttons if I click only one and how can I make them independent without putting both in the same frame?

There are two independent frames and checkbuttons. You can see it simply by modifying:
Frame1 = tk.Frame(root, bg='red', padx=10)

And in my test, I didn't see both checkbuttons can be checked by a single click.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Manipulating Checkboxes teflon 8 3,821 Oct-02-2019, 11:27 PM
Last Post: teflon
  [Tkinter] Print if all checkboxes marked Kaelmi 10 18,689 May-24-2017, 02:17 PM
Last Post: buran
  [WxPython] Setting interdependencies between checkboxes merlem 2 3,682 Feb-12-2017, 07:51 PM
Last Post: merlem

Forum Jump:

User Panel Messages

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