# -*- 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_())
PyQt4 动态显示ui
最新推荐文章于 2024-07-24 16:28:56 发布