-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·49 lines (34 loc) · 1.46 KB
/
Copy pathexample.py
File metadata and controls
executable file
·49 lines (34 loc) · 1.46 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
#! /usr/bin/python3
import menu
import sys
class printing:
def __init__ (self, string):
self.a_string = string
def printing (self):
print(self.a_string[0])
def goodbye ():
print ('Good Bye!')
def example_one ():
# create a 50x30 main menu with box around and 5 items
main_menu = menu.Menu(20, 50, 0, 0, box=True, item_num=5, warp=True)
# create a 50x30 sub menu with no box and 3 items
sub_menu = menu.Menu(20, 50, 0, 0, box=False, item_num=3, warp=False)
# when selected, the menu exit and print Good Bye
main_menu.add_simple_item(0, 'Print Good Bye!', function=goodbye, breaking=True)
# when selected, enter sub menu
main_menu.add_link_item(1, 'Sub menu', menu_obj=sub_menu)
# when selected, edit the string
a_string = ['Hello!']
main_menu.add_edit_item(2, 'String: ', edit_target=a_string)
# when selected, print the string (Due to currently does not allow function with argument, use a class as work around)
out = printing(a_string)
main_menu.add_simple_item(3, 'Print above', function=out.printing, breaking=True)
# when selected, exit the main menu
main_menu.add_exit_item(4, 'Exit')
# place holder
sub_menu.add_simple_item(0, 'Welcome to', start_y=10, start_x=12)
sub_menu.add_simple_item(1, 'Nothing', start_y=12, start_x=10)
sub_menu.add_exit_item(2, 'Return', start_y=14, start_x=14)
main_menu.display()
if __name__ == "__main__":
example_one()