码迷,mamicode.com
首页 > 其他好文 > 详细

qt动态更新界面的菜鸟代码,请指出

时间:2015-07-16 15:41:57      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

qt简单界面更新代码(菜鸟级)(部分代码)

self.timers_1=QtCore.QTimer(self)

self.timers_1.timeout.connect(self.min_1)

self.timers_1.start(1000)

def getCPUstate(self,interval=1):

        return (" CPU: " + str(psutil.cpu_percent(interval)) + "%")

    def getMemorystate(self):

        phymem = psutil.phymem_usage()

        buffers = getattr(psutil, ‘phymem_buffers‘, lambda: 0)()

        cached = getattr(psutil, ‘cached_phymem‘, lambda: 0)()

        used = phymem.total - (phymem.free + buffers + cached)

        line = " Memory: %5s%% %6s/%s" % (

            phymem.percent,

            str(int(used / 1024 / 1024)) + "M",

            str(int(phymem.total / 1024 / 1024)) + "M")

        #self.n.start(1000)

        self._tools.threaings_python_cache.setText(unicode(line))

def poll(self,interval):

        tot_before = psutil.network_io_counters()

        pnic_before = psutil.network_io_counters(pernic=True)

        tot_after = psutil.network_io_counters()

        pnic_after = psutil.network_io_counters(pernic=True)

        cpu_state = self.getCPUstate(interval)

        memory_state =self.getMemorystate()

        return (tot_before, tot_after, pnic_before, pnic_after,cpu_state,memory_state)

def refresh_window(self,tot_before, tot_after, pnic_before, pnic_after,cpu_state,memory_state):

        #self.n.start(1000)

        self._tools.threaings_python_cpu.setText(unicode(cpu_state))

def min_1(self):

        interval = 1

        args = self.poll(interval)

        self.refresh_window(*args)

        interval = 1

self.timers_1.timeout.connect(self.min_1)核心语句是这句

qt动态更新界面的菜鸟代码,请指出

标签:

原文地址:http://www.cnblogs.com/mhxy13867806343/p/4058483.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!