Skip to content

Instantly share code, notes, and snippets.

Created December 8, 2014 06:14
Show Gist options
  • Save anonymous/e6b0a0c6b864ca5551fc to your computer and use it in GitHub Desktop.
Save anonymous/e6b0a0c6b864ca5551fc to your computer and use it in GitHub Desktop.
from tkinter import *
def sel():
selection = "You selected the option " + str(var.get())
label.config(text=selection)
root = Tk()
var = IntVar()
R1 = Radiobutton(root, text="Option 1", variable=var, value=1, command=sel)
R1.pack(anchor=W)
R2 = Radiobutton(root, text="Option 2", variable=var, value=2, command=sel)
R2.pack(anchor=W)
R3 = Radiobutton(root, text="Option 3", variable=var, value=int(var), command=sel)
R3.pack(anchor=W)
label = Label(root)
label.pack()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment