Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nrossol
Sudoku Backtracking
Commits
3578d573
Commit
3578d573
authored
Sep 02, 2020
by
nrossol
Browse files
Finished grid drawing in gui.py, interactive buttons/grid to be implemented next.
parent
6dfe86fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
gui.py
View file @
3578d573
...
...
@@ -17,15 +17,17 @@ grid = [ [ 3, 2, 1, 0, 5, 0, 9, 4, 7 ],
BLACK
=
(
0
,
0
,
0
)
WHITE
=
(
255
,
255
,
255
)
#Initialize Pygame:
#os.environ["SDL_VIDEODRIVER"] = "dummy"
os
.
environ
[
'SDL_VIDEODRIVER'
]
=
'windib'
#Initialize Pygame and variables::
pygame
.
init
()
pygame
.
display
.
init
()
screen_width
=
500
screen_height
=
500
screen_width
=
490
screen_height
=
490
buttonArea
=
100
#height of area where buttons will be below the grid
box_size
=
50
margin
=
5
screen
=
pygame
.
display
.
set_mode
([
screen_width
,
screen_height
])
pygame
.
display
.
set_caption
(
"Main"
)
font
=
pygame
.
font
.
SysFont
(
"Comic Sans MS"
,
30
)
screen
=
pygame
.
display
.
set_mode
([
screen_width
,
screen_height
+
buttonArea
])
pygame
.
display
.
set_caption
(
"Sudoku"
)
clock
=
pygame
.
time
.
Clock
()
#Main Loop:
...
...
@@ -34,5 +36,27 @@ while not done:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
pygame
.
QUIT
:
done
=
True
screen
.
fill
(
BLACK
)
#draw grid:
for
i
in
range
(
0
,
screen_width
,
box_size
+
margin
):
for
j
in
range
(
0
,
screen_height
,
box_size
+
margin
):
pygame
.
draw
.
rect
(
screen
,
WHITE
,
(
i
,
j
,
box_size
,
box_size
),
0
)
pygame
.
draw
.
rect
(
screen
,
WHITE
,
(
0
,
495
,
490
,
100
),
0
)
#fill in grid:
for
i
in
range
(
0
,
9
):
for
j
in
range
(
0
,
9
):
number_surface
=
font
.
render
(
str
(
grid
[
i
][
j
]),
False
,
(
0
,
0
,
0
))
screen
.
blit
(
number_surface
,
(
7
+
i
*
(
box_size
+
margin
),
7
+
j
*
(
box_size
+
margin
)))
#update display
pygame
.
display
.
update
()
#make screen update 60 fps
clock
.
tick
(
60
)
pygame
.
quit
()
\ No newline at end of file
sudokuSolver.exe
deleted
100644 → 0
View file @
6dfe86fe
File deleted
sudokuSolverPython.pyc
deleted
100644 → 0
View file @
6dfe86fe
File deleted
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment