Radiobuttons in Tkinter (1)

Radiobuttons

With radiobuttons you can choose among more options, choosing one only.

# radiobutton
# tkinter

import tkinter as tk

root = tk.Tk()

vstring = tk.IntVar()

text_value = [
    ("option 1", "1"),
    ("option 2", "2"),
    ("option 3", "3"),
    ("option 4", "4")
]

for t, v in text_value:
    r = tk.Radiobutton(root)
    r['text'] = t
    r['value'] = v
    r['variable'] = vstring
    r.pack(anchor=tk.W)

root. mainloop()

Tkinter test for students

Tkinter articles

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.