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