在以下代码下运行时出现错误,似乎父窗口有问题。 由于错误消息框而导致错误后,应用程序立即崩溃
QObject :: setParent:无法设置父对象,新的父对象位于另一个线程中
QObject :: startTimer:无法从另一个线程启动计时器
分段错误(核心已转储)
def error_box(self, error_message):
error_alert = QtWidgets.QErrorMessage(self.mainwindow)
error_alert.setWindowTitle("ERROR")
error_alert.showMessage(error_message)
def start_method(self, provided_email):
def provision_card():
self.lineEdit.setReadOnly(1)
self.pushButton.setEnabled(False)
self.pushButton_2.setEnabled(False)
self.textEdit.setStyleSheet("QTextEdit {color:black}")
self.textEdit.append(" Email Address Entered : "+provided_email+"\n")
os.chdir(Path)
dark_pcc = "java -jar *.jar | tee -i stdout.txt"
p = subprocess.Popen(dark_pcc, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
line = p.stdout.readline().rstrip()
print (line)
self.textEdit.append(str("\n"+line.decode()))
input_string = provided_email+'\ny\ny\n'
line2 = p.communicate(input=input_string.encode())[0]
print (line2.decode())
self.textEdit.append("\n"+line2.decode())
stdout = Path+"stdout.txt"
f = open(stdout, 'r')
for line in f:
if re.match("(.+)completed successfully(.+)", line):
self.textEdit.setStyleSheet("QTextEdit {color:Green}")
self.lineEdit.clear()
elif re.match("(.+)ailed(.+)", line):
self.textEdit.setStyleSheet("QTextEdit {color:red}")
self.error_box("FAILED\n"+line)
self.lineEdit.setFocus(True)
os.remove(stdout)
self.lineEdit.setReadOnly(0)
self.pushButton.setEnabled(True)
self.pushButton_2.setEnabled(True)
multi = threading.Thread(target=provision_card)
multi.setDaemon(True)
multi.start()