Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import messagebox
- tk = Tk()
- tk.title("Radiobuttons")
- tk.geometry("100x100")
- variable = StringVar()
- variable.set("Male")
- def show():
- messagebox.showinfo("Seleted", "You selected: %s" % variable.get())
- r = Radiobutton(tk, value="Male", variable=variable, text="Male")
- r2 = Radiobutton(tk, value="Female", variable=variable, text="Female")
- b = Button(tk, text="Show selection", command=show)
- r.pack()
- r2.pack()
- b.pack()
- tk.mainloop()
Add Comment
Please, Sign In to add comment