我有一个应用程序,我尝试使用 while 循环但应用程序只是挂起,现在我认为我需要使用 QEventLoop 使应用程序工作这里是一些相关代码
def ex_initialator(self):
""" sets up things for the problem runner """
print "ayadara"
print "self.start_button_status this is...::" ,self.start_button_status
#:Pop up dialogs
no_options_selected = QtGui.QMessageBox()
select_range = QtGui.QMessageBox()
select_op_type = QtGui.QMessageBox()
#:Shows message if no options selected
if len(self.op_types) < 1 and len(self.num_range) < 1 and self.start_button_status == 0:
print "Please pick from the options provided"
no_options_selected.exec_()
#:Shows message if range is not selected
if len(self.op_types) >= 1 and len(self.num_range) < 1 and self.start_button_status == 0 :
print "Please pick at least one of the ranges"
select_range.exec_()
#:Shows message if op_type/s not selected
if len(self.op_types) < 1 and len(self.num_range) >= 1 and self.start_button_status == 0:
print "Please pick at least one of the operation types"
select_op_type.exec_()
#:Correct inputs initiates problem maker
if len(self.op_types) >= 1 and len(self.num_range) >= 1 and (self.start_button_status == 0 or self.start_button_status == 1):
self.start_button_status = 1
self.prob_signal.runner_sig.connect(self.problem_runner)
self.prob_signal.runner_sig.emit()
def problem_runner(self):
""" Expression Makers """
while self.start_button_status == 1:
#:picks range types
range_type = random.choice(self.num_range)
D = decimal.Decimal
self.answer_lineEdit.returnPressed.connect(self.ex_evaluator)
self.answer_lineEdit.clear()
我想要的是能够开始、暂停和停止按钮,我是初学者,所以我在使用 QLineEdit 时可能会出错,在这种情况下,我会很感激一些关于更好实施的建议