标签:oop str tar title tle href imp radio 结果
# coding=gbk # 注意:选中按钮时执行下面的命令,config意为配置 # lable.config(text = "you have selected " + var.get()) # 运行结果:http://ww1.sinaimg.cn/large/de060ec1ly1fqedlvhm4ag20fe09eaaf.gif import tkinter window = tkinter.Tk() window.title("jkn1234") window.geometry("500x500") var = tkinter.StringVar() lable = tkinter.Label( window, bg = ‘yellow‘, height = 6, text = ‘empty‘ ) def print_selection(): lable.config(text = "you have selected " + var.get()) lable.pack() radiobutton1 = tkinter.Radiobutton( window, variable = var, value = ‘A‘,#点击按钮时将按钮var的值设置为‘A’ text = "option A", command = print_selection ) radiobutton1.pack() radiobutton2 = tkinter.Radiobutton( window, variable = var, value = ‘B‘,#点击按钮时将按钮var的值设置为‘B’ text = "option B", command = print_selection ) radiobutton2.pack() window.mainloop()
标签:oop str tar title tle href imp radio 结果
原文地址:https://www.cnblogs.com/jkn1234/p/8855260.html