-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemergency_equip_backend.py
73 lines (55 loc) · 2.29 KB
/
emergency_equip_backend.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
import copy
def setup_variables(w):
w.type = 'Emergency Equipment'
w.title = None
w.description = None
w.aircraft_type = None
w.equipment_type = None
w.aircraft_type = None
w.manufacturer = None
w.attaching_hardware = []
w.weight= 0
w.available_equipment= ['Crash Axe', 'Defibrillator', 'ELT', 'Fire Extinguisher', 'First Aid Kit', 'Flashlight', 'Life Line',
'Life Raft', 'Life Vest', 'Life Vest Crew', 'Life Vest Infant',
'Manual Release Tool', 'Medical Kit', 'Megaphone', 'PBE', 'Seat Belt', 'Seat Belt Infant', 'Survival Kit']
def update_variables(w, source):
w.title = source.title
w.description = source.description
w.aircraft_type = source.aircraft_type
w.equipment_type = source.equipment_type
w.attaching_hardware = copy.deepcopy(source.attaching_hardware)
w.weight = source.weight
w.manufacturer = source.manufacturer
if w.aircraft_type in ['A320', 'A319']:
w.treeview_node = 'A320 EE'
class Emergency_Equip_Backend():
def __init__(self, parent_page, controller):
self.controller = controller #main append
self.parent_page = parent_page #this is the tkinter frame associated with this BE.
setup_variables(self)
self.save_class = Emergency_Equip_Saved_State
self.mainapp = self.parent_page.mainapp
def update_component(self, source, type):
#pass current joint through to state class (for undo redo)
if type != 'undo_redo':
self.controller.states.component_updated(type, self, Emergency_Equip_Saved_State)
elif type == 'new':
self.controller.states.component_updated(type, self, Emergency_Equip_Saved_State)
update_variables(self, source)
def gen_save_dict(self, comments_from_text_widget = True, comments = None):
if comments_from_text_widget:
comments = self.parent_page.comment_text.get("1.0","end")
else:
comments = comments
return {'Title': self.title,
'Description': self.description,
'Aircraft Type': self.aircraft_type,
'Equipment Type': self.equipment_type,
'Attaching Hardware': self.attaching_hardware,
'Weight': self.weight,
'Manufacturer': self.manufacturer,
'Comments': comments}
class Emergency_Equip_Saved_State():
def __init__(self, emergency_equip):
setup_variables(self)
update_variables(self, emergency_equip)