Skip to content

Instantly share code, notes, and snippets.

@FONQRI
Created August 24, 2020 12:46
Show Gist options
  • Save FONQRI/0a4abbad6b6e352ce92598ea7b58a221 to your computer and use it in GitHub Desktop.
Save FONQRI/0a4abbad6b6e352ce92598ea7b58a221 to your computer and use it in GitHub Desktop.
import tkinter as tk
root = tk.Tk()
v = tk.IntVar()
v.set(1) # initializing the choice, i.e. Python
languages = [
("Python",1),
("Perl",2),
("Java",3),
("C++",4),
("C",5)
]
def ShowChoice():
print(v.get())
tk.Label(root,
text="""Choose your favourite
programming language:""",
justify = tk.LEFT,
padx = 20).pack()
for val, language in enumerate(languages):
tk.Radiobutton(root,
text=language,
padx = 20,
variable=v,
command=ShowChoice,
value=val).pack(anchor=tk.W)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment