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