【问题标题】:Using Tcl/Tk how do i put the menu at the top of the screen in Ubuntu Unity?使用 Tcl/Tk 如何在 Ubuntu Unity 中将菜单放在屏幕顶部?
【发布时间】:2014-05-06 17:14:24
【问题描述】:

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

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

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

【问题讨论】:

  • 感谢您的图片!现在我明白了你的问题是什么(这真的是我第一次看到全局菜单栏)。您或许可以尝试使用post。当我执行.menu post 0 0 时,菜单(的克隆)出现在左上角。但是,这具有全球性的优势,并且在失去焦点时会消失。所以,我相信如果需要,全局菜单应该是可行的/定制的。
  • 这不仅仅是我想要的菜单的克隆。我希望它像所有其他程序的菜单一样出现在屏幕的左上角,就像 Mac OSX 一样。
  • 很好的问题。老实说,我不知道该怎么做!
  • 顶层由窗口管理控制。试试 8.59 及更高版本中的 wm -type 属性?没有那个版本来测试它。

标签: ubuntu menu tcl tk ubuntu-unity


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-12-07
    • 2015-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-16
    • 1970-01-01
    相关资源
    最近更新 更多