-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsmall_project.py
95 lines (76 loc) · 2.7 KB
/
small_project.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from pywebio.input import *
from pywebio.output import *
def verify(username,password):
return username=='user' and password == '1234'
def login():
data = input_group("Login",[
input('Username', name='username', type=TEXT),
input('Password', name='password', type=PASSWORD),
actions('actions', [
{'label': 'Login', 'type': 'submit','value': 'login'},
{'label': 'Register', 'value': 'register'},
{'label': 'Reset', 'type': 'reset'}
], name='action')
])
username = data['username']
password = data['password']
if verify(username,password):
return True
else:
with use_scope('msglabel', clear=True):
put_text('Please enter a valid credential!')
return login()
def user_info():
data = input_group("User Info",[
input('Name', name='name', type=TEXT),
input('Surname', name='surname', type=TEXT),
input('Date of Birth', name='birthday', type=DATE)
])
return data
def user_address():
country2city = {
'Türkiye': ['Osmaniye', 'İstanbul', 'Ankara'],
'USA': ['New York', 'Los Angeles', 'San Francisco'],
}
countries = list(country2city.keys())
data = input_group("Select a location", [
select('Country', options=countries, name='country',
onchange=lambda c: input_update('city', options=country2city[c])),
select('City', options=country2city[countries[0]], name='city'),
])
return data
def select_service():
data = input_group("Select Service",[
radio('Services',['Clean','Repair','Modify','Other'],name='service')
])
return data['service']
def get_invoice(info_data,address_data,service_data):
put_table([
['User Info:',info_data],
['User Address:',address_data],
['Service Selection',service_data]
])
def main_menu():
with use_scope('menu_scope', clear=True):
responce = actions('Select Module', ['info', 'adress','service','invoice','close'])
return responce
def index():
response = main_menu()
while response!='close':
if response=='info':
info_data= user_info()
elif response=='adress':
address_data= user_address()
elif response== 'service':
service_data =select_service()
elif response== 'invoice':
get_invoice(info_data,address_data,service_data)
break
response=main_menu()
def main():
if login():
clear('msglabel')
index()
else:
put_text('Err')
main()