-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameIntro.py
54 lines (45 loc) · 1.79 KB
/
gameIntro.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
"""
Description: GUI for the starting of the game
<pre>
Name: Gabriel Krishnadasan, Alizea Hinz, Aidan Rooney, Marissa Nicole Esteban (Pascal)
Course: COMP-305 FA22
Professor: A. Nuzen
</pre>
"""
import tkinter as tk
class GameIntro:
def __init__(self)->None:
"""
Initializer for the game intro screen
"""
# Constants
self.CONTROL_FRAME_HEIGHT = 500
# Create window
self.window = tk.Tk()
self.window.title("Battleship")
# Create frame for controls
self.control_frame = tk.Frame(self.window, width = self.CONTROL_FRAME_HEIGHT,
height = self.CONTROL_FRAME_HEIGHT)
self.control_frame.grid(row = 1, column = 2, padx=40, pady=40)
(self.human_button, self.ai_button) = self.add_control()
def add_control(self)->tuple:
"""
Create control buttons and welcome message, and add them to the control frame
"""
welcome = tk.Label(self.control_frame, text="Welcome to Battleship", font=("Helvetica", 20))
welcome.grid(row=1, column = 1)
human_button = tk.Button(self.control_frame, text="Human vs Human", font=("Helvetica", 10))
human_button.grid(row=2, column=1)
ai_button = tk.Button(self.control_frame, text="Human vs Computer", font=("Helvetica", 10))
ai_button.grid(row=3, column=1)
return (human_button, ai_button)
def set_human_handler(self, handler)->None:
"""
Set handler for clicking on start button to the function handler
"""
self.human_button.configure(command = handler)
def set_ai_handler(self, handler)->None:
"""
Set handler for clicking on pause button to the function handler
"""
self.ai_button.configure(command = handler)