OrangoMango

Tkinter Radiobutton class

May 8th, 2020
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import messagebox
  3.  
  4. tk = Tk()
  5. tk.title("Radiobuttons")
  6. tk.geometry("100x100")
  7.  
  8. variable = StringVar()
  9. variable.set("Male")
  10.  
  11. def show():
  12.   messagebox.showinfo("Seleted", "You selected: %s" % variable.get())
  13.  
  14. r = Radiobutton(tk, value="Male", variable=variable, text="Male")
  15. r2 = Radiobutton(tk, value="Female", variable=variable, text="Female")
  16.  
  17. b = Button(tk, text="Show selection", command=show)
  18.  
  19. r.pack()
  20. r2.pack()
  21. b.pack()
  22.  
  23. tk.mainloop()
Add Comment
Please, Sign In to add comment