Lecture Radio button

Lecture • Views 302 • Comments 0 • Last Updated at 2 months ago  
  • 윈도우 프로그램
  • 윈도우 프로그램

라디오 버튼

import tkinter as tk
 
window = tk.Tk()
window.title('My Window')
window.geometry('500x300')
 
var = tk.StringVar()
l = tk.Label(window, bg='white', width=20, text='empty')
l.pack()
 
def print_selection():
    l.config(text='you have selected ' + var.get())
 
r1 = tk.Radiobutton(window, text='Option A', variable=var, value='A', command=print_selection)
r1.pack()
r2 = tk.Radiobutton(window, text='Option B', variable=var, value='B', command=print_selection)
r2.pack()
r3 = tk.Radiobutton(window, text='Option C', variable=var, value='C', command=print_selection)
r3.pack()
 
window.mainloop()
열 1 열 2 열 3 열 3
previous article
next article
Comments
Feel free to ask a question, answer or comment, etc.