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 import dep_check
32 from graphics import fetch_icon
33 from gui.components.base_list import Base_list
34 from gui.string_conv import gui_to_str, str_to_gui
35 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
36 from pipe_control.mol_res_spin import molecule_loop, return_molecule
37 from status import Status; status = Status()
38 from user_functions.data import Uf_info; uf_info = Uf_info()
39
40
41
42 MENU_MOLECULE_NAME = wx.NewId()
43 MENU_MOLECULE_TYPE = wx.NewId()
44 MENU_BMRB_THIOL_STATE = wx.NewId()
45
46
47
49 """The GUI element for listing loaded molecules."""
50
52 """Launch the bmrb.thiol_state user function.
53
54 @param event: The wx event.
55 @type event: wx event
56 """
57
58
59 item = self.element.GetFirstSelected()
60
61
62 state = None
63 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'thiol_state'):
64 state = cdp.exp_info.thiol_state
65
66
67 if state == None:
68 uf_store['bmrb.thiol_state'](wx_parent=self.parent)
69 else:
70 uf_store['bmrb.thiol_state'](wx_parent=self.parent, state=state)
71
72
74 """Launch the molecule.name user function.
75
76 @param event: The wx event.
77 @type event: wx event
78 """
79
80
81 item = self.element.GetFirstSelected()
82
83
84 id = gui_to_str(self.element.GetItemText(item))
85
86
87 uf_store['molecule.name'](wx_parent=self.parent, mol_id=id)
88
89
91 """Launch the molecule.type user function.
92
93 @param event: The wx event.
94 @type event: wx event
95 """
96
97
98 item = self.element.GetFirstSelected()
99
100
101 id = gui_to_str(self.element.GetItemText(item))
102
103
104 type = None
105 mol = return_molecule(id)
106 if hasattr(mol, 'type') and mol.type != None:
107 type = mol.type
108
109
110 if type == None:
111 uf_store['molecule.type'](wx_parent=self.parent, mol_id=id)
112 else:
113 uf_store['molecule.type'](wx_parent=self.parent, mol_id=id, type=type)
114
115
117 """Determine if the data input is complete.
118
119 @return: The answer to the question.
120 @rtype: bool
121 """
122
123
124 for mol in molecule_loop():
125
126 if mol.name == None:
127 return False
128
129
130 if not hasattr(mol, 'type') or mol.type == None:
131 return False
132
133
134 if not hasattr(cdp, 'exp_info') or not hasattr(cdp.exp_info, 'thiol_state'):
135 return False
136
137
138 return True
139
140
142 """Set the label of the StaticBox."""
143
144
145 label = self.title
146 if self.is_complete():
147 label += " (complete)"
148 else:
149 label += " (incomplete)"
150
151
152 self.data_box.SetLabel(label)
153
154
156 """Override the base variables."""
157
158
159 self.title = "Molecule information"
160 self.observer_base_name = "molecule"
161 self.button_placement = None
162
163
164 self.columns = [
165 "ID string",
166 "Name",
167 "Type",
168 "Thiol state"
169 ]
170
171
172 self.popup_menus = [
173 {
174 'id': MENU_MOLECULE_NAME,
175 'text': "&Name the molecule",
176 'icon': fetch_icon(uf_info.get_uf('molecule.name').gui_icon),
177 'method': self.action_molecule_name
178 }, {
179 'id': MENU_MOLECULE_TYPE,
180 'text': "Set the molecule &type",
181 'icon': fetch_icon(uf_info.get_uf('molecule.type').gui_icon),
182 'method': self.action_molecule_type
183 }, {
184 'id': MENU_BMRB_THIOL_STATE,
185 'text': "Set the thiol &state",
186 'icon': fetch_icon(uf_info.get_uf('bmrb.thiol_state').gui_icon),
187 'method': self.action_bmrb_thiol_state
188 }
189 ]
190
191
193 """Method called from self.build_element_safe() to update the list data."""
194
195
196 i = 0
197 for mol, mol_id in molecule_loop(return_id=True):
198
199 if dep_check.wx_classic:
200 self.element.InsertStringItem(i, str_to_gui(mol_id))
201 else:
202 self.element.InsertItem(i, str_to_gui(mol_id))
203
204
205 if mol.name != None:
206 if dep_check.wx_classic:
207 self.element.SetStringItem(i, 1, str_to_gui(mol.name))
208 else:
209 self.element.SetItem(i, 1, str_to_gui(mol.name))
210
211
212 if hasattr(mol, 'type'):
213 if dep_check.wx_classic:
214 self.element.SetStringItem(i, 2, str_to_gui(mol.type))
215 else:
216 self.element.SetItem(i, 2, str_to_gui(mol.type))
217
218
219 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'thiol_state'):
220 if dep_check.wx_classic:
221 self.element.SetStringItem(i, 3, str_to_gui(cdp.exp_info.thiol_state))
222 else:
223 self.element.SetItem(i, 3, str_to_gui(cdp.exp_info.thiol_state))
224
225
226 i += 1
227