一个在ubuntu unity面板中显示任何文本的库

panel-indicator的Python项目详细描述


Ubuntu面板指示器

这个库可以用来打印ubuntuunity面板中任何脚本的输出。在

使用此软件包构建的internet donwload speed unity面板指示器的示例。
Picture

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)

Skeleton:

^{pr2}$

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用MVC设计模式观察嵌套对象   java将多个客户端连接到服务器   合并Java Web应用程序   Spring Security中未捕获java AuthenticationSuccessEvent   java Firebase JSON到Arraylist内部的Arraylist,存在对象问题   在Java15的sealedclasses特性中,final类和非密封类之间有什么区别?   java我可以使用数组。copyOf制作二维数组的防御副本?   java球不会在屏幕上移动   Java类如何在同一个文件中包含两个类?   java使用“Character.isWhiteSpace”删除所有空白   java阻止在RealmList中保存时创建领域对象   如何仅在ConnectionFactory上使用Java JMS身份验证   spring可以强制java对象在运行时实现接口吗?   socket无法在JAVA中使用TCP启用双工模式通信