-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
65 lines (53 loc) · 1.54 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
55
56
57
58
59
60
61
62
63
64
65
from tkinter import *
from cell import Cell
import settings
import utils
root = Tk()
# Override the settings of the window
root.geometry(f'{settings.WIDTH}x{settings.HEIGHT}')
root.configure(bg='black')
root.title("Minesweeper Game by [email protected]")
root.resizable(False, False)
top_frame = Frame(
root,
bg='black',
width=settings.WIDTH,
height=utils.height_percentage(25)
)
top_frame.place(x=0, y=0)
game_title = Label(
top_frame,
text="Minesweeper Game",
bg='black',
fg='white',
font=("", 48)
)
game_title.place(x=utils.width_percentage(25), y=utils.height_percentage(5))
left_frame = Frame(
root,
bg='black',
width=utils.width_percentage(25),
height=utils.height_percentage(75)
)
left_frame.place(x=0, y=utils.height_percentage(25))
center_frame = Frame(
root,
bg='black',
width=utils.width_percentage(75),
height=utils.height_percentage(75)
)
center_frame.place(x=utils.width_percentage(25), y=utils.height_percentage(25))
for x in range(settings.GRID_SIZE):
for y in range(settings.GRID_SIZE):
cell = Cell(x, y, root)
cell.create_btn_object(center_frame)
cell.cell_btn_object.grid(column=x, row=y)
# Call the label from the Cell class to show remaining cells
Cell.create_cell_count_label(left_frame)
Cell.cell_count_label_object.place(x=0, y=0)
# Call the label from the Cell class to show remaining mines
Cell.create_mines_count_label(left_frame)
Cell.mines_count_label_object.place(x=0, y=150)
Cell.randomize_mines()
# Run the window
root.mainloop()