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