-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
54 lines (41 loc) · 1.84 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import pygame_menu
import pygame
from sudokuSolver import run
# this menu file was written using the examples for pygame_menu "https://pygame-menu.readthedocs.io/en/latest/"
difficulty = "Easy"
pygame.init()
surface = pygame.display.set_mode((500, 500))
icon = pygame.image.load("sudokuIcon.png")
pygame.display.set_icon(icon)
pygame.display.set_caption("Sudoku Solver")
def setDifficulty(selected, value):
"""
From the slider get the difficulty the user choose and update the global variable to reflect this
:param selected: the slider option we are currently on
:param value: the value associated with the selected option
:return: None
"""
global difficulty
difficulty = value
def instructions():
menu = pygame_menu.Menu(height=500, width=500, theme=pygame_menu.themes.THEME_DARK, title='Instructions')
instruction = "Click on a square to select it " \
"Type the number into the square " \
"Press SPACE to start backtracking " \
"----------------------------------------"\
menu.add_label(instruction, max_char=-1, font_size=25)
menu.add_button('Play', mainrun)
menu.mainloop(surface)
def mainrun():
"""
Run sudokuSolver.py inputting the difficulty the user choose
:return: None
"""
run(difficulty)
# Build our menu
menu = pygame_menu.Menu(height=500, width=500, theme=pygame_menu.themes.THEME_DARK, title='Sudoku Solver')
menu.add_button('Play', mainrun)
menu.add_selector("Sudoku difficulty: ", [("Very Easy", "V.Easy"), ("Easy", "Easy"), ("Medium", "Medium"), ("Hard", "Hard"), ("Very Hard", "V.Hard")], onchange=setDifficulty)
menu.add_button("Instructions", instructions)
menu.add_button('Quit', pygame_menu.events.EXIT)
menu.mainloop(surface)