python中打开或启动的应用程序

python中打开或启动的应用程序

本文介绍了如何监视在linux/tcl/python中打开或启动的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个面板应用程序,就像avant窗口导航器或ubuntu unity.

I am trying to build a panel application, alike avant window navigator or ubuntu unity.

我的问题是,一旦我使用预定义的应用程序构建面板,在打开或启动应用程序时如何向面板添加项目?

My question is once I build the panel with the predifined applications, how I can add items to the panel when applications are open or launch?

这是我在tcl中的源代码:

Here is my source code in tcl:

package require Tk

set items {xterm gvim firefox}
wm withdraw .
toplevel .panel
wm attributes .panel -topmost 1 ; # on top
bind .panel <Escape> {exit}
wm geometry .panel +0+0
wm overrideredirect .panel yes ; # remove window decorations

set counter 0
foreach item $items {
    incr counter
    set separator " "
    label .panel.$counter -text "$item$separator" -bg black -fg white \
    -font {-family "Fixedsys Excelsior 3.01" -size 12}
    grid .panel.$counter -column $counter -row 0
}

是否有任何终端,tcl或python命令可以实现这一目标?

Is there any terminal, tcl or python command that can achieve this?

赞赏任何见解.预先谢谢你.

Appreciate any insights. Thank you in advance.

推荐答案

如果打开send命令(取决于与显示器安全性相关的各种因素),您可以告诉它继续收听一个知名名称",然后让另一个小应用程序使用send调度脚本进行评估.

If the send command is turned on (which depends on all sorts of factors related to the security of your display) you can just tell it to listen on a "well-known name" and then have another little app use send to dispatch a script to evaluate.

在面板中,听一个好"名字:

In the panel, listen on a "good" name:

package require Tk
tk appname MyExcellentPanel
proc registerItem args {
   # How to do the registration of things here
}

在帮助脚本中:

#!/usr/bin/env wish
package require Tk
wm withdraw .                               ;  # IMPORTANT! Don't show a GUI here
send MyExcellentPanel registerItem $argv    ;  # The magic command
exit                                        ;  # IMPORTANT! Exit now

现在,您可以使用Shell脚本中的那个小脚本,也可以在任何地方使用该指令向面板发送指令以进行注册.就这么简单.

Now you can use that little script from a shell script or wherever to send an instruction to the panel to register something. It's as easy as that.

如果没有send命令,请尝试使用 comm 程序包Tcllib,其中comm::comm sendsend近似相等.但是,没有与tk appname完全相同的东西,因为没有可移植的方法来注册端口映射(通信使用本地TCP通道),因此您需要找到一种方式来传达该信息(文件位于知名位置) ?). las,我对它不是很有经验,所以我不能真正地提供详细的建议.

If the send command isn't present, try the comm package in Tcllib, with comm::comm send as the approximate equivalent of send. However, there's nothing exactly the same as tk appname as there's no portable way to do a registry of port mappings (comm uses local TCP channels) so you need to find a way to communicate that information (a file in a well-known place?). Alas, I'm not very experienced with it so I can't really advise in detail.

这篇关于如何监视在linux/tcl/python中打开或启动的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 13:28