为什么对processEvents的调用在长达9秒的时间内什么都不做?在
我有一个应用程序,它有一个基于PySide的QT接口,UI代码位于底层实际应用程序逻辑之上的解耦层。当用户执行一个执行可能会运行一段时间的低级应用程序逻辑的操作时,实际发生的情况是:
这一切都是分散在许多文件中,以一种解耦的方式实现的。我将尝试提供一些片段来描述流程。在
解耦的低级逻辑工作循环:
while not completed_event.wait(0.1) and not work_state.is_cancelled():
work_completeness, work_description = work_state.get_completeness(), work_state.get_description()
for client in self.clients:
if work_completeness != last_completeness or work_description != last_description:
client.event_prolonged_action_update(client is acting_client, work_description, step_count * work_completeness)
# THE LAST CALL TO THE NEXT LINE LOCKS UP FOR NO REASON
client.event_tick(client is acting_client)
last_completeness, last_description = work_completeness, work_description
PySide/QT层客户端事件触发函数:
^{pr2}$在PySide/QT层中使用信号/插槽来获取GUI线程上发生的工作线程调用:
def event_pre_line_change(self, active_client, line0, line_count):
self.pre_line_change_signal.emit((line0, line_count))
def event_post_line_change(self, active_client, line0, line_count):
self.post_line_change_signal.emit((line0, line_count))
def event_uncertain_reference_modification(self, active_client, data_type_from, data_type_to, address, length):
self.uncertain_reference_modification_signal.emit((data_type_from, data_type_to, address, length))
我之所以使用signals/slot将对worker线程的调用委托给GUI线程,是因为PySide/QT需要这样做,因为它们将更新UI。在
复制案例,如果你想深入挖掘:
目前没有回答
相关问题 更多 >
编程相关推荐