【发布时间】:2017-04-02 13:19:46
【问题描述】:
我对课程或 tkinter 不太熟悉,但我想做的是,如果 选择了test1,而不是将图标更改为favicon,我真的无法弄清楚,如果你能帮助我,那就太好了,如果我做错了什么
from tkinter import *
class GUI:
def __init__(self, master):
self.iconnum = IntVar()
master.title('Testing')
master.resizable(width=False, height=False)
master.maxsize(500, 250)
master.minsize(500, 250)
self.test1= Radiobutton(master, text="test1", variable=0, value=1, )
self.test2= Radiobutton(master, text="test2", variable=0, value=2, )
self.test3= Radiobutton(master, text="test3", variable=0, value=3, )
self.test4= Radiobutton(master, text="test4", variable=0, value=4, )
self.test1.grid(row=2, columnspan=1)
self.test2.grid(row=2, columnspan=2)
self.test3.grid(row=2, column=1)
self.test4.grid(row=3, columnspan=1,)
self.Test5= Radiobutton(master, text="Test5", indicatoron=0, height=1, width=35, value=0, command=self.icon_switcher)
self.Test6= Radiobutton(master, text="Test6", indicatoron=0, height=1, width=35, value=1, command=self.icon_switcher)
self.Test5.grid(row=1)
self.Test6.grid(row=1, column=1,)
def icon_switcher(self):
if self.iconnum == 1:
self.master.iconbitmap('favicon.ico')
root = Tk()
gui = GUI(root)
root.mainloop()
【问题讨论】:
标签: python python-2.7 python-3.x class tkinter