Gives you a visual hint on your progress. Red - You've got an incorrect number at the location Yellow - You're missing an anwer for that location :param window: The GUI's Window :type window: sg.Window :param solution: A 2D array containing the solution :type solution:
(window, solution)
| 52 | |
| 53 | |
| 54 | def check_progress(window, solution): |
| 55 | """ |
| 56 | Gives you a visual hint on your progress. |
| 57 | Red - You've got an incorrect number at the location |
| 58 | Yellow - You're missing an anwer for that location |
| 59 | |
| 60 | :param window: The GUI's Window |
| 61 | :type window: sg.Window |
| 62 | :param solution: A 2D array containing the solution |
| 63 | :type solution: numpy.ndarray |
| 64 | :return: True if the puzzle has been solved correctly |
| 65 | :rtype: bool |
| 66 | """ |
| 67 | solved = True |
| 68 | for r, row in enumerate(solution): |
| 69 | for c, col in enumerate(row): |
| 70 | value = window[r,c].get() |
| 71 | if value: |
| 72 | try: |
| 73 | value = int(value) |
| 74 | except: |
| 75 | value = 0 |
| 76 | if value != solution[r][c]: |
| 77 | window[r,c].update(background_color='red') |
| 78 | solved = False |
| 79 | else: |
| 80 | window[r,c].update(background_color=sg.theme_input_background_color()) |
| 81 | else: |
| 82 | solved = False |
| 83 | window[r, c].update(background_color='yellow') |
| 84 | return solved |
| 85 | |
| 86 | |
| 87 | def create_and_show_puzzle(window): |