창을 표시하는 방법 + 해당 텍스트를 인쇄 하시겠습니까? 내 while 루프가 있으면 창이 더 이상 표시되지 않습니다. Python - 창을 표시하는 방법 + 텍스트를 인쇄 하시겠습니까? 그 유일한 인쇄하지만 창을 표시하지 않는 곳
import sys
import datetime
import time
from PyQt4 import QtCore, QtGui
class Main(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
self.b = QtGui.QPushButton("exit", self, clicked=self.close)
self.c = QtGui.QLabel("Test", self)
if __name__ == "__main__":
app=QtGui.QApplication(sys.argv)
myapp=Main()
myapp.show()
while True:
time.sleep(2)
print "Print this + Show the Window???!!!"
sys.exit(app.exec_())
시도 :
는
import sys
import datetime
import time
from PyQt4 import QtCore, QtGui
class Main(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
self.b = QtGui.QPushButton("exit", self, clicked=self.close)
self.c = QtGui.QLabel("Test", self)
def myRun():
while True:
time.sleep(2)
print "Print this + Show the Window???!!!"
if __name__ == "__main__":
app=QtGui.QApplication(sys.argv)
myapp=Main()
myapp.show()
thread = QtCore.QThread()
thread.run = lambda self: myRun()
thread.start()
sys.exit(app.exec_())
출력 :
형식 오류는() 전역 함수 myRun()
호출 정확히 1 인수 (0 주어진)
가능한 중복 (http://stackoverflow.com/questions/3765384/pyqt-how-do-i-handle-loops-in-main) –
@Aaron Digulla : 위의 내용을 참조하십시오. 적용 스레드가 작동하지 않습니다. – YumYumYum