【发布时间】:2016-10-05 10:59:50
【问题描述】:
我尝试在 tkinter 中更改 ttk.button 状态(在 mainloop 开始时),就像在这个 manual [实现:实际上是 here.]
import tkinter
from tkinter import ttk
root = tkinter.Tk()
style = ttk.Style()
style.map("C.TButton",
foreground=[('pressed', 'red'), ('active', 'blue')],
background=[('pressed', '!disabled', 'black'), ('active', 'white')]
)
colored_btn = ttk.Button(text="Test", style="C.TButton")
colored_btn.pack()
colored_btn.state('pressed')
root.mainloop()
导致错误:
in state return self.tk.splitlist(str(self.tk.call(self._w, "state", statespec))) _tkinter.TclError: Invalid state name p
【问题讨论】:
-
您问题中的链接无效。
-
我刷新了。