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