linux中python启动应用_如何监视在linux / tcl / python中打开或启动的应用程序?

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?

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 {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

}

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

Appreciate any insights. Thank you in advance.

解决方案

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

}

In the helper script:

#!/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

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值