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动态更新界面的菜鸟代码,请指出的更多相关文章

  1. MFC编辑框接收数据动态更新与刷新方法代码示例-如何让编辑框内容实时更新

    MFC编辑框接收数据动态更新与刷新方法代码示例-如何让编辑框内容实时更新 关键代码: //发送数据通知 //from txwtech@163.com LRESULT CCommSampleDlg::O ...

  2. 基于Python实现matplotlib中动态更新图片(交互式绘图)

    最近在研究动态障碍物避障算法,在Python语言进行算法仿真时需要实时显示障碍物和运动物的当前位置和轨迹,利用Anaconda的Python打包集合,在Spyder中使用Python3.5语言和mat ...

  3. 一步步教你为网站开发Android客户端---HttpWatch抓包,HttpClient模拟POST请求,Jsoup解析HTML代码,动态更新ListView

    本文面向Android初级开发者,有一定的Java和Android知识即可. 文章覆盖知识点:HttpWatch抓包,HttpClient模拟POST请求,Jsoup解析HTML代码,动态更新List ...

  4. 在Android中实现service动态更新UI界面

    之前曾介绍过Android的UI设计与后台线程交互,据Android API的介绍,service一般是在后台运行的,没有界面的.那么如何实现service动态更新UI界面呢?案例:通过service ...

  5. android中实现service动态更新UI界面

    案例:通过service向远程服务器发送请求,根据服务器返回的结果动态更新主程序UI界面,主程序可实时关闭或重启服务. 注册BroadcastReceiver 在主程序activity中注册一个Bro ...

  6. JAVA代码热部署,在线不停服动态更新

    本地debug的时候,可以实时编译并更新代码,线上也可以不停服来动态更新类,即所说的java热部署.   JDK代理的两种方式: 1.premain方式是Java SE5开始就提供的代理方式,但其必须 ...

  7. Android Handler传递参数动态更新UI界面demo

    package com.example.demo_test; import android.app.Activity; import android.os.Bundle; import android ...

  8. cocos2d-js 在线更新代码脚本 动态更新脚本程序 热更新 绕过平台审核 不需重新上架

    2014年8月15日补充 cocos2d-js 3.0 rc0 的AssetsManager有缺陷,有一些注意点:(可以阅读源代码发现) 1.旧manifest中有,但新manifest中没有的文件( ...

  9. Android零基础入门第44节:ListView数据动态更新

    原文:Android零基础入门第44节:ListView数据动态更新 经过前面几期的学习,关于ListView的一些基本用法大概学的差不多了,但是你可能发现了,所有ListView里面要填充的数据都是 ...

随机推荐

  1. UVA 714 Copying Books 最大值最小化问题 (贪心 + 二分)

      Copying Books  Before the invention of book-printing, it was very hard to make a copy of a book. A ...

  2. Web安全测试之XSS(跨站脚本攻击)

    XSS 全称(Cross Site Scripting) 跨站脚本攻击, 是Web程序中最常见的漏洞.指攻击者在网页中嵌入客户端脚本(例如JavaScript), 当用户浏览此网页时,脚本就会在用户的 ...

  3. php 回调函数

    publicfunction transaction(Closure $callback){     $this->beginTransaction();     // We'll simply ...

  4. 最好的Laravel中文文档

    分页 配置 基本用法 给分页链接添加自定义信息 配置 在其它的框架中,分页有时很痛苦. 但是Laravel让分页简单到不可思议. 默认Laravel包含了两个分页视图, 在app/config/vie ...

  5. ETL几种方案对比

  6. LDAP索引及缓存优化

    一.设置索引 索引将查找信息和 Directory Server 条目关联起来. Directory Server支持以下几种索引: 1出现索引 (pres) - 列出了具有特定属性的条目,与属性的值 ...

  7. OD: Universal Shellcode

    本节讲如果开发通用的 Shellcode. Shellcode 的组织 shellcode 的组织对成功地 exploit 很重要. 送入缓冲区的数据包括: . 填充物.一般用 0x90 (NOP) ...

  8. Asp.net - The type or namespace name 'App_Code' does not exist in the namespace 'xxx' (are you missing an assembly reference?)

    我在 项目 下面创建一个 App_Code的文件夹,然后在其下创建自定义的类,但是当我在该项目下别的地方使用时报错: The type or namespace name 'App_Code' doe ...

  9. bootstrap-datetimepicker使用记录

    版本:V2.0 1.bootstrap-datetimepicker.min.css 2.bootstrap-datetimepicker.min.js 3.bootstrap-datetimepic ...

  10. C#类中字段,属性与方法

    person类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...