From 6d53be0ad254265b0526a8b2fc6915719619fa0f Mon Sep 17 00:00:00 2001 From: MrB <154423640@qq.com> Date: Wed, 17 Apr 2024 13:20:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=9E=E6=97=B6=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=92=8C=E6=8F=90=E9=86=92=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/main.py | 69 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/main/main.py b/main/main.py index ce77f57..fc29417 100644 --- a/main/main.py +++ b/main/main.py @@ -7,7 +7,7 @@ import pickle import random import qdarkstyle -from PySide6.QtCore import QTimer +from PySide6.QtCore import QTimer, QPropertyAnimation, QRect, QPoint from PySide6.QtWidgets import * from PySide6.QtGui import QIcon from win.win import Ui_Form as Form1 @@ -50,6 +50,9 @@ class Form(Form1): self.B_read.clicked.connect(self.B_read_fun) self.timer = QTimer() + self.shake_timer = QTimer(self) + self.shake_times = 0 + self.shake_timer.timeout.connect(self.shake_window) self.timer.setInterval(1000) self.timer.timeout.connect(self.update_time) self.init_bt() @@ -248,40 +251,58 @@ class Form(Form1): except Exception as e: print(e) - def check_sudo(self): + def check_sudo(self,mode=0): global cnt, del_cnt, subject_with_answer f = 1 for row_index in range(9): for col_index in range(9): num = subject_with_answer[row_index, col_index] - - # 获取该格子对应的行、列、九宫格 - sudo_row = sd.get_row(subject_with_answer, row_index) - sudo_col = sd.get_col(subject_with_answer, col_index) - sudo_block = sd.get_block(subject_with_answer, row_index, col_index) - # print(num) - # print(sudo_row) - # print(sudo_col) - # print(sudo_block) - - cnt_oc1 = count_occurrences(sudo_row, num, 0) - cnt_oc2 = count_occurrences(sudo_col, num, 0) - cnt_oc3 = count_occurrences(sudo_block, num, 1) - if cnt_oc1 != 1 or cnt_oc2 != 1 or cnt_oc3 != 1: - f = 0 - break + if num == 0: + pass + else: + # 获取该格子对应的行、列、九宫格 + sudo_row = sd.get_row(subject_with_answer, row_index) + sudo_col = sd.get_col(subject_with_answer, col_index) + sudo_block = sd.get_block(subject_with_answer, row_index, col_index) + + cnt_oc1 = count_occurrences(sudo_row, num, 0) + cnt_oc2 = count_occurrences(sudo_col, num, 0) + cnt_oc3 = count_occurrences(sudo_block, num, 1) + # print(cnt_oc1, cnt_oc2, cnt_oc3) + if cnt_oc1 != 1 or cnt_oc2 != 1 or cnt_oc3 != 1: + f = 0 + break if f == 0: break if f == 1: - print("yes") - QMessageBox.information(self, '提示', '成功') - self.timer.stop() + # print("yes") + if del_cnt == cnt: + QMessageBox.information(self, '提示', '成功') + self.timer.stop() else: - print("no") - QMessageBox.information(self, '提示', '失败') + # print("no") + if mode == 1: + self.shake_timer.start(30) + else: + QMessageBox.information(self, '提示', '失败') + + def shake_window(self): + self.shake_times += 1 + if self.shake_times == 5: + self.shake_times = 0 + self.shake_timer.stop() + else: + if self.shake_times % 2 == 0: + self.move(self.x() + 7, self.y()) + else: + self.move(self.x() - 7, self.y()) + + + + def put_num(self): global cnt, del_cnt, subject_with_answer, stack @@ -327,6 +348,8 @@ class Form(Form1): if cnt == del_cnt: self.check_sudo() + else: + self.check_sudo(1) def B_S_fun(self): global cnt, del_cnt, stack, sudo, subject_with_answer