-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI_interactions.py
More file actions
55 lines (41 loc) · 1.62 KB
/
UI_interactions.py
File metadata and controls
55 lines (41 loc) · 1.62 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import time
def cts():
"""
Clears the screen.
Returns:
None
"""
print('\033[H\033[J')
def general_pause(message):
"""
Pauses the terminal and waits for the user to press any key before advancing with the program.
Returns:
None
"""
pause_time = True
if pause_time:
print(f"Press any Key to {message}...")
input()
cts() # clear the terminal.
def loading_animation(text, duration=6):
"""
Displays a loading animation effect.
Args:
text (str): The text to display along with the loading animation.
duration (float, optional): The duration of the animation. Defaults to 6.
Returns:
None
"""
start_time = time.time() # get the start time
end_time = start_time + duration # calculate the end time
while time.time() < end_time:
for i in range(5):
time.sleep(0.5) # pause for half a second
loading_message = f"{'.' * i}"
print(f"{loading_message}\r{text}", end="", flush=True) # print loading message with text below
print("\r" + " " * 100 + "\r", end="") # clear the line and overwrite it with 100 whitespaces
print(f"Done {text}!") # print a message when the animation is finished
def printHelp(art):
cts();
print(art)
print("Here are the following commands for this machine:\n\n['off'] - switches off the machine.\n['report'] - generates report of available resources\n['help'] - prints the help screen.\n['espresso'] - launches espresso maker\n['latte'] - launches latte maker\n['cappuccino'] - launches cappuccino maker");