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 base class for the results frame."""
25
26
27 import wx
28 from wx.lib import buttons
29
30
31 from data import Relax_data_store; ds = Relax_data_store()
32 from generic_fns.pipes import cdp_name, pipe_names
33 from status import Status; status = Status()
34
35
36 from gui.fonts import font
37 from gui.icons import relax_icons
38 from gui.interpreter import Interpreter; interpreter = Interpreter()
39 from gui.misc import add_border, open_file
40 from gui.paths import icon_22x22
41 from gui.string_conv import gui_to_str, str_to_gui
42 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
43
44
46 """The results viewer frame."""
47
48
49 border = 10
50 size = (800, 400)
51
53 """Build the results frame.
54
55 @param parent: The parent wx object.
56 @type parent: wx object
57 """
58
59
60 wx.Frame.__init__(self, parent=parent, style=wx.DEFAULT_FRAME_STYLE)
61
62
63 self.SetIcons(relax_icons)
64
65
66 self.SetTitle("Results viewer")
67 self.SetSize(self.size)
68
69
70 self.main_panel = wx.Panel(self, -1)
71
72
73 box_main = wx.BoxSizer(wx.HORIZONTAL)
74 self.main_panel.SetSizer(box_main)
75
76
77 box_centre = add_border(box_main, border=self.border, packing=wx.VERTICAL)
78
79
80 self.build_pipe_sel(box_centre)
81
82
83 box_centre.AddSpacer(self.border)
84
85
86 self.add_files(box_centre)
87
88
89 box_centre.AddSpacer(self.border)
90
91
92 self.button_open = buttons.ThemedGenBitmapTextButton(self.main_panel, -1, None, " Open")
93 self.button_open.SetBitmapLabel(wx.Bitmap(icon_22x22.document_open, wx.BITMAP_TYPE_ANY))
94 self.button_open.SetFont(font.normal)
95 self.button_open.SetMinSize((103, 33))
96 self.Bind(wx.EVT_BUTTON, self.open_result_file, self.button_open)
97 box_centre.Add(self.button_open, 0, wx.ALIGN_RIGHT|wx.ADJUST_MINSIZE, 5)
98
99
100 self.main_panel.Layout()
101 self.main_panel.Refresh()
102
103
104 self.Bind(wx.EVT_COMBOBOX, self.switch_pipes, self.pipe_name)
105 self.Bind(wx.EVT_CLOSE, self.handler_close)
106
107
108 self.name = 'results viewer'
109
110
111 - def Show(self, show=True):
133
134
136 """Activate or deactivate certain elements in response to the execution lock."""
137
138
139 enable = False
140 if not status.exec_lock.locked():
141 enable = True
142
143
144 wx.CallAfter(self.pipe_name.Enable, enable)
145
146
147 wx.CallAfter(self.button_open.Enable, enable)
148
149
151 """Create the list of results files.
152
153 @param box: The box sizer to pack the box into.
154 @type box: wx.BoxSizer instance
155 @return: The list box element.
156 @rtype: wx.ListBox element
157 """
158
159
160 self.file_list = wx.ListCtrl(self.main_panel, -1, style=wx.BORDER_SUNKEN|wx.LC_REPORT)
161
162
163 self.file_list.SetFont(font.normal)
164
165
166 self.height_char = self.file_list.GetCharHeight()
167
168
169 self.file_list.InsertColumn(0, "File type")
170 self.file_list.InsertColumn(1, "File path")
171
172
173 box.Add(self.file_list, 1, wx.ALL|wx.EXPAND, 0)
174
175
176 self.file_list.Bind(wx.EVT_SIZE, self.resize)
177 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.open_result_file, self.file_list)
178
179
181 """Create the data pipe selection element.
182
183 @param box: The horizontal box element to pack the elements into.
184 @type box: wx.BoxSizer instance
185 """
186
187
188 sizer = wx.BoxSizer(wx.HORIZONTAL)
189
190
191 label = wx.StaticText(self.main_panel, -1, "Data pipe selection")
192
193
194 label.SetFont(font.subtitle)
195
196
197 sizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
198
199
200 sizer.AddSpacer(self.border)
201
202
203 self.pipe_name = wx.ComboBox(self.main_panel, -1, value='', style=wx.CB_DROPDOWN|wx.CB_READONLY, choices=[])
204 self.pipe_name.SetMinSize((50, 27))
205 sizer.Add(self.pipe_name, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
206
207
208 box.Add(sizer, 0, wx.ALL|wx.EXPAND, 0)
209
210
226
227
229 """Open the results in the appropriate program.
230
231 @param event: The wx event.
232 @type event: wx event
233 """
234
235
236 for i in range(self.file_list.GetItemCount()):
237
238 if not self.file_list.IsSelected(i):
239 continue
240
241
242 type = self.file_data[i]
243 file = gui_to_str(self.file_list.GetItem(i, 1).GetText())
244
245
246 if type == 'grace':
247 uf_store['grace.view'](file=file, wx_parent=self)
248
249
250 elif type == 'pymol':
251 uf_store['pymol.macro_run'](file=file, wx_parent=self)
252
253
254 elif type == 'molmol':
255 uf_store['molmol.macro_run'](file=file, wx_parent=self)
256
257
258 elif type == 'diff_tensor_pdb':
259
260 if not interpreter.apply('pymol.view'):
261 return
262
263
264 interpreter.apply('pymol.cartoon')
265 interpreter.apply('pymol.tensor_pdb', file=file)
266
267
268 elif type == 'Table_of_Results':
269
270 model_result = [ds.relax_gui.table_residue, ds.relax_gui.table_model, ds.relax_gui.table_s2, ds.relax_gui.table_rex, ds.relax_gui.table_te]
271
272
273 elif type == 'text':
274 open_file(file, force_text=True)
275
276
277 else:
278 open_file(file)
279
280
282 """Update the list of result files."""
283
284
285 wx.CallAfter(self.refresh_safe)
286
287
313
314
316 """Catch the resize to allow the element to be resized.
317
318 @param event: The wx event.
319 @type event: wx event
320 """
321
322
323 self.size_cols()
324
325
326 event.Skip()
327
328
330 """Switch data pipes.
331
332 @param event: The wx event.
333 @type event: wx event
334 """
335
336
337 pipe = gui_to_str(self.pipe_name.GetString(event.GetSelection()))
338
339
340 if pipe == cdp_name():
341 return
342
343
344 interpreter.queue('pipe.switch', pipe)
345 interpreter.flush()
346
347
348 self.refresh()
349
350
351 wx.CallAfter(self.Raise)
352
353
366
367
369 """Set the column sizes."""
370
371
372 x, y = self.file_list.GetSize()
373
374
375 x = x - 10
376
377
378 self.file_list.SetColumnWidth(0, int(x/3))
379 self.file_list.SetColumnWidth(1, int(2*x/3))
380