-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame_class.py
More file actions
40 lines (39 loc) · 1.54 KB
/
Game_class.py
File metadata and controls
40 lines (39 loc) · 1.54 KB
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
import tkinter as tk # Importing tkinter for the window
from abc import ABC, abstractclassmethod # Importing abc to make parent class method abstract
# Abstract parent class
class Game_Setup(ABC):
# Configurations of the window for color and font
CONFIGS = {
'c1': '#6F61C0',
'c2': '#A084E8',
'c3': '#8BE8E5',
'c4': '#D5FFE4',
'font': ['Consolas', 14, 'bold']
}
# Constructor for the parent class where the intance of the window is created
def __init__(self, main_window, images, icon):
self.main_window = main_window
self.images = images
self.class_window = tk.Toplevel()
self.class_window.config(bg=self.CONFIGS['c1'])
self.class_window.geometry('450x600')
self.class_window.resizable(False, False)
self.class_window.iconphoto(True, icon)
self.class_window.protocol('WM_DELETE_WINDOW', self._on_close)
# Abstract method used for identifying who won in the match
@abstractclassmethod
def _identify_winner(self):
pass
# Abstract methof to implement a restart function for the game
@abstractclassmethod
def _Restart(self):
pass
# Medthod used to close the window completely
def _on_close(self):
self.class_window.destroy()
self.main_window.destroy()
# Method to close the top level window and get back to the main window
def _Exit_game(self):
self.class_window.destroy()
self.main_window.deiconify()
self.main_window.iconphoto(True, self.images['mg_icon'])