6

我有一个简单的 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}

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

在此处输入图像描述

这是对 Tcl/Tk 的限制,还是有办法让菜单在 Unity 下表现得更自然,并放置在屏幕顶部而不是窗口上?

4

1 回答 1

0

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

于 2018-04-19T20:29:12.810 回答