MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / check_progress

Function check_progress

DemoPrograms/Demo_Sudoku.py:54–84  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

52
53
54def 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
87def create_and_show_puzzle(window):

Callers 1

mainFunction · 0.85

Calls 2

getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected