-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.py
More file actions
76 lines (66 loc) · 2.71 KB
/
Menu.py
File metadata and controls
76 lines (66 loc) · 2.71 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import sys
from helpers.ConsoleHelper import ConsoleHelper
from services.LabService import LabService
from colorama import Fore, init
class Menu:
init(autoreset=True)
@staticmethod
def show():
while True:
ConsoleHelper.clear()
print(f'{Fore.CYAN}|--------------------------------|')
print(f'{Fore.CYAN}| Python labs |')
print(f'{Fore.CYAN}|--------------------------------|\n')
Menu.mount_menu()
option = input(f'\n{Fore.CYAN}Select an option: {Fore.RESET}')
if option == "1":
LabService.run_print_demo()
elif option == "2":
LabService.run_types_and_variables_demo()
elif option == "3":
LabService.run_arithmetic_operations_demo()
elif option == "4":
LabService.run_text_manipulation_demo()
elif option == "5":
LabService.run_lists_demo()
elif option == "6":
LabService.run_conditional_statements_demo()
elif option == "7":
LabService.run_loops_demo()
elif option == "8":
LabService.run_try_except_demo()
elif option == "9":
LabService.run_file_write_demo()
elif option == "10":
LabService.run_file_read_demo()
elif option == "11":
LabService.run_excel_read_demo()
elif option == "0":
Menu.exit();
else:
ConsoleHelper.clear()
print(f'{Fore.YELLOW}Invalid option. Please try again.\n')
input('Press Enter to continue...')
@staticmethod
def mount_menu():
menu_options = [
'Print function demonstration.'
, 'Types and variables demonstration.'
, 'Arithmetic operations demonstration.'
, 'String (text) manipulation demonstration.'
, 'Lists demonstration.'
, 'Conditional statements demonstration.'
, 'Loops demonstration.'
, 'Try/except/else/finally demonstration.'
, 'I/O - Write a text file on disk demonstration. (only Windows)'
, 'I/O - Read a text file from disk demonstration. (only Windows)'
, 'Read a Excel file demonstration. (only Windows)'
];
print('*** Menu ***\n')
for i in range(len(menu_options)):
print(Fore.YELLOW + f'{i + 1}.'.rjust(3,' ') + Fore.RESET, menu_options[i])
print(Fore.YELLOW + '0.'.rjust(3,' ') + Fore.RESET, 'Exit.')
@staticmethod
def exit():
print('Exiting...')
sys.exit(0)