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