需要在stop_program方法中加入停止论坛打分和论坛打分线程的代码。

修改后的代码如下:

#停止运行
def stop_program(self):
    self.running = False
    self.paused = False
    self.start_button.config(state='normal')
    self.start_score_button.config(state='disabled')
    self.start_score_button_2.config(state='disabled')
    self.start_forum_button.config(state='disabled') # 停止论坛打分
    self.stop_score_button.config(state='disabled')
    self.pause_button.config(state='disabled')
    self.update_running_label('已停止运行')
    if self.forum_thread and self.forum_thread.is_alive():
        self.forum_thread.join()
    if self.forum_score_thread and self.forum_score_thread.is_alive():
        self.forum_score_thread.join() # 停止论坛打分线程

在stop_program方法中,增加了停止论坛打分和论坛打分线程的代码,即将论坛打分按钮的状态设置为不可用,并且判断论坛打分线程是否在运行,如果在运行,则等待线程结束。同时,也需要在start_forum_score方法中将self.forum_score_thread变量赋值为线程对象,以便在stop_program方法中停止这个线程。

Python Selenium 自动评分机器人代码优化:解决论坛打分停止后按钮失效问题

原文地址: https://www.cveoy.top/t/topic/f2jx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录