需要在AutoScore100类中的run_program方法中添加循环,直到打分结束为止。具体代码如下:

def run_program(self): while self.running: while self.paused: time.sleep(0.5)

    self.update_running_label('等待登录...')
    try:
        while True:
            for handle in self.browser.window_handles:
                self.browser.switch_to.window(handle)
                if '内蒙古开放大学' in self.browser.title:
                    self.update_running_label('登录成功')
                    self.start_score_button.config(state='normal')
                    self.start_score_button_2.config(state='normal')
                    break
            else:
                self.update_running_label('未登录')
                time.sleep(5)
                continue
            break

        # 循环打分
        while True:
            if not self.running:
                break

            if self.paused:
                continue

            # 执行对应的打分功能
            # ...

            # 点击下一个学生
            next_student_element = self.browser.find_element(By.CLASS_NAME, "icon-student-right-narrow")
            if "unclickable" in next_student_element.get_attribute("class"):
                print("已经到最后一个学生")
                self.update_running_label('打分已完成')
                break
            else:
                next_student_element.click()
                time.sleep(3)
                self.update_running_label('打分中...')
        break

    except Exception as e:
        print(e)
        continue

需要将对应的打分功能代码放入循环中,同时在循环结束后更新状态标签为打分已完成。


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

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