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. 使用Eclipse生成自动生成apk

    使用Eclipse生成自动生成apk     在eclipse的Preferences -> Android -> Build中有一项“Skip packaging and dexing ...

  2. [Angular 2] *ngFor with index

    Let's see how to track index when we use 'ngFor: <li *ngFor="#hero of heros | async, #i = in ...

  3. 十二.200多万元得到的创业教训--app名字是关键

    摘要:当完毕了一个app后,就要须要上应用市场,以下讲一下起名和上应用市场的一些技巧. 健生干货分享:第12篇 1.必须是先上app store,再上其它应用市场 为啥要这样做?由于app store ...

  4. python课程第一天作业1-模拟登录

    第一周作业: 作业1:编写登陆接口 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定 流程图: 代码:后来修改过一次: #!/usr/bin/env python # -*-conding:ut ...

  5. 常用元素的属性/方法 attr / val / html /text

    常用元素的属性/方法 得到一个元素的高度, $("#myid").height() 得到一个元素的位置, $("#myid").offset() 返回的是一个o ...

  6. C#。5 函数 类

    函数:能够独立完成某个功能的模块.          好处:1.结构更清析(编写.维护方便 ).2.代码重用.3.分工开发.          四要素:名称,输入(参数),输出(返回的类型),加工(函 ...

  7. nagios配置

    接近两个星期的奋战,nagios的安装搭建以及监控服务自动报警功能终于基本得以实现,现在自己整理一份安装技术手册,方便自己以后查阅和回顾. 接近两个星期的奋战,nagios的安装搭建以及监控服务自动报 ...

  8. pendingIntent初步_什么是pendingIntent

    pendingIntent字面意义:等待的,未决定的Intent. 要得到一个pendingIntent对象,使用方法类的静态方法 通过getActivity(Context context, int ...

  9. YUI 之getLocation

    关于Y.getLocation的简介是 Returns the `location` object from the window/frame in which this YUI instance o ...

  10. 对于js原型和原型链继承的简单理解(第二种,对象冒充)

    关键代码    this.parent = Cat;    this.parent.apply(this); function Cat(){ this.climb = function(){ aler ...