PyQt4 动态显示ui

# -*- coding: utf-8 -*-

"""
Module implementing function.
"""
import PyQt4, PyQt4.QtGui, sys
from PyQt4.QtGui import QDialog
from PyQt4.QtCore import pyqtSignature
import time
from Ui_fucntion import Ui_func

class function(QDialog, Ui_func):
    """
    Class documentation goes here.
    """
    def __init__(self, parent = None):#original init
    #def __init__(self, ui):
        """
        Constructor
        """
        global cnt   #全局变量cnt,用于循环显示
        cnt=0
        QDialog.__init__(self, parent)
        
        self.setupUi(self)
        
        #SET TIMER  
        self.timer3_1=PyQt4.QtCore.QTimer()
        PyQt4.QtCore.QObject.connect(self.timer3_1,PyQt4.QtCore.SIGNAL("timeout()"), self.OnTimer) #将新建的timer与ontimer事件connect
        
     
    def OnTimer(self):#循环显示keyarry中的数据
       # self.timer3_2.start(1000)
        global cnt
        self.foundkey3.setText(keyarry[cnt])
        cnt=(cnt+1)%5
    @pyqtSignature("")
    def on_start3_clicked(self):
        """
        Slot documentation goes here.
        """
        #change the label several times per second
        self.foundkey3.setText("***START***")
        #start step 3 process
    
        self.timer3_1.start( 125 )
        
        
if __name__ == "__main__":
    global cnt
    cnt=0
    keyarry=['1','2', '3', '4', '5']
    app = PyQt4.QtGui.QApplication(sys.argv)
    dlg = function()
    dlg.show()
    sys.exit(app.exec_())

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值