0
我是PyQt編碼的新手。我正嘗試從父級啓動子進程(GUI)。在此我使用waitcondition和互斥瞭解其functionality.Here是我的代碼:當在父級pyqt中使用waitcondition時,子GUI不顯示
import sys
from PyQt4 import QtGui, QtCore
waitCondition = QtCore.QWaitCondition()
mutex = QtCore.QMutex()
class Child(QtGui.QWidget):
def __init__(self,ABC=None):
super(Child, self).__init__()
def startUI(self):
self.text = QtGui.QLineEdit()
self.text.returnPressed.connect(self.wakeup)
def wakeup(self):
waitCondition.wakeAll()
class Parent(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Parent, self).__init__()
val = 3
abc = Child(val)
abc.startUI()
mutex.lock()
waitCondition.wait(mutex)
mutex.unlock()
print ("Mutex unlocked")
def main():
app = QtGui.QApplication(sys.argv)
aa = Parent()
aa.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
如果我執行這個代碼,沒有啓動子GUI那裏,好像我去掉waitCondition.wait(互斥)在Parent類中運行它,GUI顯示出來。
有人能幫我確定我在這裏做的錯誤嗎?