-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (53 loc) · 1.36 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
from settings import WIDTH, HEIGHT, GRID_SIZE
from cell import Cell
from utils import height_percentage, width_percentage
from tkinter import *
root = Tk()
# Override the settings of the window
root.configure(bg='black')
root.geometry(f'{WIDTH}x{HEIGHT}')
root.title('Minesweeper Game')
root.resizable(False, False)
top_frame_height = height_percentage(25)
top_frame = Frame(
root,
bg='black',
width=WIDTH,
height=top_frame_height
)
top_frame.place(x=0, y=0)
game_title = Label(
top_frame,
bg='black',
fg='white',
text='Minesweeper Game',
font=('', 48)
)
game_title.place(x=width_percentage(25))
left_frame_width = width_percentage(25)
left_frame = Frame(
root,
bg='black',
width=left_frame_width,
height=HEIGHT - top_frame_height
)
left_frame.place(x=0, y=top_frame_height)
main_frame_width = width_percentage(75)
main_frame_height = height_percentage(75)
main_frame = Frame(
root,
width=main_frame_width,
height=main_frame_height
)
main_frame.place(x=left_frame_width, y=top_frame_height)
for x in range(GRID_SIZE):
for y in range(GRID_SIZE):
c = Cell(x, y)
c.create_btn(main_frame)
c.cell_btn.grid(row=x, column=y)
# Call the label from the Cell class
Cell.create_cell_count_label(left_frame)
Cell.cell_count_label.place(x=0, y=0)
Cell.randomize_mines()
# Run the window
root.mainloop()