============================================================================================= import os import platform import time from math import pi import re import thread from PyQt4 import QtCore, QtGui import ui_shoptime class MainWindow(QtGui.QMainWindow, ui_shoptime.Ui_ShopTime): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.__index = 0 self.setupUi(self) def on_startButton_clicked(self): self.startButton.toggle() startTime = time.time() thread.start_new_thread(countFunction(startTime)) #threading.Thread(target=count).start() #count().start() #thread.start_new_thread(countFunction, ()) def countFunction(startTime,*args): while 1: runtime = time.time() - startTime print runtime runtimeSeconds = runtime / 60 self.runningTime.display(runtimeSeconds) time.sleep(1) if __name__ == "__main__": import sys app = QtGui.QApplication(sys.argv) form = MainWindow() form.show() app.exec_() #print form.text() _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
I've been playing with threading the last few hours, because I have a
lcd number object in the gui that I want to update once per second. Am I
barking up the right tree with threading? The problem Ive got is self is
no longer defined in countFunction. Is there a way to run a thread that
has access to *everything*?
- [PyQt] threading Lawrence Shafer
- Re: [PyQt] threading Andreas Pakulat