我想用QTimer用感应值更新图形用户界面。
我尝试了以下非常简单的代码:
from pyQt4 import QtCore
def f():
try :
print ("text")
finally :
QtCore.QTimer.singleShot(5000, f)
f()这不管用。
发布于 2014-11-13 17:10:55
import sys
from PyQt4 import QtCore, QtGui
class MyApp(QtGui.QWidget):
def __init__(self):
self.print_hello()
def print_hello(self):
print 'hello'
QtCore.QTimer.singleShot(3000, self.print_hello)
qapp = QtGui.QApplication(sys.argv)
app = MyApp()
qapp.exec_()我不确定为什么这样做,但它与计时器需要在运行的线程中有关。我猜它是用app对象创建的.
https://stackoverflow.com/questions/26817458
复制相似问题