-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
129 lines (95 loc) · 4.12 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from tkinter import *
from tkinter import messagebox
import os
class Main_page():
def __init__(self):
pass
def gui(self):
# Main window GUI
# self.main = Tk()
self.main = Toplevel()
self.main.title("Game Deck")
self.main.geometry("1377x768")
self.main.resizable(0, 0)
self.main.configure(bg="white")
# bg for tkinter window
self.main_bg = Label(self.main)
self.main_bg.place(relx=0, rely=0, width=1377, height=768)
self.image = PhotoImage(file="./images/pages/main.png")
self.main_bg.configure(image=self.image)
# Game buttons
# row 1
self.snake_game_btn = Button(self.main, text ="PLAY",bg="#0074e4", relief="flat", width=10, height=1, cursor="hand2", command=self.snake)
self.snake_game_btn.place(x=320, y=352.5)
self.quiz_game_btn = Button(self.main, text ="PLAY", bg="#0074e4", relief="flat", width=10, height=1, cursor="hand2", command=self.quiz_game)
self.quiz_game_btn.place(x=636, y=352.5)
self.pong_game_btn = Button(self.main, text ="PLAY", bg="#0074e4", relief="flat", width=10, height=1, cursor="hand2", command=self.pong)
self.pong_game_btn.place(x=948, y=354)
# row 2
self.turtle_crossing_btn = Button(self.main, text ="PLAY",bg="#0074e4", relief="flat", width=10, height=1, cursor="hand2", command=self.turtle_crossing)
self.turtle_crossing_btn.place(x=320, y=678)
self.hangman_btn = Button(self.main, text ="PLAY", bg="#0074e4", relief="flat", width=10, height=1, cursor="hand2", command=self.hangman)
self.hangman_btn.place(x=638, y=680)
self.profile_btn = Button(self.main, text ="USER", bg="#0074e4", relief="flat", width=10, height=1, cursor="hand2", command=self.profile)
self.profile_btn.place(x=953, y=678)
# instruction btn
self.inst_btn = Label(self.main)
self.ins_bg = PhotoImage(file="./images/buttons/instructions_btn.png")
self.instruction_btn = Button(self.main, bg="#121212", relief="flat", image=self.ins_bg ,width=70, height=70, cursor="hand2", command=self.instructions)
self.instruction_btn.place(x=5, y=7)
# exit btn
self.exit_btn = Label(self.main)
self.exit_bg = PhotoImage(file="./images/buttons/exit_btn (2).png")
self.exit_btn = Button(self.main, bg="#121212", relief="flat", image= self.exit_bg ,width=70, height=70, cursor="hand2", command=self.exit)
self.exit_btn.place(x=1294, y=7)
self.main.protocol("WM_DELETE_WINDOW", self.confirm_exit)
self.main.mainloop()
# helper methods
def run_file(self, name):
if os.getcwd().split('\\')[-1] == name:
os.system("python main.py")
else:
os.chdir(name)
os.system("python main.py")
os.chdir("..")
def pong(self):
self.main.withdraw()
self.run_file("Pong Game")
self.main.deiconify()
def snake(self):
self.main.withdraw()
self.run_file("Snake Game")
self.main.deiconify()
def quiz_game(self):
self.main.withdraw()
self.run_file("Quiz Game (GUI)")
self.main.deiconify()
def turtle_crossing(self):
self.main.withdraw()
self.run_file("Turtle Crossing Game")
self.main.deiconify()
def hangman(self):
self.main.withdraw()
self.run_file("Hangman Game")
self.main.deiconify()
def profile(self):
self.main.withdraw()
from profile import Profile_page
Profile_page().gui()
def instructions(self):
self.main.withdraw()
from instructions import Instructions_page
Instructions_page().gui()
def exit(self):
dummy = Tk()
dummy.destroy()
messagebox.showinfo("Exit", "Thank you for playing Game Deck!! \nSee you soon.")
self.main.destroy()
def confirm_exit(self):
self.dummy = Tk()
self.dummy.destroy()
yes_no = messagebox.askyesno("Confirm selection", "Are you sure you want to exit?")
if yes_no:
self.exit()
# demo = Main_page()
# demo.gui()