1 | ################################################################################ |
---|
2 | # This software was developed by the University of Tennessee as part of the |
---|
3 | # Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
4 | # project funded by the US National Science Foundation. |
---|
5 | # |
---|
6 | # See the license text in license.txt |
---|
7 | # |
---|
8 | # copyright 2010, University of Tennessee |
---|
9 | ################################################################################ |
---|
10 | """ |
---|
11 | This module provides Graphic interface for the data_manager module. |
---|
12 | """ |
---|
13 | from __future__ import print_function |
---|
14 | |
---|
15 | import wx |
---|
16 | from wx.build import build_options |
---|
17 | |
---|
18 | import sys |
---|
19 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
20 | import wx.lib.agw.customtreectrl as CT |
---|
21 | from sas.sasgui.guiframe.dataFitting import Data1D |
---|
22 | from sas.sasgui.guiframe.dataFitting import Data2D |
---|
23 | from sas.sasgui.guiframe.panel_base import PanelBase |
---|
24 | from sas.sasgui.guiframe.events import StatusEvent |
---|
25 | from sas.sasgui.guiframe.events import EVT_DELETE_PLOTPANEL |
---|
26 | from sas.sasgui.guiframe.events import NewLoadDataEvent |
---|
27 | from sas.sasgui.guiframe.events import NewPlotEvent |
---|
28 | from sas.sasgui.guiframe.gui_style import GUIFRAME |
---|
29 | from sas.sasgui.guiframe.events import NewBatchEvent |
---|
30 | from sas.sascalc.dataloader.loader import Loader |
---|
31 | # from sas.sasgui.guiframe.local_perspectives.plotting.masking \ |
---|
32 | # import FloatPanel as QucikPlotDialog |
---|
33 | from sas.sasgui.guiframe.local_perspectives.plotting.SimplePlot \ |
---|
34 | import PlotFrame as QucikPlotDialog |
---|
35 | import sas.sasgui.guiframe.config as config |
---|
36 | |
---|
37 | # Check version |
---|
38 | toks = str(wx.__version__).split('.') |
---|
39 | if int(toks[1]) < 9: |
---|
40 | if int(toks[2]) < 12: |
---|
41 | wx_version = 811 |
---|
42 | else: |
---|
43 | wx_version = 812 |
---|
44 | else: |
---|
45 | wx_version = 900 |
---|
46 | |
---|
47 | extension_list = [] |
---|
48 | if config.APPLICATION_STATE_EXTENSION is not None: |
---|
49 | extension_list.append(config.APPLICATION_STATE_EXTENSION) |
---|
50 | EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS + extension_list |
---|
51 | PLUGINS_WLIST = config.PLUGINS_WLIST |
---|
52 | APPLICATION_WLIST = config.APPLICATION_WLIST |
---|
53 | |
---|
54 | # Control panel width |
---|
55 | if sys.platform.count("win32") > 0: |
---|
56 | PANEL_WIDTH = 235 |
---|
57 | PANEL_HEIGHT = 700 |
---|
58 | CBOX_WIDTH = 140 |
---|
59 | BUTTON_WIDTH = 80 |
---|
60 | FONT_VARIANT = 0 |
---|
61 | IS_MAC = False |
---|
62 | else: |
---|
63 | PANEL_WIDTH = 255 |
---|
64 | PANEL_HEIGHT = 750 |
---|
65 | CBOX_WIDTH = 155 |
---|
66 | BUTTON_WIDTH = 100 |
---|
67 | FONT_VARIANT = 1 |
---|
68 | IS_MAC = True |
---|
69 | |
---|
70 | STYLE_FLAG = (wx.RAISED_BORDER | CT.TR_HAS_BUTTONS | |
---|
71 | wx.WANTS_CHARS | CT.TR_HAS_VARIABLE_ROW_HEIGHT) |
---|
72 | |
---|
73 | |
---|
74 | class DataTreeCtrl(CT.CustomTreeCtrl): |
---|
75 | """ |
---|
76 | Check list control to be used for Data Panel |
---|
77 | """ |
---|
78 | def __init__(self, parent, root, *args, **kwds): |
---|
79 | # agwstyle is introduced in wx.2.8.11 but is not working for mac |
---|
80 | if IS_MAC and wx_version < 812: |
---|
81 | try: |
---|
82 | kwds['style'] = STYLE_FLAG |
---|
83 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
84 | except: |
---|
85 | del kwds['style'] |
---|
86 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
87 | else: |
---|
88 | # agwstyle is introduced in wx.2.8.11 |
---|
89 | # argument working only for windows |
---|
90 | try: |
---|
91 | kwds['agwStyle'] = STYLE_FLAG |
---|
92 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
93 | except: |
---|
94 | try: |
---|
95 | del kwds['agwStyle'] |
---|
96 | kwds['style'] = STYLE_FLAG |
---|
97 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
98 | except: |
---|
99 | del kwds['style'] |
---|
100 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
101 | self.root = self.AddRoot(root) |
---|
102 | |
---|
103 | def OnCompareItems(self, item1, item2): |
---|
104 | """ |
---|
105 | Overrides OnCompareItems in wx.TreeCtrl. |
---|
106 | Used by the SortChildren method. |
---|
107 | """ |
---|
108 | # Get the item data |
---|
109 | data_1 = self.GetItemText(item1) |
---|
110 | data_2 = self.GetItemText(item2) |
---|
111 | # Compare the item data |
---|
112 | if data_1 < data_2: |
---|
113 | return -1 |
---|
114 | elif data_1 > data_2: |
---|
115 | return 1 |
---|
116 | else: |
---|
117 | return 0 |
---|
118 | |
---|
119 | |
---|
120 | class DataPanel(ScrolledPanel, PanelBase): |
---|
121 | """ |
---|
122 | This panel displays data available in the application and widgets to |
---|
123 | interact with data. |
---|
124 | """ |
---|
125 | # Internal name for the AUI manager |
---|
126 | window_name = "Data Panel" |
---|
127 | # Title to appear on top of the window |
---|
128 | window_caption = "Data Explorer" |
---|
129 | # type of window |
---|
130 | window_type = "Data Panel" |
---|
131 | # Flag to tell the GUI manager that this panel is not |
---|
132 | # tied to any perspective |
---|
133 | # ALWAYS_ON = True |
---|
134 | |
---|
135 | def __init__(self, parent, |
---|
136 | list=None, |
---|
137 | size=(PANEL_WIDTH, PANEL_HEIGHT), |
---|
138 | id=-1, |
---|
139 | list_of_perspective=None, manager=None, *args, **kwds): |
---|
140 | # kwds['size'] = size |
---|
141 | # kwds['style'] = STYLE_FLAG |
---|
142 | ScrolledPanel.__init__(self, parent=parent, id=id, *args, **kwds) |
---|
143 | PanelBase.__init__(self, parent) |
---|
144 | self.SetupScrolling() |
---|
145 | # Set window's font size |
---|
146 | self.SetWindowVariant(variant=FONT_VARIANT) |
---|
147 | self.loader = Loader() |
---|
148 | # Default location |
---|
149 | self._default_save_location = None |
---|
150 | self.all_data1d = True |
---|
151 | self.parent = parent.parent |
---|
152 | self._manager = manager |
---|
153 | self.frame = parent |
---|
154 | if list is None: |
---|
155 | list = [] |
---|
156 | self.list_of_data = list |
---|
157 | if list_of_perspective is None: |
---|
158 | list_of_perspective = [] |
---|
159 | self.list_of_perspective = list_of_perspective |
---|
160 | self.list_rb_perspectives = [] |
---|
161 | self.list_cb_data = {} |
---|
162 | self.list_cb_theory = {} |
---|
163 | self.tree_ctrl = None |
---|
164 | self.tree_ctrl_theory = None |
---|
165 | self.perspective_cbox = None |
---|
166 | # Create context menu for page |
---|
167 | self.data_menu = None |
---|
168 | self.popUpMenu = None |
---|
169 | self.plot3d_id = None |
---|
170 | self.editmask_id = None |
---|
171 | # Default attr |
---|
172 | self.vbox = None |
---|
173 | self.sizer1 = None |
---|
174 | self.sizer2 = None |
---|
175 | self.sizer3 = None |
---|
176 | self.sizer4 = None |
---|
177 | self.sizer5 = None |
---|
178 | self.selection_cbox = None |
---|
179 | self.bt_add = None |
---|
180 | self.bt_remove = None |
---|
181 | self.bt_import = None |
---|
182 | self.bt_append_plot = None |
---|
183 | self.bt_plot = None |
---|
184 | self.bt_freeze = None |
---|
185 | self.cb_plotpanel = None |
---|
186 | self.rb_single_mode = None |
---|
187 | self.rb_batch_mode = None |
---|
188 | |
---|
189 | self.owner = None |
---|
190 | self.do_layout() |
---|
191 | self.fill_cbox_analysis(self.list_of_perspective) |
---|
192 | self.Bind(wx.EVT_SHOW, self.on_close_page) |
---|
193 | if self.parent is not None: |
---|
194 | self.parent.Bind(EVT_DELETE_PLOTPANEL, self._on_delete_plot_panel) |
---|
195 | |
---|
196 | def do_layout(self): |
---|
197 | """ |
---|
198 | Create the panel layout |
---|
199 | """ |
---|
200 | self.define_panel_structure() |
---|
201 | self.layout_selection() |
---|
202 | self.layout_data_list() |
---|
203 | self.layout_batch() |
---|
204 | self.layout_button() |
---|
205 | |
---|
206 | def disable_app_combo(self, enable): |
---|
207 | """ |
---|
208 | Disable app combo box |
---|
209 | """ |
---|
210 | self.perspective_cbox.Enable(enable) |
---|
211 | |
---|
212 | def define_panel_structure(self): |
---|
213 | """ |
---|
214 | Define the skeleton of the panel |
---|
215 | """ |
---|
216 | w, h = self.parent.GetSize() |
---|
217 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
218 | self.sizer1 = wx.BoxSizer(wx.VERTICAL) |
---|
219 | self.sizer1.SetMinSize(wx.Size(w/13, h*2/5)) |
---|
220 | |
---|
221 | self.sizer2 = wx.BoxSizer(wx.VERTICAL) |
---|
222 | self.sizer3 = wx.FlexGridSizer(9, 2, 4, 1) |
---|
223 | self.sizer4 = wx.BoxSizer(wx.VERTICAL) |
---|
224 | self.sizer5 = wx.BoxSizer(wx.VERTICAL) |
---|
225 | |
---|
226 | self.vbox.Add(self.sizer5, 0, wx.EXPAND | wx.ALL, 1) |
---|
227 | self.vbox.Add(self.sizer1, 1, wx.EXPAND | wx.ALL, 0) |
---|
228 | self.vbox.Add(self.sizer2, 0, wx.EXPAND | wx.ALL, 1) |
---|
229 | self.vbox.Add(self.sizer3, 0, wx.EXPAND | wx.ALL, 10) |
---|
230 | # self.vbox.Add(self.sizer4, 0, wx.EXPAND|wx.ALL,5) |
---|
231 | |
---|
232 | self.SetSizer(self.vbox) |
---|
233 | |
---|
234 | def layout_selection(self): |
---|
235 | """ |
---|
236 | Create selection option combo box |
---|
237 | """ |
---|
238 | select_txt = wx.StaticText(self, -1, 'Selection Options') |
---|
239 | select_txt.SetForegroundColour('blue') |
---|
240 | self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
241 | list_of_options = ['Select all Data', |
---|
242 | 'Unselect all Data', |
---|
243 | 'Select all Data 1D', |
---|
244 | 'Unselect all Data 1D', |
---|
245 | 'Select all Data 2D', |
---|
246 | 'Unselect all Data 2D'] |
---|
247 | for option in list_of_options: |
---|
248 | self.selection_cbox.Append(str(option)) |
---|
249 | self.selection_cbox.SetValue('Select all Data') |
---|
250 | wx.EVT_COMBOBOX(self.selection_cbox, -1, self._on_selection_type) |
---|
251 | self.sizer5.AddMany([(select_txt, 0, wx.ALL, 5), |
---|
252 | (self.selection_cbox, 0, wx.ALL, 5)]) |
---|
253 | self.enable_selection() |
---|
254 | |
---|
255 | def _on_selection_type(self, event): |
---|
256 | """ |
---|
257 | Select data according to patterns |
---|
258 | :param event: UI event |
---|
259 | """ |
---|
260 | def check_item_and_children(control, check_value=True): |
---|
261 | self.tree_ctrl.CheckItem(data_ctrl, check_value) |
---|
262 | if data_ctrl.HasChildren(): |
---|
263 | if check_value and not control.IsExpanded(): |
---|
264 | # Only select children if control is expanded |
---|
265 | # Always deselect children, regardless (see ticket #259) |
---|
266 | return |
---|
267 | for child_ctrl in data_ctrl.GetChildren(): |
---|
268 | self.tree_ctrl.CheckItem(child_ctrl, check_value) |
---|
269 | |
---|
270 | option = self.selection_cbox.GetValue() |
---|
271 | |
---|
272 | pos = self.selection_cbox.GetSelection() |
---|
273 | if pos == wx.NOT_FOUND: |
---|
274 | return |
---|
275 | option = self.selection_cbox.GetString(pos) |
---|
276 | for item in self.list_cb_data.values(): |
---|
277 | data_ctrl, _, _, _, _, _, _, _ = item |
---|
278 | _, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl) |
---|
279 | if option == 'Select all Data': |
---|
280 | check_item_and_children(data_ctrl, check_value=True) |
---|
281 | elif option == 'Unselect all Data': |
---|
282 | check_item_and_children(data_ctrl, check_value=False) |
---|
283 | elif option == 'Select all Data 1D': |
---|
284 | if data_class == 'Data1D': |
---|
285 | check_item_and_children(data_ctrl, check_value=True) |
---|
286 | elif option == 'Unselect all Data 1D': |
---|
287 | if data_class == 'Data1D': |
---|
288 | check_item_and_children(data_ctrl, check_value=False) |
---|
289 | elif option == 'Select all Data 2D': |
---|
290 | if data_class == 'Data2D': |
---|
291 | check_item_and_children(data_ctrl, check_value=True) |
---|
292 | elif option == 'Unselect all Data 2D': |
---|
293 | if data_class == 'Data2D': |
---|
294 | check_item_and_children(data_ctrl, check_value=False) |
---|
295 | self.enable_append() |
---|
296 | self.enable_freeze() |
---|
297 | self.enable_plot() |
---|
298 | self.enable_import() |
---|
299 | self.enable_remove() |
---|
300 | |
---|
301 | def layout_button(self): |
---|
302 | """ |
---|
303 | Layout widgets related to buttons |
---|
304 | """ |
---|
305 | # Load Data Button |
---|
306 | self.bt_add = wx.Button(self, wx.NewId(), "Load Data", |
---|
307 | size=(BUTTON_WIDTH, -1)) |
---|
308 | self.bt_add.SetToolTipString("Load data files") |
---|
309 | wx.EVT_BUTTON(self, self.bt_add.GetId(), self._load_data) |
---|
310 | |
---|
311 | # Delete Data Button |
---|
312 | self.bt_remove = wx.Button(self, wx.NewId(), "Delete Data", |
---|
313 | size=(BUTTON_WIDTH, -1)) |
---|
314 | self.bt_remove.SetToolTipString("Delete data from the application") |
---|
315 | wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) |
---|
316 | |
---|
317 | # Send data to perspective button |
---|
318 | self.bt_import = wx.Button(self, wx.NewId(), "Send To", |
---|
319 | size=(BUTTON_WIDTH, -1)) |
---|
320 | self.bt_import.SetToolTipString("Send Data set to active perspective") |
---|
321 | wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) |
---|
322 | |
---|
323 | # Choose perspective to be send data to combo box |
---|
324 | self.perspective_cbox = wx.ComboBox(self, -1, |
---|
325 | style=wx.CB_READONLY) |
---|
326 | if not IS_MAC: |
---|
327 | self.perspective_cbox.SetMinSize((BUTTON_WIDTH*1.6, -1)) |
---|
328 | wx.EVT_COMBOBOX(self.perspective_cbox, -1, |
---|
329 | self._on_perspective_selection) |
---|
330 | |
---|
331 | # Append data to current Graph Button |
---|
332 | self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To", |
---|
333 | size=(BUTTON_WIDTH, -1)) |
---|
334 | self.bt_append_plot.SetToolTipString( |
---|
335 | "Plot the selected data in the active panel") |
---|
336 | wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) |
---|
337 | |
---|
338 | # Create a new graph and send data to that new graph button |
---|
339 | self.bt_plot = wx.Button(self, wx.NewId(), "New Plot", |
---|
340 | size=(BUTTON_WIDTH, -1)) |
---|
341 | self.bt_plot.SetToolTipString("To trigger plotting") |
---|
342 | wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) |
---|
343 | |
---|
344 | # Freeze current theory button - becomes a data set and stays on graph |
---|
345 | self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze Theory", |
---|
346 | size=(BUTTON_WIDTH, -1)) |
---|
347 | freeze_tip = "To trigger freeze a theory: making a copy\n" |
---|
348 | freeze_tip += "of the theory checked to Data box,\n" |
---|
349 | freeze_tip += " so that it can act like a real data set." |
---|
350 | self.bt_freeze.SetToolTipString(freeze_tip) |
---|
351 | wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) |
---|
352 | |
---|
353 | # select plot to send to combo box (blank if no data) |
---|
354 | if sys.platform == 'darwin': |
---|
355 | self.cb_plotpanel = wx.ComboBox(self, -1, |
---|
356 | style=wx.CB_READONLY) |
---|
357 | else: |
---|
358 | self.cb_plotpanel = wx.ComboBox(self, -1, |
---|
359 | style=wx.CB_READONLY | wx.CB_SORT) |
---|
360 | wx.EVT_COMBOBOX(self.cb_plotpanel, -1, self._on_plot_selection) |
---|
361 | self.cb_plotpanel.Disable() |
---|
362 | |
---|
363 | # Help button |
---|
364 | self.bt_help = wx.Button(self, wx.NewId(), "HELP", |
---|
365 | size=(BUTTON_WIDTH, -1)) |
---|
366 | self.bt_help.SetToolTipString("Help for the Data Explorer.") |
---|
367 | wx.EVT_BUTTON(self, self.bt_help.GetId(), self.on_help) |
---|
368 | |
---|
369 | self.sizer3.AddMany([(self.bt_add), |
---|
370 | ((10, 10)), |
---|
371 | (self.bt_remove), |
---|
372 | ((10, 10)), |
---|
373 | (self.bt_freeze), |
---|
374 | ((10, 10)), |
---|
375 | (self.bt_plot), |
---|
376 | ((10, 10)), |
---|
377 | (self.bt_append_plot), |
---|
378 | (self.cb_plotpanel, |
---|
379 | wx.EXPAND | wx.ADJUST_MINSIZE, 5), |
---|
380 | ((5, 5)), |
---|
381 | ((5, 5)), |
---|
382 | (self.bt_import, 0, wx.EXPAND | wx.RIGHT, 5), |
---|
383 | (self.perspective_cbox, |
---|
384 | wx.EXPAND | wx.ADJUST_MINSIZE, 5), |
---|
385 | ((10, 10)), |
---|
386 | (self.sizer4), |
---|
387 | ((10, 10)), |
---|
388 | (self.bt_help, 0, wx.RIGHT, 5)]) |
---|
389 | |
---|
390 | self.sizer3.AddGrowableCol(1, 1) |
---|
391 | self.show_data_button() |
---|
392 | self.enable_remove() |
---|
393 | self.enable_import() |
---|
394 | self.enable_plot() |
---|
395 | self.enable_append() |
---|
396 | self.enable_freeze() |
---|
397 | self.enable_remove_plot() |
---|
398 | |
---|
399 | def layout_batch(self): |
---|
400 | """ |
---|
401 | Set up batch mode options |
---|
402 | """ |
---|
403 | self.rb_single_mode = wx.RadioButton(self, -1, 'Single Mode', |
---|
404 | style=wx.RB_GROUP) |
---|
405 | self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode') |
---|
406 | self.Bind(wx.EVT_RADIOBUTTON, self.on_single_mode, |
---|
407 | id=self.rb_single_mode.GetId()) |
---|
408 | self.Bind(wx.EVT_RADIOBUTTON, self.on_batch_mode, |
---|
409 | id=self.rb_batch_mode.GetId()) |
---|
410 | |
---|
411 | self.rb_single_mode.SetValue(not self.parent.batch_on) |
---|
412 | self.rb_batch_mode.SetValue(self.parent.batch_on) |
---|
413 | self.sizer4.AddMany([(self.rb_single_mode, 0, wx.ALL, 4), |
---|
414 | (self.rb_batch_mode, 0, wx.ALL, 4)]) |
---|
415 | |
---|
416 | def on_single_mode(self, event): |
---|
417 | """ |
---|
418 | Change to single mode |
---|
419 | :param event: UI event |
---|
420 | """ |
---|
421 | if self.parent is not None: |
---|
422 | wx.PostEvent(self.parent, NewBatchEvent(enable=False)) |
---|
423 | |
---|
424 | def on_batch_mode(self, event): |
---|
425 | """ |
---|
426 | Change to batch mode |
---|
427 | :param event: UI event |
---|
428 | """ |
---|
429 | if self.parent is not None: |
---|
430 | wx.PostEvent(self.parent, |
---|
431 | NewBatchEvent(enable=True)) |
---|
432 | |
---|
433 | def _get_data_selection(self, event): |
---|
434 | """ |
---|
435 | Get data selection from the right click |
---|
436 | :param event: UI event |
---|
437 | """ |
---|
438 | data = None |
---|
439 | # selection = event.GetSelection() |
---|
440 | id, _, _ = self.FindFocus().GetSelection().GetData() |
---|
441 | data_list, theory_list = \ |
---|
442 | self.parent.get_data_manager().get_by_id(id_list=[id]) |
---|
443 | if data_list: |
---|
444 | data = data_list.values()[0] |
---|
445 | if data is None: |
---|
446 | data = theory_list.values()[0][0] |
---|
447 | return data |
---|
448 | |
---|
449 | def on_edit_data(self, event): |
---|
450 | """ |
---|
451 | Pop Up Data Editor |
---|
452 | """ |
---|
453 | data = self._get_data_selection(event) |
---|
454 | from sas.sasgui.guiframe.local_perspectives.plotting.masking \ |
---|
455 | import MaskPanel as MaskDialog |
---|
456 | |
---|
457 | panel = MaskDialog(parent=self.parent, base=self, |
---|
458 | data=data, id=wx.NewId()) |
---|
459 | panel.ShowModal() |
---|
460 | |
---|
461 | def on_plot_3d(self, event): |
---|
462 | """ |
---|
463 | Frozen image of 3D |
---|
464 | """ |
---|
465 | data = self._get_data_selection(event) |
---|
466 | from sas.sasgui.guiframe.local_perspectives.plotting.masking \ |
---|
467 | import FloatPanel as Float3dDialog |
---|
468 | |
---|
469 | panel = Float3dDialog(base=self, data=data, |
---|
470 | dimension=3, id=wx.NewId()) |
---|
471 | panel.ShowModal() |
---|
472 | |
---|
473 | def on_quick_plot(self, event): |
---|
474 | """ |
---|
475 | Frozen plot |
---|
476 | """ |
---|
477 | data = self._get_data_selection(event) |
---|
478 | if data.__class__.__name__ == "Data2D": |
---|
479 | dimension = 2 |
---|
480 | else: |
---|
481 | dimension = 1 |
---|
482 | # panel = QucikPlotDialog(base=self, data=data, |
---|
483 | # dimension=dimension, id=wx.NewId()) |
---|
484 | frame = QucikPlotDialog(self, -1, "Plot " + data.name, 'log_{10}') |
---|
485 | self.parent.put_icon(frame) |
---|
486 | frame.add_plot(data) |
---|
487 | # frame.SetTitle(title) |
---|
488 | frame.Show(True) |
---|
489 | frame.SetFocus() |
---|
490 | # panel.ShowModal() |
---|
491 | |
---|
492 | def on_data_info(self, event): |
---|
493 | """ |
---|
494 | Data Info panel |
---|
495 | """ |
---|
496 | data = self._get_data_selection(event) |
---|
497 | if data.__class__.__name__ == "Data2D": |
---|
498 | self.parent.show_data2d(data, data.name) |
---|
499 | else: |
---|
500 | self.parent.show_data1d(data, data.name) |
---|
501 | |
---|
502 | def on_save_as(self, event): |
---|
503 | """ |
---|
504 | Save data as a file |
---|
505 | """ |
---|
506 | data = self._get_data_selection(event) |
---|
507 | # path = None |
---|
508 | default_name = data.name |
---|
509 | if default_name.count('.') > 0: |
---|
510 | default_name = default_name.split('.')[0] |
---|
511 | default_name += "_out" |
---|
512 | if self.parent is not None: |
---|
513 | if issubclass(data.__class__, Data1D): |
---|
514 | self.parent.save_data1d(data, default_name) |
---|
515 | elif issubclass(data.__class__, Data2D): |
---|
516 | self.parent.save_data2d(data, default_name) |
---|
517 | else: |
---|
518 | print("unable to save this type of data") |
---|
519 | |
---|
520 | def layout_data_list(self): |
---|
521 | """ |
---|
522 | Add a listcrtl in the panel |
---|
523 | """ |
---|
524 | # Add splitter |
---|
525 | w, h = self.parent.GetSize() |
---|
526 | splitter = wx.SplitterWindow(self) |
---|
527 | splitter.SetMinimumPaneSize(50) |
---|
528 | splitter.SetSashGravity(1.0) |
---|
529 | |
---|
530 | file_sizer = wx.BoxSizer(wx.VERTICAL) |
---|
531 | file_sizer.SetMinSize(wx.Size(w/13, h*2/5)) |
---|
532 | theory_sizer = wx.BoxSizer(wx.VERTICAL) |
---|
533 | theory_sizer.SetMinSize(wx.Size(w/13, h*2/5)) |
---|
534 | |
---|
535 | self.tree_ctrl = DataTreeCtrl(parent=splitter, |
---|
536 | style=wx.SUNKEN_BORDER, |
---|
537 | root="Available Data") |
---|
538 | |
---|
539 | self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) |
---|
540 | self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_MENU, self.on_right_click_data) |
---|
541 | # Create context menu for page |
---|
542 | self.data_menu = wx.Menu() |
---|
543 | id = wx.NewId() |
---|
544 | name = "Data Info" |
---|
545 | msg = "Show Data Info" |
---|
546 | self.data_menu.Append(id, name, msg) |
---|
547 | wx.EVT_MENU(self, id, self.on_data_info) |
---|
548 | |
---|
549 | id = wx.NewId() |
---|
550 | name = "Save As" |
---|
551 | msg = "Save Theory/Data as a file" |
---|
552 | self.data_menu.Append(id, name, msg) |
---|
553 | wx.EVT_MENU(self, id, self.on_save_as) |
---|
554 | |
---|
555 | quickplot_id = wx.NewId() |
---|
556 | name = "Quick Plot" |
---|
557 | msg = "Plot the current Data" |
---|
558 | self.data_menu.Append(quickplot_id, name, msg) |
---|
559 | wx.EVT_MENU(self, quickplot_id, self.on_quick_plot) |
---|
560 | |
---|
561 | self.plot3d_id = wx.NewId() |
---|
562 | name = "Quick 3DPlot (Slow)" |
---|
563 | msg = "Plot3D the current 2D Data" |
---|
564 | self.data_menu.Append(self.plot3d_id, name, msg) |
---|
565 | wx.EVT_MENU(self, self.plot3d_id, self.on_plot_3d) |
---|
566 | |
---|
567 | self.editmask_id = wx.NewId() |
---|
568 | name = "Edit Mask" |
---|
569 | msg = "Edit Mask for the current 2D Data" |
---|
570 | self.data_menu.Append(self.editmask_id, name, msg) |
---|
571 | wx.EVT_MENU(self, self.editmask_id, self.on_edit_data) |
---|
572 | |
---|
573 | self.tree_ctrl_theory = DataTreeCtrl(parent=splitter, |
---|
574 | style=wx.SUNKEN_BORDER, |
---|
575 | root="Available Theory") |
---|
576 | self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING, |
---|
577 | self.on_check_item) |
---|
578 | self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_MENU, |
---|
579 | self.on_right_click_theory) |
---|
580 | splitter.SplitHorizontally(self.tree_ctrl, self.tree_ctrl_theory) |
---|
581 | self.sizer1.Add(splitter, 1, wx.EXPAND | wx.ALL, 10) |
---|
582 | |
---|
583 | def on_right_click_theory(self, event): |
---|
584 | """ |
---|
585 | On click theory data |
---|
586 | """ |
---|
587 | try: |
---|
588 | id, data_class_name, _ = \ |
---|
589 | self.tree_ctrl_theory.GetSelection().GetData() |
---|
590 | _, _ = self.parent.get_data_manager().get_by_id(id_list=[id]) |
---|
591 | except: |
---|
592 | return |
---|
593 | if self.data_menu is not None: |
---|
594 | menu_enable = (data_class_name == "Data2D") |
---|
595 | self.data_menu.Enable(self.editmask_id, False) |
---|
596 | self.data_menu.Enable(self.plot3d_id, menu_enable) |
---|
597 | self.PopupMenu(self.data_menu) |
---|
598 | |
---|
599 | def on_right_click_data(self, event): |
---|
600 | """ |
---|
601 | Allow Editing Data |
---|
602 | """ |
---|
603 | # selection = event.GetSelection() |
---|
604 | is_data = True |
---|
605 | try: |
---|
606 | id, data_class_name, _ = self.tree_ctrl.GetSelection().GetData() |
---|
607 | data_list, _ = \ |
---|
608 | self.parent.get_data_manager().get_by_id(id_list=[id]) |
---|
609 | if not data_list: |
---|
610 | is_data = False |
---|
611 | except: |
---|
612 | return |
---|
613 | if self.data_menu is not None: |
---|
614 | menu_enable = (data_class_name == "Data2D") |
---|
615 | maskmenu_enable = (menu_enable and is_data) |
---|
616 | self.data_menu.Enable(self.editmask_id, maskmenu_enable) |
---|
617 | self.data_menu.Enable(self.plot3d_id, menu_enable) |
---|
618 | self.PopupMenu(self.data_menu) |
---|
619 | |
---|
620 | def onContextMenu(self, event): |
---|
621 | """ |
---|
622 | Retrieve the state selected state |
---|
623 | """ |
---|
624 | # Skipping the save state functionality for release 0.9.0 |
---|
625 | # return |
---|
626 | pos = event.GetPosition() |
---|
627 | pos = self.ScreenToClient(pos) |
---|
628 | self.PopupMenu(self.popUpMenu, pos) |
---|
629 | |
---|
630 | def on_check_item(self, event): |
---|
631 | """ |
---|
632 | On check item |
---|
633 | """ |
---|
634 | item = event.GetItem() |
---|
635 | item.Check(not item.IsChecked()) |
---|
636 | self.enable_append() |
---|
637 | self.enable_freeze() |
---|
638 | self.enable_plot() |
---|
639 | self.enable_import() |
---|
640 | self.enable_remove() |
---|
641 | event.Skip() |
---|
642 | |
---|
643 | def fill_cbox_analysis(self, plugin): |
---|
644 | """ |
---|
645 | fill the combobox with analysis name |
---|
646 | """ |
---|
647 | self.list_of_perspective = plugin |
---|
648 | if self.parent is None or \ |
---|
649 | not hasattr(self.parent, "get_current_perspective") or \ |
---|
650 | len(self.list_of_perspective) == 0: |
---|
651 | return |
---|
652 | if self.parent is not None and self.perspective_cbox is not None: |
---|
653 | for plug in self.list_of_perspective: |
---|
654 | if plug.get_perspective(): |
---|
655 | self.perspective_cbox.Append(plug.sub_menu, plug) |
---|
656 | |
---|
657 | curr_pers = self.parent.get_current_perspective() |
---|
658 | if curr_pers: |
---|
659 | self.perspective_cbox.SetStringSelection(curr_pers.sub_menu) |
---|
660 | self.enable_import() |
---|
661 | |
---|
662 | def load_data_list(self, list): |
---|
663 | """ |
---|
664 | add need data with its theory under the tree |
---|
665 | """ |
---|
666 | if list: |
---|
667 | for state_id, dstate in list.iteritems(): |
---|
668 | data = dstate.get_data() |
---|
669 | theory_list = dstate.get_theory() |
---|
670 | if data is not None: |
---|
671 | data_name = str(data.name) |
---|
672 | data_title = str(data.title) |
---|
673 | data_run = str(data.run) |
---|
674 | data_class = data.__class__.__name__ |
---|
675 | path = dstate.get_path() |
---|
676 | process_list = data.process |
---|
677 | data_id = data.id |
---|
678 | s_path = str(path) |
---|
679 | if state_id not in self.list_cb_data: |
---|
680 | # new state |
---|
681 | data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root, |
---|
682 | 0, data_name, |
---|
683 | ct_type=1, |
---|
684 | data=(data_id, data_class, state_id)) |
---|
685 | data_c.Check(True) |
---|
686 | d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') |
---|
687 | d_t_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
688 | 'Title: %s' % |
---|
689 | data_title) |
---|
690 | r_n_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
691 | 'Run: %s' % data_run) |
---|
692 | i_c_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
693 | 'Type: %s' % |
---|
694 | data_class) |
---|
695 | p_c_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
696 | "Path: '%s'" % s_path) |
---|
697 | d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') |
---|
698 | |
---|
699 | for process in process_list: |
---|
700 | process_str = str(process).replace('\n', ' ') |
---|
701 | if len(process_str) > 20: |
---|
702 | process_str = process_str[:20] + ' [...]' |
---|
703 | self.tree_ctrl.AppendItem(d_p_c, process_str) |
---|
704 | theory_child = self.tree_ctrl.AppendItem(data_c, |
---|
705 | "THEORIES") |
---|
706 | self.list_cb_data[state_id] = [data_c, |
---|
707 | d_i_c, |
---|
708 | d_t_c, |
---|
709 | r_n_c, |
---|
710 | i_c_c, |
---|
711 | p_c_c, |
---|
712 | d_p_c, |
---|
713 | theory_child] |
---|
714 | else: |
---|
715 | data_ctrl_list = self.list_cb_data[state_id] |
---|
716 | # This state is already display replace it contains |
---|
717 | data_c, d_i_c, d_t_c, r_n_c, i_c_c, p_c_c, d_p_c, _ \ |
---|
718 | = data_ctrl_list |
---|
719 | self.tree_ctrl.SetItemText(data_c, data_name) |
---|
720 | temp = (data_id, data_class, state_id) |
---|
721 | self.tree_ctrl.SetItemPyData(data_c, temp) |
---|
722 | self.tree_ctrl.SetItemText(i_c_c, |
---|
723 | 'Type: %s' % data_class) |
---|
724 | self.tree_ctrl.SetItemText(p_c_c, |
---|
725 | 'Path: %s' % s_path) |
---|
726 | self.tree_ctrl.DeleteChildren(d_p_c) |
---|
727 | for process in process_list: |
---|
728 | if not process.is_empty(): |
---|
729 | _ = self.tree_ctrl.AppendItem(d_p_c, |
---|
730 | process.single_line_desc()) |
---|
731 | wx.CallAfter(self.append_theory, state_id, theory_list) |
---|
732 | # Sort by data name |
---|
733 | if self.tree_ctrl.root: |
---|
734 | self.tree_ctrl.SortChildren(self.tree_ctrl.root) |
---|
735 | # Expand root if # of data sets > 0 |
---|
736 | if self.tree_ctrl.GetCount() > 0: |
---|
737 | self.tree_ctrl.root.Expand() |
---|
738 | self.enable_remove() |
---|
739 | self.enable_import() |
---|
740 | self.enable_plot() |
---|
741 | self.enable_freeze() |
---|
742 | self.enable_selection() |
---|
743 | |
---|
744 | def _uncheck_all(self): |
---|
745 | """ |
---|
746 | Uncheck all check boxes |
---|
747 | """ |
---|
748 | for item in self.list_cb_data.values(): |
---|
749 | data_ctrl, _, _, _, _, _, _, _ = item |
---|
750 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
751 | self.enable_append() |
---|
752 | self.enable_freeze() |
---|
753 | self.enable_plot() |
---|
754 | self.enable_import() |
---|
755 | self.enable_remove() |
---|
756 | |
---|
757 | def append_theory(self, state_id, theory_list): |
---|
758 | """ |
---|
759 | append theory object under data from a state of id = state_id |
---|
760 | replace that theory if already displayed |
---|
761 | """ |
---|
762 | if not theory_list: |
---|
763 | return |
---|
764 | if state_id not in self.list_cb_data.keys(): |
---|
765 | root = self.tree_ctrl_theory.root |
---|
766 | tree = self.tree_ctrl_theory |
---|
767 | else: |
---|
768 | item = self.list_cb_data[state_id] |
---|
769 | data_c, _, _, _, _, _, _, _ = item |
---|
770 | root = data_c |
---|
771 | tree = self.tree_ctrl |
---|
772 | if root is not None: |
---|
773 | wx.CallAfter(self.append_theory_helper, tree=tree, root=root, |
---|
774 | state_id=state_id, |
---|
775 | theory_list=theory_list) |
---|
776 | if self.tree_ctrl_theory.GetCount() > 0: |
---|
777 | self.tree_ctrl_theory.root.Expand() |
---|
778 | |
---|
779 | def append_theory_helper(self, tree, root, state_id, theory_list): |
---|
780 | """ |
---|
781 | Append theory helper |
---|
782 | """ |
---|
783 | if state_id in self.list_cb_theory.keys(): |
---|
784 | # update current list of theory for this data |
---|
785 | theory_list_ctrl = self.list_cb_theory[state_id] |
---|
786 | |
---|
787 | for theory_id, item in theory_list.iteritems(): |
---|
788 | theory_data, _ = item |
---|
789 | if theory_data is None: |
---|
790 | name = "Unknown" |
---|
791 | theory_class = "Unknown" |
---|
792 | theory_id = "Unknown" |
---|
793 | temp = (None, None, None) |
---|
794 | else: |
---|
795 | name = theory_data.name |
---|
796 | theory_class = theory_data.__class__.__name__ |
---|
797 | theory_id = theory_data.id |
---|
798 | # if theory_state is not None: |
---|
799 | # name = theory_state.model.name |
---|
800 | temp = (theory_id, theory_class, state_id) |
---|
801 | if theory_id not in theory_list_ctrl: |
---|
802 | # add new theory |
---|
803 | t_child = tree.AppendItem(root, |
---|
804 | name, ct_type=1, data=temp) |
---|
805 | t_i_c = tree.AppendItem(t_child, 'Info') |
---|
806 | i_c_c = tree.AppendItem(t_i_c, |
---|
807 | 'Type: %s' % theory_class) |
---|
808 | t_p_c = tree.AppendItem(t_i_c, 'Process') |
---|
809 | |
---|
810 | for process in theory_data.process: |
---|
811 | tree.AppendItem(t_p_c, process.__str__()) |
---|
812 | theory_list_ctrl[theory_id] = [t_child, |
---|
813 | i_c_c, |
---|
814 | t_p_c] |
---|
815 | else: |
---|
816 | # replace theory |
---|
817 | t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id] |
---|
818 | tree.SetItemText(t_child, name) |
---|
819 | tree.SetItemPyData(t_child, temp) |
---|
820 | tree.SetItemText(i_c_c, 'Type: %s' % theory_class) |
---|
821 | tree.DeleteChildren(t_p_c) |
---|
822 | for process in theory_data.process: |
---|
823 | tree.AppendItem(t_p_c, process.__str__()) |
---|
824 | |
---|
825 | else: |
---|
826 | # data didn't have a theory associated it before |
---|
827 | theory_list_ctrl = {} |
---|
828 | for theory_id, item in theory_list.iteritems(): |
---|
829 | theory_data, _ = item |
---|
830 | if theory_data is not None: |
---|
831 | name = theory_data.name |
---|
832 | theory_class = theory_data.__class__.__name__ |
---|
833 | theory_id = theory_data.id |
---|
834 | # if theory_state is not None: |
---|
835 | # name = theory_state.model.name |
---|
836 | temp = (theory_id, theory_class, state_id) |
---|
837 | t_child = tree.AppendItem(root, |
---|
838 | name, ct_type=1, |
---|
839 | data=(theory_data.id, theory_class, state_id)) |
---|
840 | t_i_c = tree.AppendItem(t_child, 'Info') |
---|
841 | i_c_c = tree.AppendItem(t_i_c, |
---|
842 | 'Type: %s' % theory_class) |
---|
843 | t_p_c = tree.AppendItem(t_i_c, 'Process') |
---|
844 | |
---|
845 | for process in theory_data.process: |
---|
846 | tree.AppendItem(t_p_c, process.__str__()) |
---|
847 | |
---|
848 | theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] |
---|
849 | # self.list_cb_theory[data_id] = theory_list_ctrl |
---|
850 | self.list_cb_theory[state_id] = theory_list_ctrl |
---|
851 | |
---|
852 | def set_data_helper(self): |
---|
853 | """ |
---|
854 | Set data helper |
---|
855 | """ |
---|
856 | data_to_plot = [] |
---|
857 | state_to_plot = [] |
---|
858 | theory_to_plot = [] |
---|
859 | for value in self.list_cb_data.values(): |
---|
860 | item, _, _, _, _, _, _, _ = value |
---|
861 | if item.IsChecked(): |
---|
862 | data_id, _, state_id = self.tree_ctrl.GetItemPyData(item) |
---|
863 | data_to_plot.append(data_id) |
---|
864 | if state_id not in state_to_plot: |
---|
865 | state_to_plot.append(state_id) |
---|
866 | |
---|
867 | for theory_dict in self.list_cb_theory.values(): |
---|
868 | for _, value in theory_dict.iteritems(): |
---|
869 | item, _, _ = value |
---|
870 | if item.IsChecked(): |
---|
871 | theory_id, _, state_id = self.tree_ctrl.GetItemPyData(item) |
---|
872 | theory_to_plot.append(theory_id) |
---|
873 | if state_id not in state_to_plot: |
---|
874 | state_to_plot.append(state_id) |
---|
875 | return data_to_plot, theory_to_plot, state_to_plot |
---|
876 | |
---|
877 | def remove_by_id(self, id): |
---|
878 | """ |
---|
879 | Remove_dat by id |
---|
880 | """ |
---|
881 | for item in self.list_cb_data.values(): |
---|
882 | data_c, _, _, _, _, _, _, _ = item |
---|
883 | data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c) |
---|
884 | if id == data_id: |
---|
885 | self.tree_ctrl.Delete(data_c) |
---|
886 | del self.list_cb_data[state_id] |
---|
887 | del self.list_cb_theory[data_id] |
---|
888 | |
---|
889 | def load_error(self, error=None): |
---|
890 | """ |
---|
891 | Pop up an error message. |
---|
892 | |
---|
893 | :param error: details error message to be displayed |
---|
894 | """ |
---|
895 | if error is not None or str(error).strip() != "": |
---|
896 | dial = wx.MessageDialog(self.parent, str(error), |
---|
897 | 'Error Loading File', |
---|
898 | wx.OK | wx.ICON_EXCLAMATION) |
---|
899 | dial.ShowModal() |
---|
900 | |
---|
901 | def _load_data(self, event): |
---|
902 | """ |
---|
903 | send an event to the parent to trigger load from plugin module |
---|
904 | """ |
---|
905 | if self.parent is not None: |
---|
906 | wx.PostEvent(self.parent, NewLoadDataEvent()) |
---|
907 | |
---|
908 | def on_remove(self, event, prompt=True): |
---|
909 | """ |
---|
910 | Get a list of item checked and remove them from the treectrl |
---|
911 | Ask the parent to remove reference to this item |
---|
912 | """ |
---|
913 | if prompt: |
---|
914 | msg = "This operation will delete the data sets checked " |
---|
915 | msg += "and all the dependents." |
---|
916 | msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK|wx.CANCEL) |
---|
917 | if msg_box.ShowModal() != wx.ID_OK: |
---|
918 | return |
---|
919 | |
---|
920 | data_to_remove, theory_to_remove, _ = self.set_data_helper() |
---|
921 | data_key = [] |
---|
922 | theory_key = [] |
---|
923 | # remove data from treectrl |
---|
924 | for d_key, item in self.list_cb_data.iteritems(): |
---|
925 | data_c, _, _, _, _, _, _, _ = item |
---|
926 | if data_c.IsChecked(): |
---|
927 | self.tree_ctrl.Delete(data_c) |
---|
928 | data_key.append(d_key) |
---|
929 | if d_key in self.list_cb_theory.keys(): |
---|
930 | theory_list_ctrl = self.list_cb_theory[d_key] |
---|
931 | theory_to_remove += theory_list_ctrl.keys() |
---|
932 | # Remove theory from treectrl |
---|
933 | for _, theory_dict in self.list_cb_theory.iteritems(): |
---|
934 | for key, value in theory_dict.iteritems(): |
---|
935 | item, _, _ = value |
---|
936 | if item.IsChecked(): |
---|
937 | try: |
---|
938 | self.tree_ctrl.Delete(item) |
---|
939 | except: |
---|
940 | pass |
---|
941 | theory_key.append(key) |
---|
942 | |
---|
943 | # Remove data and related theory references |
---|
944 | for key in data_key: |
---|
945 | del self.list_cb_data[key] |
---|
946 | if key in theory_key: |
---|
947 | del self.list_cb_theory[key] |
---|
948 | # remove theory references independently of data |
---|
949 | for key in theory_key: |
---|
950 | for _, theory_dict in self.list_cb_theory.iteritems(): |
---|
951 | if key in theory_dict: |
---|
952 | for key, value in theory_dict.iteritems(): |
---|
953 | item, _, _ = value |
---|
954 | if item.IsChecked(): |
---|
955 | try: |
---|
956 | self.tree_ctrl_theory.Delete(item) |
---|
957 | except: |
---|
958 | pass |
---|
959 | del theory_dict[key] |
---|
960 | |
---|
961 | self.parent.remove_data(data_id=data_to_remove, |
---|
962 | theory_id=theory_to_remove) |
---|
963 | self.enable_remove() |
---|
964 | self.enable_freeze() |
---|
965 | self.enable_remove_plot() |
---|
966 | |
---|
967 | def on_import(self, event=None): |
---|
968 | """ |
---|
969 | Get all select data and set them to the current active perspetive |
---|
970 | """ |
---|
971 | if event is not None: |
---|
972 | event.Skip() |
---|
973 | data_id, theory_id, state_id = self.set_data_helper() |
---|
974 | temp = data_id + state_id |
---|
975 | self.parent.set_data(data_id=temp, theory_id=theory_id) |
---|
976 | |
---|
977 | def on_append_plot(self, event=None): |
---|
978 | """ |
---|
979 | append plot to plot panel on focus |
---|
980 | """ |
---|
981 | self._on_plot_selection() |
---|
982 | data_id, theory_id, state_id = self.set_data_helper() |
---|
983 | self.parent.plot_data(data_id=data_id, |
---|
984 | state_id=state_id, |
---|
985 | theory_id=theory_id, |
---|
986 | append=True) |
---|
987 | |
---|
988 | def on_plot(self, event=None): |
---|
989 | """ |
---|
990 | Send a list of data names to plot |
---|
991 | """ |
---|
992 | data_id, theory_id, state_id = self.set_data_helper() |
---|
993 | self.parent.plot_data(data_id=data_id, |
---|
994 | state_id=state_id, |
---|
995 | theory_id=theory_id, |
---|
996 | append=False) |
---|
997 | self.enable_remove_plot() |
---|
998 | |
---|
999 | def on_close_page(self, event=None): |
---|
1000 | """ |
---|
1001 | On close |
---|
1002 | """ |
---|
1003 | if event is not None: |
---|
1004 | event.Skip() |
---|
1005 | # send parent to update menu with no show nor hide action |
---|
1006 | self.parent.show_data_panel(action=False) |
---|
1007 | |
---|
1008 | def on_freeze(self, event): |
---|
1009 | """ |
---|
1010 | On freeze to make a theory to a data set |
---|
1011 | """ |
---|
1012 | _, theory_id, state_id = self.set_data_helper() |
---|
1013 | if len(theory_id) > 0: |
---|
1014 | self.parent.freeze(data_id=state_id, theory_id=theory_id) |
---|
1015 | msg = "Freeze Theory:" |
---|
1016 | msg += " The theory(s) copied to the Data box as a data set." |
---|
1017 | else: |
---|
1018 | msg = "Freeze Theory: Requires at least one theory checked." |
---|
1019 | wx.PostEvent(self.parent, StatusEvent(status=msg)) |
---|
1020 | |
---|
1021 | def set_active_perspective(self, name): |
---|
1022 | """ |
---|
1023 | set the active perspective |
---|
1024 | """ |
---|
1025 | self.perspective_cbox.SetStringSelection(name) |
---|
1026 | self.enable_import() |
---|
1027 | |
---|
1028 | def _on_delete_plot_panel(self, event): |
---|
1029 | """ |
---|
1030 | get an event with attribute name and caption to delete existing name |
---|
1031 | from the combobox of the current panel |
---|
1032 | """ |
---|
1033 | # name = event.name |
---|
1034 | caption = event.caption |
---|
1035 | if self.cb_plotpanel is not None: |
---|
1036 | pos = self.cb_plotpanel.FindString(str(caption)) |
---|
1037 | if pos != wx.NOT_FOUND: |
---|
1038 | self.cb_plotpanel.Delete(pos) |
---|
1039 | self.enable_append() |
---|
1040 | |
---|
1041 | def set_panel_on_focus(self, name=None): |
---|
1042 | """ |
---|
1043 | set the plot panel on focus |
---|
1044 | """ |
---|
1045 | if self.cb_plotpanel and self.cb_plotpanel.IsBeingDeleted(): |
---|
1046 | return |
---|
1047 | for _, value in self.parent.plot_panels.iteritems(): |
---|
1048 | name_plot_panel = str(value.window_caption) |
---|
1049 | if name_plot_panel not in self.cb_plotpanel.GetItems(): |
---|
1050 | self.cb_plotpanel.Append(name_plot_panel, value) |
---|
1051 | if name is not None and name == name_plot_panel: |
---|
1052 | self.cb_plotpanel.SetStringSelection(name_plot_panel) |
---|
1053 | break |
---|
1054 | self.enable_append() |
---|
1055 | self.enable_remove_plot() |
---|
1056 | |
---|
1057 | def set_plot_unfocus(self): |
---|
1058 | """ |
---|
1059 | Unfocus plot |
---|
1060 | """ |
---|
1061 | return |
---|
1062 | |
---|
1063 | def _on_perspective_selection(self, event=None): |
---|
1064 | """ |
---|
1065 | select the current perspective for guiframe |
---|
1066 | """ |
---|
1067 | selection = self.perspective_cbox.GetSelection() |
---|
1068 | if self.perspective_cbox.GetValue() != 'None': |
---|
1069 | perspective = self.perspective_cbox.GetClientData(selection) |
---|
1070 | perspective.on_perspective(event=None) |
---|
1071 | self.parent.check_multimode(perspective=perspective) |
---|
1072 | |
---|
1073 | def _on_plot_selection(self, event=None): |
---|
1074 | """ |
---|
1075 | On source combobox selection |
---|
1076 | """ |
---|
1077 | if event is not None: |
---|
1078 | combo = event.GetEventObject() |
---|
1079 | event.Skip() |
---|
1080 | else: |
---|
1081 | combo = self.cb_plotpanel |
---|
1082 | selection = combo.GetSelection() |
---|
1083 | |
---|
1084 | if combo.GetValue() != 'None': |
---|
1085 | panel = combo.GetClientData(selection) |
---|
1086 | self.parent.on_set_plot_focus(panel) |
---|
1087 | |
---|
1088 | def on_close_plot(self, event): |
---|
1089 | """ |
---|
1090 | clseo the panel on focus |
---|
1091 | """ |
---|
1092 | self.enable_append() |
---|
1093 | selection = self.cb_plotpanel.GetSelection() |
---|
1094 | if self.cb_plotpanel.GetValue() != 'None': |
---|
1095 | panel = self.cb_plotpanel.GetClientData(selection) |
---|
1096 | if self.parent is not None and panel is not None: |
---|
1097 | wx.PostEvent(self.parent, |
---|
1098 | NewPlotEvent(group_id=panel.group_id, |
---|
1099 | action="delete")) |
---|
1100 | self.enable_remove_plot() |
---|
1101 | |
---|
1102 | def set_frame(self, frame): |
---|
1103 | """ |
---|
1104 | """ |
---|
1105 | self.frame = frame |
---|
1106 | |
---|
1107 | def get_frame(self): |
---|
1108 | """ |
---|
1109 | """ |
---|
1110 | return self.frame |
---|
1111 | |
---|
1112 | def on_help(self, event): |
---|
1113 | """ |
---|
1114 | Bring up the data manager Documentation whenever |
---|
1115 | the HELP button is clicked. |
---|
1116 | |
---|
1117 | Calls DocumentationWindow with the path of the location within the |
---|
1118 | documentation tree (after /doc/ ....". Note that when using old |
---|
1119 | versions of Wx (before 2.9) and thus not the release version of |
---|
1120 | installers, the help comes up at the top level of the file as |
---|
1121 | webbrowser does not pass anything past the # to the browser when it is |
---|
1122 | running "file:///...." |
---|
1123 | |
---|
1124 | :param event: Triggers on clicking the help button |
---|
1125 | """ |
---|
1126 | |
---|
1127 | #import documentation window here to avoid circular imports |
---|
1128 | #if put at top of file with rest of imports. |
---|
1129 | from documentation_window import DocumentationWindow |
---|
1130 | |
---|
1131 | _TreeLocation = "user/sasgui/guiframe/data_explorer_help.html" |
---|
1132 | _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "", |
---|
1133 | "Data Explorer Help") |
---|
1134 | |
---|
1135 | def on_close(self, event): |
---|
1136 | """ |
---|
1137 | On close event |
---|
1138 | """ |
---|
1139 | self.parent.show_data_panel(event) |
---|
1140 | |
---|
1141 | def set_schedule_full_draw(self, panel=None, func='del'): |
---|
1142 | """ |
---|
1143 | Send full draw to guimanager |
---|
1144 | """ |
---|
1145 | self.parent.set_schedule_full_draw(panel, func) |
---|
1146 | |
---|
1147 | def enable_remove_plot(self): |
---|
1148 | """ |
---|
1149 | enable remove plot button if there is a plot panel on focus |
---|
1150 | """ |
---|
1151 | pass |
---|
1152 | #if self.cb_plotpanel.GetCount() == 0: |
---|
1153 | # self.bt_close_plot.Disable() |
---|
1154 | #else: |
---|
1155 | # self.bt_close_plot.Enable() |
---|
1156 | |
---|
1157 | def enable_remove(self): |
---|
1158 | """ |
---|
1159 | enable or disable remove button |
---|
1160 | """ |
---|
1161 | n_t = self.tree_ctrl.GetCount() |
---|
1162 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
1163 | if n_t + n_t_t <= 0: |
---|
1164 | self.bt_remove.Disable() |
---|
1165 | else: |
---|
1166 | self.bt_remove.Enable() |
---|
1167 | |
---|
1168 | def enable_import(self): |
---|
1169 | """ |
---|
1170 | enable or disable send button |
---|
1171 | """ |
---|
1172 | n_t = 0 |
---|
1173 | if self.tree_ctrl is not None: |
---|
1174 | n_t = self.tree_ctrl.GetCount() |
---|
1175 | if n_t > 0 and len(self.list_of_perspective) > 0: |
---|
1176 | self.bt_import.Enable() |
---|
1177 | else: |
---|
1178 | self.bt_import.Disable() |
---|
1179 | if len(self.list_of_perspective) <= 0 or \ |
---|
1180 | self.perspective_cbox.GetValue() in ["None", |
---|
1181 | "No Active Application"]: |
---|
1182 | self.perspective_cbox.Disable() |
---|
1183 | else: |
---|
1184 | self.perspective_cbox.Enable() |
---|
1185 | |
---|
1186 | def enable_plot(self): |
---|
1187 | """ |
---|
1188 | enable or disable plot button |
---|
1189 | """ |
---|
1190 | n_t = 0 |
---|
1191 | n_t_t = 0 |
---|
1192 | if self.tree_ctrl is not None: |
---|
1193 | n_t = self.tree_ctrl.GetCount() |
---|
1194 | if self.tree_ctrl_theory is not None: |
---|
1195 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
1196 | if n_t + n_t_t <= 0: |
---|
1197 | self.bt_plot.Disable() |
---|
1198 | else: |
---|
1199 | self.bt_plot.Enable() |
---|
1200 | self.enable_append() |
---|
1201 | |
---|
1202 | def enable_append(self): |
---|
1203 | """ |
---|
1204 | enable or disable append button |
---|
1205 | """ |
---|
1206 | n_t = 0 |
---|
1207 | n_t_t = 0 |
---|
1208 | if self.tree_ctrl is not None: |
---|
1209 | n_t = self.tree_ctrl.GetCount() |
---|
1210 | if self.tree_ctrl_theory is not None: |
---|
1211 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
1212 | if n_t + n_t_t <= 0: |
---|
1213 | self.bt_append_plot.Disable() |
---|
1214 | self.cb_plotpanel.Disable() |
---|
1215 | elif self.cb_plotpanel.GetCount() <= 0: |
---|
1216 | self.cb_plotpanel.Disable() |
---|
1217 | self.bt_append_plot.Disable() |
---|
1218 | else: |
---|
1219 | self.bt_append_plot.Enable() |
---|
1220 | self.cb_plotpanel.Enable() |
---|
1221 | |
---|
1222 | def check_theory_to_freeze(self): |
---|
1223 | """ |
---|
1224 | Check_theory_to_freeze |
---|
1225 | """ |
---|
1226 | def enable_freeze(self): |
---|
1227 | """ |
---|
1228 | enable or disable the freeze button |
---|
1229 | """ |
---|
1230 | n_t_t = 0 |
---|
1231 | n_l = 0 |
---|
1232 | if self.tree_ctrl_theory is not None: |
---|
1233 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
1234 | n_l = len(self.list_cb_theory) |
---|
1235 | if (n_t_t + n_l > 0): |
---|
1236 | self.bt_freeze.Enable() |
---|
1237 | else: |
---|
1238 | self.bt_freeze.Disable() |
---|
1239 | |
---|
1240 | def enable_selection(self): |
---|
1241 | """ |
---|
1242 | enable or disable combobo box selection |
---|
1243 | """ |
---|
1244 | n_t = 0 |
---|
1245 | n_t_t = 0 |
---|
1246 | if self.tree_ctrl is not None: |
---|
1247 | n_t = self.tree_ctrl.GetCount() |
---|
1248 | if self.tree_ctrl_theory is not None: |
---|
1249 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
1250 | if n_t + n_t_t > 0 and self.selection_cbox is not None: |
---|
1251 | self.selection_cbox.Enable() |
---|
1252 | else: |
---|
1253 | self.selection_cbox.Disable() |
---|
1254 | |
---|
1255 | def show_data_button(self): |
---|
1256 | """ |
---|
1257 | show load data and remove data button if |
---|
1258 | dataloader on else hide them |
---|
1259 | """ |
---|
1260 | try: |
---|
1261 | gui_style = self.parent.get_style() |
---|
1262 | style = gui_style & GUIFRAME.DATALOADER_ON |
---|
1263 | if style == GUIFRAME.DATALOADER_ON: |
---|
1264 | #self.bt_remove.Show(True) |
---|
1265 | self.bt_add.Show(True) |
---|
1266 | else: |
---|
1267 | #self.bt_remove.Hide() |
---|
1268 | self.bt_add.Hide() |
---|
1269 | except: |
---|
1270 | #self.bt_remove.Hide() |
---|
1271 | self.bt_add.Hide() |
---|
1272 | |
---|
1273 | |
---|
1274 | WIDTH = 400 |
---|
1275 | HEIGHT = 300 |
---|
1276 | |
---|
1277 | |
---|
1278 | class DataDialog(wx.Dialog): |
---|
1279 | """ |
---|
1280 | Allow file selection at loading time |
---|
1281 | """ |
---|
1282 | def __init__(self, data_list, parent=None, text='', *args, **kwds): |
---|
1283 | wx.Dialog.__init__(self, parent, *args, **kwds) |
---|
1284 | self.SetTitle("Data Selection") |
---|
1285 | self.SetSize((WIDTH, HEIGHT)) |
---|
1286 | self.list_of_ctrl = [] |
---|
1287 | if not data_list: |
---|
1288 | return |
---|
1289 | self._sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
1290 | self._sizer_txt = wx.BoxSizer(wx.VERTICAL) |
---|
1291 | self._sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
1292 | self.sizer = wx.GridBagSizer(5, 5) |
---|
1293 | self._panel = ScrolledPanel(self, style=wx.RAISED_BORDER, |
---|
1294 | size=(WIDTH-20, HEIGHT-50)) |
---|
1295 | self._panel.SetupScrolling() |
---|
1296 | self.__do_layout(data_list, text=text) |
---|
1297 | |
---|
1298 | def __do_layout(self, data_list, text=''): |
---|
1299 | """ |
---|
1300 | layout the dialog |
---|
1301 | """ |
---|
1302 | if not data_list or len(data_list) <= 1: |
---|
1303 | return |
---|
1304 | # add text |
---|
1305 | |
---|
1306 | text = "Deleting these file reset some panels.\n" |
---|
1307 | text += "Do you want to proceed?\n" |
---|
1308 | text_ctrl = wx.StaticText(self, -1, str(text)) |
---|
1309 | self._sizer_txt.Add(text_ctrl) |
---|
1310 | iy = 0 |
---|
1311 | ix = 0 |
---|
1312 | # data_count = 0 |
---|
1313 | for (data_name, in_use, sub_menu) in range(len(data_list)): |
---|
1314 | if in_use: |
---|
1315 | ctrl_name = wx.StaticBox(self, -1, str(data_name)) |
---|
1316 | ctrl_in_use = wx.StaticBox(self, -1, " is used by ") |
---|
1317 | plug_name = str(sub_menu) + "\n" |
---|
1318 | # ctrl_sub_menu = wx.StaticBox(self, -1, plug_name) |
---|
1319 | self.sizer.Add(ctrl_name, (iy, ix), |
---|
1320 | (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
1321 | ix += 1 |
---|
1322 | self._sizer_button.Add(ctrl_in_use, 1, |
---|
1323 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
1324 | ix += 1 |
---|
1325 | self._sizer_button.Add(plug_name, 1, |
---|
1326 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
1327 | iy += 1 |
---|
1328 | self._panel.SetSizer(self.sizer) |
---|
1329 | # add sizer |
---|
1330 | self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
1331 | button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") |
---|
1332 | self._sizer_button.Add(button_cancel, 0, |
---|
1333 | wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
1334 | button_OK = wx.Button(self, wx.ID_OK, "Ok") |
---|
1335 | button_OK.SetFocus() |
---|
1336 | self._sizer_button.Add(button_OK, 0, |
---|
1337 | wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
1338 | static_line = wx.StaticLine(self, -1) |
---|
1339 | |
---|
1340 | self._sizer_txt.Add(self._panel, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5) |
---|
1341 | self._sizer_main.Add(self._sizer_txt, 1, wx.EXPAND|wx.ALL, 10) |
---|
1342 | #self._sizer_main.Add(self._data_text_ctrl, 0, |
---|
1343 | # wx.EXPAND|wx.LEFT|wx.RIGHT, 10) |
---|
1344 | self._sizer_main.Add(static_line, 0, wx.EXPAND, 0) |
---|
1345 | self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND|wx.ALL, 10) |
---|
1346 | self.SetSizer(self._sizer_main) |
---|
1347 | self.Layout() |
---|
1348 | |
---|
1349 | def get_data(self): |
---|
1350 | """ |
---|
1351 | return the selected data |
---|
1352 | """ |
---|
1353 | temp = [] |
---|
1354 | for item in self.list_of_ctrl: |
---|
1355 | cb, data = item |
---|
1356 | if cb.GetValue(): |
---|
1357 | temp.append(data) |
---|
1358 | return temp |
---|
1359 | |
---|
1360 | class DataFrame(wx.Frame): |
---|
1361 | """ |
---|
1362 | Data Frame |
---|
1363 | """ |
---|
1364 | ## Internal name for the AUI manager |
---|
1365 | window_name = "Data Panel" |
---|
1366 | ## Title to appear on top of the window |
---|
1367 | window_caption = "Data Panel" |
---|
1368 | ## Flag to tell the GUI manager that this panel is not |
---|
1369 | # tied to any perspective |
---|
1370 | ALWAYS_ON = True |
---|
1371 | |
---|
1372 | def __init__(self, parent=None, owner=None, manager=None, size=(300, 800), |
---|
1373 | list_of_perspective=[], list=[], *args, **kwds): |
---|
1374 | kwds['size'] = size |
---|
1375 | kwds['id'] = -1 |
---|
1376 | kwds['title'] = "Loaded Data" |
---|
1377 | wx.Frame.__init__(self, parent=parent, *args, **kwds) |
---|
1378 | self.parent = parent |
---|
1379 | self.owner = owner |
---|
1380 | self._manager = manager |
---|
1381 | self.panel = DataPanel(parent=self, |
---|
1382 | manager=manager, |
---|
1383 | list_of_perspective=list_of_perspective) |
---|
1384 | |
---|
1385 | def load_data_list(self, list=[]): |
---|
1386 | """ |
---|
1387 | Fill the list inside its panel |
---|
1388 | """ |
---|
1389 | self.panel.load_data_list(list=list) |
---|
1390 | |
---|
1391 | |
---|
1392 | from sas.sasgui.guiframe.dataFitting import Theory1D |
---|
1393 | from sas.sasgui.guiframe.data_state import DataState |
---|
1394 | |
---|
1395 | |
---|
1396 | class State(): |
---|
1397 | """ |
---|
1398 | DataPanel State |
---|
1399 | """ |
---|
1400 | def __init__(self): |
---|
1401 | self.msg = "" |
---|
1402 | def __str__(self): |
---|
1403 | self.msg = "model mane : model1\n" |
---|
1404 | self.msg += "params : \n" |
---|
1405 | self.msg += "name value\n" |
---|
1406 | return self.msg |
---|
1407 | |
---|
1408 | |
---|
1409 | def set_data_state(data=None, path=None, theory=None, state=None): |
---|
1410 | """ |
---|
1411 | Set data state |
---|
1412 | """ |
---|
1413 | dstate = DataState(data=data) |
---|
1414 | dstate.set_path(path=path) |
---|
1415 | dstate.set_theory(theory, state) |
---|
1416 | |
---|
1417 | return dstate |
---|
1418 | |
---|
1419 | if __name__ == "__main__": |
---|
1420 | |
---|
1421 | app = wx.App() |
---|
1422 | try: |
---|
1423 | # list_of_perspective = [('perspective2', False), ('perspective1', True)] |
---|
1424 | data_list1 = {} |
---|
1425 | # state 1 |
---|
1426 | data1 = Data2D() |
---|
1427 | data1.name = "data2" |
---|
1428 | data1.id = 1 |
---|
1429 | data1.append_empty_process() |
---|
1430 | process1 = data1.process[len(data1.process)-1] |
---|
1431 | process1.data = "07/01/2010" |
---|
1432 | theory1 = Data2D() |
---|
1433 | theory1.id = 34 |
---|
1434 | theory1.name = "theory1" |
---|
1435 | path1 = "path1" |
---|
1436 | state1 = State() |
---|
1437 | data_list1['1'] = set_data_state(data1, path1, theory1, state1) |
---|
1438 | # state 2 |
---|
1439 | data1 = Data2D() |
---|
1440 | data1.name = "data2" |
---|
1441 | data1.id = 76 |
---|
1442 | theory1 = Data2D() |
---|
1443 | theory1.id = 78 |
---|
1444 | theory1.name = "CoreShell 07/24/25" |
---|
1445 | path1 = "path2" |
---|
1446 | # state3 |
---|
1447 | state1 = State() |
---|
1448 | data_list1['2'] = set_data_state(data1, path1, theory1, state1) |
---|
1449 | data1 = Data1D() |
---|
1450 | data1.id = 3 |
---|
1451 | data1.name = "data2" |
---|
1452 | theory1 = Theory1D() |
---|
1453 | theory1.name = "CoreShell" |
---|
1454 | theory1.id = 4 |
---|
1455 | theory1.append_empty_process() |
---|
1456 | process1 = theory1.process[len(theory1.process)-1] |
---|
1457 | process1.description = "this is my description" |
---|
1458 | path1 = "path3" |
---|
1459 | data1.append_empty_process() |
---|
1460 | process1 = data1.process[len(data1.process)-1] |
---|
1461 | process1.data = "07/22/2010" |
---|
1462 | data_list1['4'] = set_data_state(data1, path1, theory1, state1) |
---|
1463 | # state 4 |
---|
1464 | temp_data_list = {} |
---|
1465 | data1.name = "data5 erasing data2" |
---|
1466 | temp_data_list['4'] = set_data_state(data1, path1, theory1, state1) |
---|
1467 | # state 5 |
---|
1468 | data1 = Data2D() |
---|
1469 | data1.name = "data3" |
---|
1470 | data1.id = 5 |
---|
1471 | data1.append_empty_process() |
---|
1472 | process1 = data1.process[len(data1.process)-1] |
---|
1473 | process1.data = "07/01/2010" |
---|
1474 | theory1 = Theory1D() |
---|
1475 | theory1.name = "Cylinder" |
---|
1476 | path1 = "path2" |
---|
1477 | state1 = State() |
---|
1478 | dstate1 = set_data_state(data1, path1, theory1, state1) |
---|
1479 | theory1 = Theory1D() |
---|
1480 | theory1.id = 6 |
---|
1481 | theory1.name = "CoreShell" |
---|
1482 | dstate1.set_theory(theory1) |
---|
1483 | theory1 = Theory1D() |
---|
1484 | theory1.id = 6 |
---|
1485 | theory1.name = "CoreShell replacing coreshell in data3" |
---|
1486 | dstate1.set_theory(theory1) |
---|
1487 | data_list1['3'] = dstate1 |
---|
1488 | #state 6 |
---|
1489 | data_list1['6'] = set_data_state(None, path1, theory1, state1) |
---|
1490 | data_list1['6'] = set_data_state(theory=theory1, state=None) |
---|
1491 | theory1 = Theory1D() |
---|
1492 | theory1.id = 7 |
---|
1493 | data_list1['6'] = set_data_state(theory=theory1, state=None) |
---|
1494 | data_list1['7'] = set_data_state(theory=theory1, state=None) |
---|
1495 | window = DataFrame(list=data_list1) |
---|
1496 | window.load_data_list(list=data_list1) |
---|
1497 | window.Show(True) |
---|
1498 | window.load_data_list(list=temp_data_list) |
---|
1499 | except: |
---|
1500 | # raise |
---|
1501 | print("error", sys.exc_value) |
---|
1502 | |
---|
1503 | app.MainLoop() |
---|