Tcl/Tk:设置菜单项的默认背景和背景格式

Tcl/Tk:设置菜单项的默认背景和背景格式,tcl,tk,Tcl,Tk,我不得不一次又一次地为每个对象设置相同的格式,需要编写/维护大量代码。是否有允许默认设置菜单栏等小部件格式的配置 是的,我可以写一个程序来处理这个问题,但只是问一下 以下示例中所示的条件: set menuBar .t.menubar set wMenuBar [menu .t.menubar -bg #e6e6fa -activebackground #6495ed -fg #000080] # .t configure -menu [menu .t.menubar -bg #e6e6fa -

我不得不一次又一次地为每个对象设置相同的格式,需要编写/维护大量代码。是否有允许默认设置菜单栏等小部件格式的配置

是的,我可以写一个程序来处理这个问题,但只是问一下

以下示例中所示的条件:

set menuBar .t.menubar
set wMenuBar [menu .t.menubar -bg #e6e6fa -activebackground #6495ed -fg #000080]
# .t configure -menu [menu .t.menubar -bg #e6e6fa -activebackground #6495ed -fg #000080 ] 
set fileMenu ${menuBar}.file
$menuBar  add cascade -label "File" -menu [menu $fileMenu -bg #e6e6fa -activebackground #6495ed -fg #000080] -underline 0 
$fileMenu add command -label "Save" -command { doTheSave } -underline 1 
$fileMenu add separator
$fileMenu add command -label "Quit" -command { destroy .t } -underline 0 

set logsMenu ${menuBar}.logs
$menuBar  add cascade -label "Logs" -menu [menu $logsMenu -bg #e6e6fa -activebackground #6495ed -fg #000080] -underline 0 
您可以尝试使用设置菜单的小部件级默认值

option add *Menu.background "#e6e6fa"
option add *Menu.activeBackgrund "#6495ed"
option add *Menu.foreground "#000080"
模式描述格式现在相当模糊