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簡單界面更新代碼(菜鳥級)(部分代碼)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
馬哥LINUX高薪LINUX高薪就業入門教程-虛擬機篇幅-學習筆記-11
白手起家學
2019-02-23 12:58:30
指針
18810357201
2019-02-23 13:21:35
jquery配合.NET實現點擊指定綁定數據並且能夠一鍵下載
張立達
2019-02-23 00:36:44
c++ return語句
好事多磨啊
2019-02-23 00:36:41
10個經典的 Java main 方法面試題
bigbang1991
2019-02-23 00:34:23
10個經典的 Java main 方法面試題
bigbang1991
2019-02-23 00:34:23
10個經典的 Java main 方法面試題
bigbang1991
2019-02-23 00:34:22
Lintcode14 First Position of Target Solution 題解
coderer
2019-02-23 00:24:38
js讀取php設置的cookie亂碼 中文
yujie001
2019-02-23 00:19:01