练习图
实现效果图
实现代码
from tkinter import *
win = Tk()
win.geometry('600x400')
win.title('My Window')
l = Label(win,width=20,text='empty',font=('微软雅黑,18'),bg='yellow')
l.pack()
var = StringVar()
def func():
l.config(text='you have selected' + var.get())
r1 = Radiobutton(win,text='Option A',variable=var,value='A',command=func)
r1.pack()
r2 = Radiobutton(win,text='Option B',variable=var,value='B',command=func)
r2.pack()
r3 = Radiobutton(win,text='Option C',variable=var,value='C',command=func)
r3.pack()
win.mainloop()
|