一个在ubuntu unity面板中显示任何文本的库
panel-indicator的Python项目详细描述
Ubuntu面板指示器
这个库可以用来打印ubuntuunity面板中任何脚本的输出。在
使用此软件包构建的internet donwload speed unity面板指示器的示例。
from panel_indicator import PanelIndicator
import subprocess
class MyIndicator(PanelIndicator):
""" abstract function(set_new_value) returns a string """
""" update_interval in seconds """
def __init__(self, update_interval):
self.current_val = 0
PanelIndicator.__init__(self, update_interval)
def set_new_value(self):
out, err = self.bash_script_runner("/home/ketankr9/bin/netusage.sh")
old_val = self.current_val
self.current_val = int(out.strip().decode('utf-8'))
# convert bytes to megabytes
val = (self.current_val*1.0 - old_val)/10**3
val /= self.update_interval
if val/10**3 >= 1.0:
# convert megabytes to gigabytes
val /= 10**3
val = round(val, 1)
val = str(val) + " MB"
else:
val = round(val, 1)
val = str(val) + " KB"
return val
MyIndicator(1.5)
^{pr2}$Skeleton:
- 项目
标签: