控制按钮状态

This commit is contained in:
halliday2023 2024-02-12 22:28:36 +08:00
parent e78d291936
commit 57e34b35b9
1 changed files with 9 additions and 3 deletions

View File

@ -51,7 +51,9 @@ class Window(formType, baseType):
self.start_thread() self.start_thread()
else: else:
self.start_run_db() self.start_run_db()
# 按钮置灰
self.startButton.setEnabled(not self.startButton.isEnabled())
@Slot() @Slot()
def stop(self): def stop(self):
@ -61,6 +63,8 @@ class Window(formType, baseType):
self.stop_run_file() self.stop_run_file()
else: else:
self.stop_run_db() self.stop_run_db()
# 按钮恢复
self.startButton.setEnabled(not self.startButton.isEnabled())
@Slot() @Slot()
def conntest(self): def conntest(self):
@ -104,9 +108,11 @@ class Window(formType, baseType):
def stop_run_file(self): def stop_run_file(self):
# 终止线程的事件循环
global_var.set_value('start_flag',False) global_var.set_value('start_flag',False)
self.thread.quit() # 终止线程的事件循环 self.thread.quit()
self.thread_running = False # 标记线程停止 # 标记线程停止
self.thread_running = global_var.get_value('start_flag')