python 检测按钮状态是否禁用,代码如下:
#!/bin/python from Tkinter import * class Dummy: pass var = Dummy() root = Tk() root.title('Checkbutton') for castmember, row, col, status in [ ('A', 0,0,NORMAL), ('B', 0,1,NORMAL), ('C', 1,0,disabled), ('D', 1,1,NORMAL), ('E',2,0,NORMAL), ('F', 2,1,NORMAL)]: setattr(var, castmember, IntVar()) Checkbutton(root, text=castmember, state=status, anchor=W, variable = getattr(var, castmember)).grid(row=row, column=col, sticky=W) root.mainloop()
如下图: