Python Forum
[Tkinter] Grid the radio buttons
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Grid the radio buttons
#4
You cannot use pack() and grid() in the same frame, so make a frame for the radio buttons.
import tkinter as tk

root = tk.Tk()

var_1 = tk.IntVar(0)

tk.Label(root, text="""Radio Buttons""", justify=tk.LEFT, padx=20).pack()

radio_frame = tk.Frame(root)
radio_frame.pack()
for index, button in enumerate('ABCD'):
    button = tk.Radiobutton(radio_frame, text=button, variable=var_1, value=index)  # Buttons are added to radio_frame, not root
    button.grid(row=index // 2, column=index % 2, padx=5, pady=5)

root.mainloop()
Reply


Messages In This Thread
Grid the radio buttons - by Joni_Engr - Nov-23-2021, 03:33 PM
RE: Grid the radio buttons - by DPaul - Nov-23-2021, 04:18 PM
RE: Grid the radio buttons - by BashBedlam - Nov-23-2021, 04:18 PM
RE: Grid the radio buttons - by deanhystad - Nov-23-2021, 04:26 PM
RE: Grid the radio buttons - by Joni_Engr - Nov-24-2021, 09:54 AM
RE: Grid the radio buttons - by menator01 - Nov-24-2021, 10:36 AM
RE: Grid the radio buttons - by menator01 - Nov-24-2021, 07:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Is there a way to determine if a radio button has been selected? TWB 5 5,113 Jan-31-2023, 09:44 AM
Last Post: Vadanane
  [Tkinter] Radio Buttons Working Bassackwards gw1500se 6 2,333 Dec-07-2021, 07:13 PM
Last Post: menator01
  Radio butto to enable/disable combo box in Tkinter cybertooth 5 5,564 Oct-09-2021, 07:30 AM
Last Post: cybertooth
  problem with radio button crook79 3 3,749 Aug-12-2021, 02:30 PM
Last Post: deanhystad
  .grid buttons AnunnakiKungFu 3 2,023 Feb-08-2021, 05:56 PM
Last Post: deanhystad
  [Tkinter] I can't get information from a radio button aquerci 2 2,778 May-20-2020, 10:31 AM
Last Post: aquerci
  [Tkinter] Radio button help Muzz 5 3,714 Apr-28-2019, 07:43 AM
Last Post: Muzz

Forum Jump:

User Panel Messages

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