当鼠标悬停在按钮上时,我试图将ttk.tkinter按钮背景更改为黑色,将前景色更改为白色。已经尝试过 highlightbackground,activebackground但没有产生我想要的结果。
import tkinter as tk
import tkinter.ttk as ttk
root = tk.Tk()
style = ttk.Style(root)
#style.theme_use("clam")
style.configure('TButton', foreground="black", highlightthickness=5,
highlightbackground='#3E4149', highlightforeground="white",
activebackground="black")
btr = ttk.Button(root, text="TEST BUTTON")
btr.pack()
root.mainloop()
Run Code Online (Sandbox Code Playgroud) 我经常看到Tkinter应用程序在构造函数中初始化Menu小部件tearoff=0.
import tkinter as tk
root = tk.Tk()
menubar = tk.Menu(root)
filemenu = tk.Menu(menubar, tearoff=0)
Run Code Online (Sandbox Code Playgroud)
effbot.org的文档Menu指定默认值为tearoff1,但它没有解释该值的用途.
tearoff=
Default value is 1. (tearOff/TearOff)
tearoffcommand=
No default value. (tearOffCommand/TearOffCommand)
Run Code Online (Sandbox Code Playgroud)
什么是tearoff初始化Tkinter的属性时,做Menu小部件?