我用 编写了代码ttk.Menubutton
,但遇到了一个问题 - 指示器没有消失,尽管可以在tk.Menubutton
.
代码
ttk.Menubutton
:
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.option_add("*Menu.borderWidth", "0")
root.option_add("*Menu.activeBorderWidth", "0")
root.option_add("*Menu.background", "black")
style = ttk.Style(root)
menu = tk.Menu(root)
btn_menu = ttk.Menubutton(root, text='fegvd')
btn_menu.pack()
file = tk.Menu(btn_menu, tearoff=0, foreground='white')
file.add_command(label='ГЫГ')
style.configure('TMenubutton', background='black', foreground='white', indicatoron=0, menu=file, direction='delow', state='active')
root.mainloop()
tk.Menubutton
:
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.option_add("*Menu.borderWidth", "0")
root.option_add("*Menu.activeBorderWidth", "0")
root.option_add("*Menu.background", "black")
menu = tk.Menu(root)
btn_menu = tk.Menubutton(root, text='fegvd')
btn_menu.pack()
file = tk.Menu(btn_menu, tearoff=0, foreground='white')
file.add_command(label='ГЫГ')
btn_menu.configure(background='black', foreground='white', indicator=0, menu=file, state='active')
root.mainloop()
截图
ttk.Menubutton
tk.Menubutton
如何解决?