1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing the classes for GUI components involving molecules."""
25
26
27 import wx
28 import wx.lib.buttons
29
30
31 from graphics import fetch_icon
32 from gui.components.base_list import Base_list
33 from gui.string_conv import gui_to_str, str_to_gui
34 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
35 from pipe_control.mol_res_spin import molecule_loop, return_molecule
36 from status import Status; status = Status()
37 from user_functions.data import Uf_info; uf_info = Uf_info()
38
39
41 """The GUI element for listing loaded molecules."""
42
44 """Launch the bmrb.thiol_state user function.
45
46 @param event: The wx event.
47 @type event: wx event
48 """
49
50
51 item = self.element.GetFirstSelected()
52
53
54 state = None
55 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'thiol_state'):
56 state = cdp.exp_info.thiol_state
57
58
59 if state == None:
60 uf_store['bmrb.thiol_state'](wx_parent=self.parent)
61 else:
62 uf_store['bmrb.thiol_state'](wx_parent=self.parent, state=state)
63
64
66 """Launch the molecule.name user function.
67
68 @param event: The wx event.
69 @type event: wx event
70 """
71
72
73 item = self.element.GetFirstSelected()
74
75
76 id = gui_to_str(self.element.GetItemText(item))
77
78
79 uf_store['molecule.name'](wx_parent=self.parent, mol_id=id)
80
81
83 """Launch the molecule.type user function.
84
85 @param event: The wx event.
86 @type event: wx event
87 """
88
89
90 item = self.element.GetFirstSelected()
91
92
93 id = gui_to_str(self.element.GetItemText(item))
94
95
96 type = None
97 mol = return_molecule(id)
98 if hasattr(mol, 'type') and mol.type != None:
99 type = mol.type
100
101
102 if type == None:
103 uf_store['molecule.type'](wx_parent=self.parent, mol_id=id)
104 else:
105 uf_store['molecule.type'](wx_parent=self.parent, mol_id=id, type=type)
106
107
109 """Determine if the data input is complete.
110
111 @return: The answer to the question.
112 @rtype: bool
113 """
114
115
116 for mol in molecule_loop():
117
118 if mol.name == None:
119 return False
120
121
122 if not hasattr(mol, 'type') or mol.type == None:
123 return False
124
125
126 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'thiol_state'):
127 return False
128
129
130 return True
131
132
134 """Set the label of the StaticBox."""
135
136
137 label = self.title
138 if self.is_complete():
139 label += " (complete)"
140 else:
141 label += " (incomplete)"
142
143
144 self.data_box.SetLabel(label)
145
146
148 """Override the base variables."""
149
150
151 self.title = "Molecule information"
152 self.observer_base_name = "molecule"
153 self.button_placement = None
154
155
156 self.columns = [
157 "ID string",
158 "Name",
159 "Type",
160 "Thiol state"
161 ]
162
163
164 self.popup_menus = [
165 {
166 'id': wx.NewId(),
167 'text': "&Name the molecule",
168 'icon': fetch_icon(uf_info.get_uf('molecule.name').gui_icon),
169 'method': self.action_molecule_name
170 }, {
171 'id': wx.NewId(),
172 'text': "Set the molecule &type",
173 'icon': fetch_icon(uf_info.get_uf('molecule.type').gui_icon),
174 'method': self.action_molecule_type
175 }, {
176 'id': wx.NewId(),
177 'text': "Set the thiol &state",
178 'icon': fetch_icon(uf_info.get_uf('bmrb.thiol_state').gui_icon),
179 'method': self.action_bmrb_thiol_state
180 }
181 ]
182
183
185 """Method called from self.build_element_safe() to update the list data."""
186
187
188 i = 0
189 for mol, mol_id in molecule_loop(return_id=True):
190
191 self.element.InsertStringItem(i, str_to_gui(mol_id))
192
193
194 if mol.name != None:
195 self.element.SetStringItem(i, 1, str_to_gui(mol.name))
196
197
198 if hasattr(mol, 'type'):
199 self.element.SetStringItem(i, 2, str_to_gui(mol.type))
200
201
202 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'thiol_state'):
203 self.element.SetStringItem(i, 3, str_to_gui(cdp.exp_info.thiol_state))
204
205
206 i += 1
207