使用Tcl/Tk如何将菜单放在Ubuntu Unity的屏幕顶部?

Gar*_*hby 6 ubuntu tk-toolkit menu tcl ubuntu-unity

我有一个简单的Tcl脚本,它创建一个带菜单的窗口.

#! /usr/bin/tclsh
package require Tk
#  Create the main message window
message .m -text {Hello Tcl!} -background white
pack .m -expand true -fill both -ipadx 100 -ipady 40

#  Create the main menu bar with a Help-About entry
menu .menubar
menu .menubar.help -tearoff 0
.menubar add cascade -label Help -menu .menubar.help -underline 0
.menubar.help add command -label {About Hello ...} \
    -accelerator F1 -underline 0 -command showAbout

#  Define a procedure - an action for Help-About
proc showAbout {} {
    tk_messageBox -message "Tcl/Tk\nHello Windows\nVersion 1.0" \
        -title {About Hello}
}

#  Configure the main window 
wm title . {Hello Foundation Application}
. configure -menu .menubar -width 200 -height 150
bind . {<Key F1>} {showAbout}
Run Code Online (Sandbox Code Playgroud)

如果使用Unity窗口管理器在Ubuntu上运行此脚本,则菜单将放置在窗口上,而不是位于其他本机程序放置其菜单的最顶部栏(类似于MacOSX)上.像这样:

在此输入图像描述

这是对Tcl/Tk的限制还是有一种方法可以使菜单在Unity下更加原生,并且放在屏幕顶部而不是在窗口上?

小智 0

我认为你需要尝试使用 Gnocl 包。标准 Tk 不实现应用程序级菜单。Tk 菜单必须附加到窗口。