一个在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 Spring安全编程授权   java Android库AAR取决于另一个库   Java/Groovy双精度语句问题   爪哇。查看安卓监视器图形时,release()不会减少我的内存   java无法在子类中使用EventFiringWebDriver对象   java第一个if语句始终为true,但第二个if语句不为true   java如何从作为字符串提供的XML源代码创建可绘制(或XmlResourceParser对象)?   多线程Java并发问题锁和同步方法   java Android Studio注册链接   java ArrayList of ArrayList of String   使用Shadow重新定位的包中的java Kotlin属性不起作用   java在接口org上找不到方法。阿帕奇。伊巴蒂斯。遗嘱执行人。陈述名为prepare的语句处理程序   如何在Java中放大2倍?   java当参数作为RequestBody和RequestParam发送时,sprig控制器无法识别发送的请求