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 | import os |
---|
14 | import wx |
---|
15 | import sys |
---|
16 | import warnings |
---|
17 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
18 | import wx.lib.agw.customtreectrl as CT |
---|
19 | from sans.guiframe.dataFitting import Data1D |
---|
20 | from sans.guiframe.dataFitting import Data2D |
---|
21 | from sans.guiframe.panel_base import PanelBase |
---|
22 | from sans.guiframe.events import StatusEvent |
---|
23 | from DataLoader.loader import Loader |
---|
24 | import logging |
---|
25 | |
---|
26 | try: |
---|
27 | # Try to find a local config |
---|
28 | import imp |
---|
29 | path = os.getcwd() |
---|
30 | if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \ |
---|
31 | (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))): |
---|
32 | fObj, path, descr = imp.find_module('local_config', [path]) |
---|
33 | config = imp.load_module('local_config', fObj, path, descr) |
---|
34 | else: |
---|
35 | # Try simply importing local_config |
---|
36 | import local_config as config |
---|
37 | except: |
---|
38 | # Didn't find local config, load the default |
---|
39 | import config |
---|
40 | |
---|
41 | extension_list = [] |
---|
42 | if config.APPLICATION_STATE_EXTENSION is not None: |
---|
43 | extension_list.append(config.APPLICATION_STATE_EXTENSION) |
---|
44 | EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS + extension_list |
---|
45 | |
---|
46 | PANEL_WIDTH = 235 |
---|
47 | PANEL_HEIGHT = 700 |
---|
48 | CBOX_WIDTH = 140 |
---|
49 | BUTTON_WIDTH = 80 |
---|
50 | STYLE_FLAG =wx.RAISED_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT|\ |
---|
51 | wx.WANTS_CHARS|CT.TR_HAS_VARIABLE_ROW_HEIGHT |
---|
52 | |
---|
53 | |
---|
54 | class DataTreeCtrl(CT.CustomTreeCtrl): |
---|
55 | """ |
---|
56 | Check list control to be used for Data Panel |
---|
57 | """ |
---|
58 | def __init__(self, parent,*args, **kwds): |
---|
59 | #agwstyle is introduced in wx.2.8.11 but is not working for mac |
---|
60 | if sys.platform.count("darwin") != 0: |
---|
61 | try: |
---|
62 | kwds['style'] = STYLE_FLAG |
---|
63 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
64 | except: |
---|
65 | del kwds['style'] |
---|
66 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
67 | else: |
---|
68 | #agwstyle is introduced in wx.2.8.11 .argument working only for windows |
---|
69 | try: |
---|
70 | kwds['agwStyle'] = STYLE_FLAG |
---|
71 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
72 | except: |
---|
73 | try: |
---|
74 | del kwds['agwStyle'] |
---|
75 | kwds['style'] = STYLE_FLAG |
---|
76 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
77 | except: |
---|
78 | del kwds['style'] |
---|
79 | CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) |
---|
80 | self.root = self.AddRoot("Available Data") |
---|
81 | |
---|
82 | class DataPanel(ScrolledPanel, PanelBase): |
---|
83 | """ |
---|
84 | This panel displays data available in the application and widgets to |
---|
85 | interact with data. |
---|
86 | """ |
---|
87 | ## Internal name for the AUI manager |
---|
88 | window_name = "Data Panel" |
---|
89 | ## Title to appear on top of the window |
---|
90 | window_caption = "Data Explorer" |
---|
91 | #type of window |
---|
92 | window_type = "Data Panel" |
---|
93 | ## Flag to tell the GUI manager that this panel is not |
---|
94 | # tied to any perspective |
---|
95 | #ALWAYS_ON = True |
---|
96 | def __init__(self, parent, |
---|
97 | list=None, |
---|
98 | size=(PANEL_WIDTH, PANEL_HEIGHT), |
---|
99 | list_of_perspective=None, manager=None, *args, **kwds): |
---|
100 | |
---|
101 | kwds['size']= size |
---|
102 | kwds['style'] = STYLE_FLAG |
---|
103 | ScrolledPanel.__init__(self, parent=parent, *args, **kwds) |
---|
104 | PanelBase.__init__(self) |
---|
105 | self.SetupScrolling() |
---|
106 | self.loader = Loader() |
---|
107 | #Default location |
---|
108 | self._default_save_location = None |
---|
109 | self.all_data1d = True |
---|
110 | self.parent = parent |
---|
111 | self.manager = manager |
---|
112 | if list is None: |
---|
113 | list = [] |
---|
114 | self.list_of_data = list |
---|
115 | if list_of_perspective is None: |
---|
116 | list_of_perspective = [] |
---|
117 | self.list_of_perspective = list_of_perspective |
---|
118 | self.list_rb_perspectives= [] |
---|
119 | self.list_cb_data = {} |
---|
120 | self.list_cb_theory = {} |
---|
121 | self.tree_ctrl = None |
---|
122 | self.tree_ctrl_theory = None |
---|
123 | self.perspective_cbox = None |
---|
124 | |
---|
125 | self.owner = None |
---|
126 | self.do_layout() |
---|
127 | self.fill_cbox_analysis(self.list_of_perspective) |
---|
128 | self.Bind(wx.EVT_SHOW, self.on_close_page) |
---|
129 | |
---|
130 | |
---|
131 | def do_layout(self): |
---|
132 | """ |
---|
133 | """ |
---|
134 | self.define_panel_structure() |
---|
135 | self.layout_selection() |
---|
136 | self.layout_data_list() |
---|
137 | self.layout_button() |
---|
138 | #self.layout_batch() |
---|
139 | |
---|
140 | def define_panel_structure(self): |
---|
141 | """ |
---|
142 | Define the skeleton of the panel |
---|
143 | """ |
---|
144 | w, h = self.parent.GetSize() |
---|
145 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
146 | self.sizer1 = wx.BoxSizer(wx.VERTICAL) |
---|
147 | self.sizer1.SetMinSize((w/13, h*2/5)) |
---|
148 | |
---|
149 | self.sizer2 = wx.BoxSizer(wx.VERTICAL) |
---|
150 | self.sizer3 = wx.FlexGridSizer(5, 2, 0, 0) |
---|
151 | self.sizer4 = wx.BoxSizer(wx.HORIZONTAL) |
---|
152 | self.sizer5 = wx.BoxSizer(wx.VERTICAL) |
---|
153 | |
---|
154 | self.vbox.Add(self.sizer5, 0, wx.EXPAND|wx.ALL,1) |
---|
155 | self.vbox.Add(self.sizer1, 0, wx.EXPAND|wx.ALL,0) |
---|
156 | self.vbox.Add(self.sizer2, 0, wx.EXPAND|wx.ALL,1) |
---|
157 | self.vbox.Add(self.sizer3, 0, wx.EXPAND|wx.ALL,1) |
---|
158 | self.vbox.Add(self.sizer4, 0, wx.EXPAND|wx.ALL,5) |
---|
159 | |
---|
160 | self.SetSizer(self.vbox) |
---|
161 | |
---|
162 | def layout_selection(self): |
---|
163 | """ |
---|
164 | """ |
---|
165 | select_txt = wx.StaticText(self, -1, 'Selection Options') |
---|
166 | select_txt.SetForegroundColour('blue') |
---|
167 | self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
168 | list_of_options = ['Select all Data', |
---|
169 | 'Unselect all Data', |
---|
170 | 'Select all Data 1D', |
---|
171 | 'Unselect all Data 1D', |
---|
172 | 'Select all Data 2D', |
---|
173 | 'Unselect all Data 2D' ] |
---|
174 | for option in list_of_options: |
---|
175 | self.selection_cbox.Append(str(option)) |
---|
176 | self.selection_cbox.SetValue('Select all Data') |
---|
177 | wx.EVT_COMBOBOX(self.selection_cbox,-1, self._on_selection_type) |
---|
178 | self.sizer5.AddMany([(select_txt,0, wx.ALL,5), |
---|
179 | (self.selection_cbox,0, wx.ALL,5)]) |
---|
180 | self.enable_selection() |
---|
181 | |
---|
182 | |
---|
183 | def _on_selection_type(self, event): |
---|
184 | """ |
---|
185 | Select data according to patterns |
---|
186 | """ |
---|
187 | |
---|
188 | list_of_options = ['Select all Data', |
---|
189 | 'Unselect all Data', |
---|
190 | 'Select all Data 1D', |
---|
191 | 'Unselect all Data 1D', |
---|
192 | 'Select all Data 2D', |
---|
193 | 'Unselect all Data 2D' ] |
---|
194 | option = self.selection_cbox.GetValue() |
---|
195 | |
---|
196 | pos = self.selection_cbox.GetSelection() |
---|
197 | if pos == wx.NOT_FOUND: |
---|
198 | return |
---|
199 | option = self.selection_cbox.GetString(pos) |
---|
200 | for item in self.list_cb_data.values(): |
---|
201 | data_ctrl, _, _, _,_, _ = item |
---|
202 | data_id, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl) |
---|
203 | if option == 'Select all Data': |
---|
204 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
205 | elif option == 'Unselect all Data': |
---|
206 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
207 | elif option == 'Select all Data 1D': |
---|
208 | if data_class == 'Data1D': |
---|
209 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
210 | elif option == 'Unselect all Data 1D': |
---|
211 | if data_class == 'Data1D': |
---|
212 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
213 | elif option == 'Select all Data 1D': |
---|
214 | if data_class == 'Data1D': |
---|
215 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
216 | elif option == 'Select all Data 2D': |
---|
217 | if data_class == 'Data2D': |
---|
218 | self.tree_ctrl.CheckItem(data_ctrl, True) |
---|
219 | elif option == 'Unselect all Data 2D': |
---|
220 | if data_class == 'Data2D': |
---|
221 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
222 | self.enable_append() |
---|
223 | self.enable_freeze() |
---|
224 | self.enable_plot() |
---|
225 | self.enable_import() |
---|
226 | #self.enable_remove() |
---|
227 | |
---|
228 | def layout_button(self): |
---|
229 | """ |
---|
230 | Layout widgets related to buttons |
---|
231 | """ |
---|
232 | w, _ = self.GetSize() |
---|
233 | self.bt_add = wx.Button(self, wx.NewId(), "Load Data", |
---|
234 | size=(BUTTON_WIDTH, -1)) |
---|
235 | self.bt_add.SetToolTipString("Load data files") |
---|
236 | wx.EVT_BUTTON(self, self.bt_add.GetId(), self._load_data) |
---|
237 | #self.bt_remove = wx.Button(self, wx.NewId(), "Remove Data", |
---|
238 | # size=(BUTTON_WIDTH, -1)) |
---|
239 | #self.bt_remove.SetToolTipString("Remove data from the application") |
---|
240 | #wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) |
---|
241 | self.bt_import = wx.Button(self, wx.NewId(), "Send To", |
---|
242 | size=(BUTTON_WIDTH, -1)) |
---|
243 | self.bt_import.SetToolTipString("Send set of Data to active perspective") |
---|
244 | wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) |
---|
245 | self.perspective_cbox = wx.ComboBox(self, -1, size=(CBOX_WIDTH, -1), |
---|
246 | style=wx.CB_READONLY) |
---|
247 | wx.EVT_COMBOBOX(self.perspective_cbox,-1, |
---|
248 | self._on_perspective_selection) |
---|
249 | |
---|
250 | self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To", |
---|
251 | size=(BUTTON_WIDTH, -1)) |
---|
252 | self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel") |
---|
253 | wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) |
---|
254 | |
---|
255 | self.bt_plot = wx.Button(self, wx.NewId(), "New Plot", |
---|
256 | size=(BUTTON_WIDTH, -1)) |
---|
257 | self.bt_plot.SetToolTipString("To trigger plotting") |
---|
258 | wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) |
---|
259 | |
---|
260 | self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze Theory", |
---|
261 | size=(BUTTON_WIDTH, -1)) |
---|
262 | self.bt_freeze.SetToolTipString("To trigger freeze a theory") |
---|
263 | wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) |
---|
264 | |
---|
265 | self.cb_plotpanel = wx.ComboBox(self, -1, size=(CBOX_WIDTH, -1), |
---|
266 | style=wx.CB_READONLY|wx.CB_SORT) |
---|
267 | wx.EVT_COMBOBOX(self.cb_plotpanel,-1, self._on_plot_selection) |
---|
268 | self.cb_plotpanel.Disable() |
---|
269 | |
---|
270 | self.sizer3.AddMany([(self.bt_add), |
---|
271 | ((10, 10)), |
---|
272 | (self.bt_import, 0, wx.EXPAND|wx.RIGHT, 5), |
---|
273 | (self.perspective_cbox, wx.EXPAND), |
---|
274 | (self.bt_append_plot), |
---|
275 | (self.cb_plotpanel, wx.EXPAND), |
---|
276 | (self.bt_plot), |
---|
277 | ((10, 10)), |
---|
278 | (self.bt_freeze), |
---|
279 | ((10, 10))]) |
---|
280 | |
---|
281 | self.sizer3.AddGrowableCol(1, 1) |
---|
282 | |
---|
283 | #self.enable_remove() |
---|
284 | self.enable_import() |
---|
285 | self.enable_plot() |
---|
286 | self.enable_append() |
---|
287 | self.enable_freeze() |
---|
288 | |
---|
289 | def layout_batch(self): |
---|
290 | """ |
---|
291 | """ |
---|
292 | self.rb_single_mode = wx.RadioButton(self, -1, 'Single Mode', |
---|
293 | style=wx.RB_GROUP) |
---|
294 | self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode') |
---|
295 | |
---|
296 | self.rb_single_mode.SetValue(True) |
---|
297 | self.rb_batch_mode.SetValue(False) |
---|
298 | self.sizer4.AddMany([(self.rb_single_mode,0, wx.ALL,5), |
---|
299 | (self.rb_batch_mode,0, wx.ALL,5)]) |
---|
300 | |
---|
301 | def layout_data_list(self): |
---|
302 | """ |
---|
303 | Add a listcrtl in the panel |
---|
304 | """ |
---|
305 | tree_ctrl_label = wx.StaticText(self, -1, "Data") |
---|
306 | tree_ctrl_label.SetForegroundColour('blue') |
---|
307 | self.tree_ctrl = DataTreeCtrl(parent=self) |
---|
308 | self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) |
---|
309 | tree_ctrl_theory_label = wx.StaticText(self, -1, "Theory") |
---|
310 | tree_ctrl_theory_label.SetForegroundColour('blue') |
---|
311 | self.tree_ctrl_theory = DataTreeCtrl(parent=self) |
---|
312 | self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) |
---|
313 | self.sizer1.Add(tree_ctrl_label, 0, wx.LEFT, 10) |
---|
314 | self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND|wx.ALL, 10) |
---|
315 | self.sizer1.Add(tree_ctrl_theory_label, 0, wx.LEFT, 10) |
---|
316 | self.sizer1.Add(self.tree_ctrl_theory, 1, wx.EXPAND|wx.ALL, 10) |
---|
317 | |
---|
318 | def onContextMenu(self, event): |
---|
319 | """ |
---|
320 | Retrieve the state selected state |
---|
321 | """ |
---|
322 | # Skipping the save state functionality for release 0.9.0 |
---|
323 | #return |
---|
324 | pos = event.GetPosition() |
---|
325 | pos = self.ScreenToClient(pos) |
---|
326 | self.PopupMenu(self.popUpMenu, pos) |
---|
327 | |
---|
328 | |
---|
329 | def on_check_item(self, event): |
---|
330 | """ |
---|
331 | """ |
---|
332 | item = event.GetItem() |
---|
333 | item.Check(not item.IsChecked()) |
---|
334 | self.enable_append() |
---|
335 | self.enable_freeze() |
---|
336 | self.enable_plot() |
---|
337 | self.enable_import() |
---|
338 | #self.enable_remove() |
---|
339 | event.Skip() |
---|
340 | |
---|
341 | def fill_cbox_analysis(self, plugin): |
---|
342 | """ |
---|
343 | fill the combobox with analysis name |
---|
344 | """ |
---|
345 | self.list_of_perspective = plugin |
---|
346 | if self.parent is None or \ |
---|
347 | not hasattr(self.parent, "get_current_perspective") or \ |
---|
348 | len(self.list_of_perspective) == 0: |
---|
349 | return |
---|
350 | if self.parent is not None and self.perspective_cbox is not None: |
---|
351 | for plug in self.list_of_perspective: |
---|
352 | if plug.get_perspective(): |
---|
353 | self.perspective_cbox.Append(plug.sub_menu, plug) |
---|
354 | |
---|
355 | curr_pers = self.parent.get_current_perspective() |
---|
356 | self.perspective_cbox.SetStringSelection(curr_pers.sub_menu) |
---|
357 | self.enable_import() |
---|
358 | |
---|
359 | def load_data_list(self, list): |
---|
360 | """ |
---|
361 | add need data with its theory under the tree |
---|
362 | """ |
---|
363 | if list: |
---|
364 | for state_id, dstate in list.iteritems(): |
---|
365 | data = dstate.get_data() |
---|
366 | theory_list = dstate.get_theory() |
---|
367 | if data is not None: |
---|
368 | data_name = data.name |
---|
369 | data_class = data.__class__.__name__ |
---|
370 | path = dstate.get_path() |
---|
371 | process_list = data.process |
---|
372 | data_id = data.id |
---|
373 | |
---|
374 | if state_id not in self.list_cb_data: |
---|
375 | #new state |
---|
376 | data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, |
---|
377 | data_name, ct_type=1, |
---|
378 | data=(data_id, data_class, state_id)) |
---|
379 | data_c.Check(True) |
---|
380 | d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') |
---|
381 | i_c_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
382 | 'Type: %s' % data_class) |
---|
383 | p_c_c = self.tree_ctrl.AppendItem(d_i_c, |
---|
384 | 'Path: %s' % str(path)) |
---|
385 | d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') |
---|
386 | |
---|
387 | for process in process_list: |
---|
388 | i_t_c = self.tree_ctrl.AppendItem(d_p_c, |
---|
389 | process.__str__()) |
---|
390 | theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES") |
---|
391 | |
---|
392 | self.list_cb_data[state_id] = [data_c, |
---|
393 | d_i_c, |
---|
394 | i_c_c, |
---|
395 | p_c_c, |
---|
396 | d_p_c, |
---|
397 | theory_child] |
---|
398 | else: |
---|
399 | data_ctrl_list = self.list_cb_data[state_id] |
---|
400 | #This state is already display replace it contains |
---|
401 | data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list |
---|
402 | self.tree_ctrl.SetItemText(data_c, data_name) |
---|
403 | temp = (data_id, data_class, state_id) |
---|
404 | self.tree_ctrl.SetItemPyData(data_c, temp) |
---|
405 | self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class) |
---|
406 | self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % str(path)) |
---|
407 | self.tree_ctrl.DeleteChildren(d_p_c) |
---|
408 | for process in process_list: |
---|
409 | i_t_c = self.tree_ctrl.AppendItem(d_p_c, |
---|
410 | process.__str__()) |
---|
411 | self.append_theory(state_id, theory_list) |
---|
412 | #self.enable_remove() |
---|
413 | self.enable_import() |
---|
414 | self.enable_plot() |
---|
415 | self.enable_freeze() |
---|
416 | self.enable_selection() |
---|
417 | |
---|
418 | def _uncheck_all(self): |
---|
419 | """ |
---|
420 | Uncheck all check boxes |
---|
421 | """ |
---|
422 | for item in self.list_cb_data.values(): |
---|
423 | data_ctrl, _, _, _,_, _ = item |
---|
424 | self.tree_ctrl.CheckItem(data_ctrl, False) |
---|
425 | self.enable_append() |
---|
426 | self.enable_freeze() |
---|
427 | self.enable_plot() |
---|
428 | self.enable_import() |
---|
429 | #self.enable_remove() |
---|
430 | |
---|
431 | def append_theory(self, state_id, theory_list): |
---|
432 | """ |
---|
433 | append theory object under data from a state of id = state_id |
---|
434 | replace that theory if already displayed |
---|
435 | """ |
---|
436 | if not theory_list: |
---|
437 | return |
---|
438 | if state_id not in self.list_cb_data.keys(): |
---|
439 | root = self.tree_ctrl_theory.root |
---|
440 | tree = self.tree_ctrl_theory |
---|
441 | else: |
---|
442 | item = self.list_cb_data[state_id] |
---|
443 | data_c, _, _, _, _, _ = item |
---|
444 | root = data_c |
---|
445 | tree = self.tree_ctrl |
---|
446 | if root is not None: |
---|
447 | self.append_theory_helper(tree=tree, root=root, |
---|
448 | state_id=state_id, |
---|
449 | theory_list=theory_list) |
---|
450 | |
---|
451 | |
---|
452 | def append_theory_helper(self, tree, root, state_id, theory_list): |
---|
453 | """ |
---|
454 | """ |
---|
455 | if state_id in self.list_cb_theory.keys(): |
---|
456 | #update current list of theory for this data |
---|
457 | theory_list_ctrl = self.list_cb_theory[state_id] |
---|
458 | |
---|
459 | for theory_id, item in theory_list.iteritems(): |
---|
460 | theory_data, theory_state = item |
---|
461 | if theory_data is None: |
---|
462 | name = "Unknown" |
---|
463 | theory_class = "Unknown" |
---|
464 | theory_id = "Unknown" |
---|
465 | temp = (None, None, None) |
---|
466 | else: |
---|
467 | name = theory_data.name |
---|
468 | theory_class = theory_data.__class__.__name__ |
---|
469 | theory_id = theory_data.id |
---|
470 | #if theory_state is not None: |
---|
471 | # name = theory_state.model.name |
---|
472 | temp = (theory_id, theory_class, state_id) |
---|
473 | if theory_id not in theory_list_ctrl: |
---|
474 | #add new theory |
---|
475 | t_child = tree.AppendItem(root, |
---|
476 | name, ct_type=1, data=temp) |
---|
477 | t_i_c = tree.AppendItem(t_child, 'Info') |
---|
478 | i_c_c = tree.AppendItem(t_i_c, |
---|
479 | 'Type: %s' % theory_class) |
---|
480 | t_p_c = tree.AppendItem(t_i_c, 'Process') |
---|
481 | |
---|
482 | for process in theory_data.process: |
---|
483 | i_t_c = tree.AppendItem(t_p_c, |
---|
484 | process.__str__()) |
---|
485 | theory_list_ctrl[theory_id] = [t_child, |
---|
486 | i_c_c, |
---|
487 | t_p_c] |
---|
488 | else: |
---|
489 | #replace theory |
---|
490 | t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id] |
---|
491 | tree.SetItemText(t_child, name) |
---|
492 | tree.SetItemPyData(t_child, temp) |
---|
493 | tree.SetItemText(i_c_c, 'Type: %s' % theory_class) |
---|
494 | tree.DeleteChildren(t_p_c) |
---|
495 | for process in theory_data.process: |
---|
496 | i_t_c = tree.AppendItem(t_p_c, |
---|
497 | process.__str__()) |
---|
498 | |
---|
499 | else: |
---|
500 | #data didn't have a theory associated it before |
---|
501 | theory_list_ctrl = {} |
---|
502 | for theory_id, item in theory_list.iteritems(): |
---|
503 | theory_data, theory_state = item |
---|
504 | if theory_data is not None: |
---|
505 | name = theory_data.name |
---|
506 | theory_class = theory_data.__class__.__name__ |
---|
507 | theory_id = theory_data.id |
---|
508 | #if theory_state is not None: |
---|
509 | # name = theory_state.model.name |
---|
510 | temp = (theory_id, theory_class, state_id) |
---|
511 | t_child = tree.AppendItem(root, |
---|
512 | name, ct_type=1, |
---|
513 | data=(theory_data.id, theory_class, state_id)) |
---|
514 | t_i_c = tree.AppendItem(t_child, 'Info') |
---|
515 | i_c_c = tree.AppendItem(t_i_c, |
---|
516 | 'Type: %s' % theory_class) |
---|
517 | t_p_c = tree.AppendItem(t_i_c, 'Process') |
---|
518 | |
---|
519 | for process in theory_data.process: |
---|
520 | i_t_c = tree.AppendItem(t_p_c, |
---|
521 | process.__str__()) |
---|
522 | |
---|
523 | theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] |
---|
524 | #self.list_cb_theory[data_id] = theory_list_ctrl |
---|
525 | self.list_cb_theory[state_id] = theory_list_ctrl |
---|
526 | |
---|
527 | |
---|
528 | |
---|
529 | def set_data_helper(self): |
---|
530 | """ |
---|
531 | """ |
---|
532 | data_to_plot = [] |
---|
533 | state_to_plot = [] |
---|
534 | theory_to_plot = [] |
---|
535 | for value in self.list_cb_data.values(): |
---|
536 | item, _, _, _, _, _ = value |
---|
537 | if item.IsChecked(): |
---|
538 | data_id, _, state_id = self.tree_ctrl.GetItemPyData(item) |
---|
539 | data_to_plot.append(data_id) |
---|
540 | if state_id not in state_to_plot: |
---|
541 | state_to_plot.append(state_id) |
---|
542 | |
---|
543 | for theory_dict in self.list_cb_theory.values(): |
---|
544 | for key, value in theory_dict.iteritems(): |
---|
545 | item, _, _ = value |
---|
546 | if item.IsChecked(): |
---|
547 | theory_id, _, state_id = self.tree_ctrl.GetItemPyData(item) |
---|
548 | theory_to_plot.append(theory_id) |
---|
549 | if state_id not in state_to_plot: |
---|
550 | state_to_plot.append(state_id) |
---|
551 | return data_to_plot, theory_to_plot, state_to_plot |
---|
552 | |
---|
553 | def remove_by_id(self, id): |
---|
554 | """ |
---|
555 | """ |
---|
556 | for item in self.list_cb_data.values(): |
---|
557 | data_c, _, _, _, _, theory_child = item |
---|
558 | data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c) |
---|
559 | if id == data_id: |
---|
560 | self.tree_ctrl.Delete(data_c) |
---|
561 | del self.list_cb_data[state_id] |
---|
562 | del self.list_cb_theory[data_id] |
---|
563 | |
---|
564 | def load_error(self, error=None): |
---|
565 | """ |
---|
566 | Pop up an error message. |
---|
567 | |
---|
568 | :param error: details error message to be displayed |
---|
569 | """ |
---|
570 | message = "The data file you selected could not be loaded.\n" |
---|
571 | message += "Make sure the content of your file" |
---|
572 | message += " is properly formatted.\n\n" |
---|
573 | |
---|
574 | if error is not None: |
---|
575 | message += "When contacting the DANSE team, mention the" |
---|
576 | message += " following:\n%s" % str(error) |
---|
577 | dial = wx.MessageDialog(self.parent, message, 'Error Loading File', |
---|
578 | wx.OK | wx.ICON_EXCLAMATION) |
---|
579 | dial.ShowModal() |
---|
580 | |
---|
581 | def _load_data(self, event): |
---|
582 | """ |
---|
583 | Load data |
---|
584 | """ |
---|
585 | path = None |
---|
586 | if self._default_save_location == None: |
---|
587 | self._default_save_location = os.getcwd() |
---|
588 | |
---|
589 | cards = self.loader.get_wildcards() |
---|
590 | wlist = '|'.join(cards) |
---|
591 | style = wx.OPEN|wx.FD_MULTIPLE |
---|
592 | dlg = wx.FileDialog(self.parent, |
---|
593 | "Choose a file", |
---|
594 | self._default_save_location, "", |
---|
595 | wlist, |
---|
596 | style=style) |
---|
597 | if dlg.ShowModal() == wx.ID_OK: |
---|
598 | file_list = dlg.GetPaths() |
---|
599 | if len(file_list) >= 0 and not(file_list[0]is None): |
---|
600 | self._default_save_location = os.path.dirname(file_list[0]) |
---|
601 | path = self._default_save_location |
---|
602 | dlg.Destroy() |
---|
603 | |
---|
604 | if path is None or not file_list or file_list[0] is None: |
---|
605 | return |
---|
606 | self._get_data(file_list) |
---|
607 | |
---|
608 | def _get_data(self, path, format=None): |
---|
609 | """ |
---|
610 | """ |
---|
611 | message = "" |
---|
612 | log_msg = '' |
---|
613 | output = {} |
---|
614 | error_message = "" |
---|
615 | for p_file in path: |
---|
616 | basename = os.path.basename(p_file) |
---|
617 | root, extension = os.path.splitext(basename) |
---|
618 | if extension.lower() in EXTENSIONS: |
---|
619 | log_msg = "Data Loader cannot " |
---|
620 | log_msg += "load: %s\n" % str(p_file) |
---|
621 | log_msg += "Try File opening ...." |
---|
622 | logging.info(log_msg) |
---|
623 | continue |
---|
624 | |
---|
625 | try: |
---|
626 | temp = self.loader.load(p_file, format) |
---|
627 | if temp.__class__.__name__ == "list": |
---|
628 | for item in temp: |
---|
629 | data = self.parent.create_gui_data(item, p_file) |
---|
630 | output[data.id] = data |
---|
631 | else: |
---|
632 | data = self.parent.create_gui_data(temp, p_file) |
---|
633 | output[data.id] = data |
---|
634 | message = "Loading Data..." + str(p_file) + "\n" |
---|
635 | self.load_update(output=output, message=message) |
---|
636 | except: |
---|
637 | error_message = "Error while loading Data: %s\n" % str(p_file) |
---|
638 | error_message += str(sys.exc_value) + "\n" |
---|
639 | self.load_update(output=output, message=error_message) |
---|
640 | |
---|
641 | message = "Loading Data Complete! " |
---|
642 | message += log_msg |
---|
643 | self.load_complete(output=output, error_message=error_message, |
---|
644 | message=message, path=path) |
---|
645 | |
---|
646 | def load_update(self, output=None, message=""): |
---|
647 | """ |
---|
648 | print update on the status bar |
---|
649 | """ |
---|
650 | if message != "" and self.parent is not None: |
---|
651 | wx.PostEvent(self.parent, StatusEvent(status=message, |
---|
652 | type="progress", |
---|
653 | info="warning")) |
---|
654 | |
---|
655 | def load_complete(self, output, message="", error_message="", path=None): |
---|
656 | """ |
---|
657 | post message to status bar and return list of data |
---|
658 | """ |
---|
659 | if self.parent is not None: |
---|
660 | wx.PostEvent(self.parent, StatusEvent(status=message, |
---|
661 | info="warning", |
---|
662 | type="stop")) |
---|
663 | if error_message != "": |
---|
664 | self.load_error(error_message) |
---|
665 | if self.parent is not None: |
---|
666 | self.parent.add_data(data_list=output) |
---|
667 | |
---|
668 | def on_remove(self, event): |
---|
669 | """ |
---|
670 | Get a list of item checked and remove them from the treectrl |
---|
671 | Ask the parent to remove reference to this item |
---|
672 | """ |
---|
673 | data_to_remove, theory_to_remove, _ = self.set_data_helper() |
---|
674 | data_key = [] |
---|
675 | theory_key = [] |
---|
676 | #remove data from treectrl |
---|
677 | for d_key, item in self.list_cb_data.iteritems(): |
---|
678 | data_c, d_i_c, i_c_c, p_c_c, d_p_c, t_c = item |
---|
679 | if data_c.IsChecked(): |
---|
680 | self.tree_ctrl.Delete(data_c) |
---|
681 | data_key.append(d_key) |
---|
682 | if d_key in self.list_cb_theory.keys(): |
---|
683 | theory_list_ctrl = self.list_cb_theory[d_key] |
---|
684 | theory_to_remove += theory_list_ctrl.keys() |
---|
685 | # Remove theory from treectrl |
---|
686 | for t_key, theory_dict in self.list_cb_theory.iteritems(): |
---|
687 | for key, value in theory_dict.iteritems(): |
---|
688 | item, _, _ = value |
---|
689 | if item.IsChecked(): |
---|
690 | self.tree_ctrl.Delete(item) |
---|
691 | theory_key.append(key) |
---|
692 | #Remove data and related theory references |
---|
693 | for key in data_key: |
---|
694 | del self.list_cb_data[key] |
---|
695 | if key in theory_key: |
---|
696 | del self.list_cb_theory[key] |
---|
697 | #remove theory references independently of data |
---|
698 | for key in theory_key: |
---|
699 | for t_key, theory_dict in self.list_cb_theory.iteritems(): |
---|
700 | if key in theory_dict: |
---|
701 | del theory_dict[key] |
---|
702 | |
---|
703 | self.parent.remove_data(data_id=data_to_remove, |
---|
704 | theory_id=theory_to_remove) |
---|
705 | #self.enable_remove() |
---|
706 | self.enable_freeze() |
---|
707 | |
---|
708 | def on_import(self, event=None): |
---|
709 | """ |
---|
710 | Get all select data and set them to the current active perspetive |
---|
711 | """ |
---|
712 | data_id, theory_id, state_id = self.set_data_helper() |
---|
713 | self.parent.set_data(data_id) |
---|
714 | self.parent.set_data(data_id=state_id, theory_id=theory_id) |
---|
715 | |
---|
716 | def on_append_plot(self, event=None): |
---|
717 | """ |
---|
718 | append plot to plot panel on focus |
---|
719 | """ |
---|
720 | self._on_plot_selection() |
---|
721 | data_id, theory_id, state_id = self.set_data_helper() |
---|
722 | self.parent.plot_data(data_id=data_id, |
---|
723 | state_id=state_id, |
---|
724 | theory_id=theory_id, |
---|
725 | append=True) |
---|
726 | |
---|
727 | def on_plot(self, event=None): |
---|
728 | """ |
---|
729 | Send a list of data names to plot |
---|
730 | """ |
---|
731 | data_id, theory_id, state_id = self.set_data_helper() |
---|
732 | self.parent.plot_data(data_id=data_id, |
---|
733 | state_id=state_id, |
---|
734 | theory_id=theory_id, |
---|
735 | append=False) |
---|
736 | |
---|
737 | def on_close_page(self, event=None): |
---|
738 | """ |
---|
739 | On close |
---|
740 | """ |
---|
741 | if event != None: |
---|
742 | event.Skip() |
---|
743 | # send parent to update menu with no show nor hide action |
---|
744 | self.parent.show_data_panel(action=False) |
---|
745 | |
---|
746 | def on_freeze(self, event): |
---|
747 | """ |
---|
748 | """ |
---|
749 | _, theory_id, state_id = self.set_data_helper() |
---|
750 | self.parent.freeze(data_id=state_id, theory_id=theory_id) |
---|
751 | |
---|
752 | def set_active_perspective(self, name): |
---|
753 | """ |
---|
754 | set the active perspective |
---|
755 | """ |
---|
756 | self.perspective_cbox.SetStringSelection(name) |
---|
757 | self.enable_import() |
---|
758 | |
---|
759 | def set_panel_on_focus(self, name=None): |
---|
760 | """ |
---|
761 | set the plot panel on focus |
---|
762 | """ |
---|
763 | for key, value in self.parent.plot_panels.iteritems(): |
---|
764 | name_plot_panel = str(value.window_caption) |
---|
765 | if name_plot_panel not in self.cb_plotpanel.GetItems(): |
---|
766 | self.cb_plotpanel.Append(name_plot_panel, value) |
---|
767 | if name != None and name == name_plot_panel: |
---|
768 | self.cb_plotpanel.SetStringSelection(name_plot_panel) |
---|
769 | break |
---|
770 | self.enable_append() |
---|
771 | |
---|
772 | def _on_perspective_selection(self, event=None): |
---|
773 | """ |
---|
774 | select the current perspective for guiframe |
---|
775 | """ |
---|
776 | selection = self.perspective_cbox.GetSelection() |
---|
777 | |
---|
778 | if self.perspective_cbox.GetValue() != 'None': |
---|
779 | perspective = self.perspective_cbox.GetClientData(selection) |
---|
780 | perspective.on_perspective(event=None) |
---|
781 | |
---|
782 | def _on_plot_selection(self, event = None): |
---|
783 | """ |
---|
784 | On source combobox selection |
---|
785 | """ |
---|
786 | if event != None: |
---|
787 | combo = event.GetEventObject() |
---|
788 | event.Skip() |
---|
789 | else: |
---|
790 | combo = self.cb_plotpanel |
---|
791 | selection = combo.GetSelection() |
---|
792 | |
---|
793 | if combo.GetValue() != 'None': |
---|
794 | panel = combo.GetClientData(selection) |
---|
795 | self.parent.on_set_plot_focus(panel) |
---|
796 | |
---|
797 | def enable_remove(self): |
---|
798 | """ |
---|
799 | enable or disable remove button |
---|
800 | """ |
---|
801 | n_t = self.tree_ctrl.GetCount() |
---|
802 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
803 | if n_t + n_t_t <= 0: |
---|
804 | self.bt_remove.Disable() |
---|
805 | else: |
---|
806 | self.bt_remove.Enable() |
---|
807 | |
---|
808 | def enable_import(self): |
---|
809 | """ |
---|
810 | enable or disable send button |
---|
811 | """ |
---|
812 | n_t = 0 |
---|
813 | if self.tree_ctrl != None: |
---|
814 | n_t = self.tree_ctrl.GetCount() |
---|
815 | if n_t > 0 and len(self.list_of_perspective) > 0: |
---|
816 | self.bt_import.Enable() |
---|
817 | else: |
---|
818 | self.bt_import.Disable() |
---|
819 | if len(self.list_of_perspective) <= 0 or \ |
---|
820 | self.perspective_cbox.GetValue() in ["None", |
---|
821 | "No Active Application"]: |
---|
822 | self.perspective_cbox.Disable() |
---|
823 | else: |
---|
824 | self.perspective_cbox.Enable() |
---|
825 | |
---|
826 | def enable_plot(self): |
---|
827 | """ |
---|
828 | enable or disable plot button |
---|
829 | """ |
---|
830 | n_t = 0 |
---|
831 | n_t_t = 0 |
---|
832 | if self.tree_ctrl != None: |
---|
833 | n_t = self.tree_ctrl.GetCount() |
---|
834 | if self.tree_ctrl_theory != None: |
---|
835 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
836 | if n_t + n_t_t <= 0: |
---|
837 | self.bt_plot.Disable() |
---|
838 | else: |
---|
839 | self.bt_plot.Enable() |
---|
840 | self.enable_append() |
---|
841 | |
---|
842 | def enable_append(self): |
---|
843 | """ |
---|
844 | enable or disable append button |
---|
845 | """ |
---|
846 | n_t = 0 |
---|
847 | n_t_t = 0 |
---|
848 | if self.tree_ctrl != None: |
---|
849 | n_t = self.tree_ctrl.GetCount() |
---|
850 | if self.tree_ctrl_theory != None: |
---|
851 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
852 | if n_t + n_t_t <= 0: |
---|
853 | self.bt_append_plot.Disable() |
---|
854 | self.cb_plotpanel.Disable() |
---|
855 | elif self.cb_plotpanel.GetCount() <= 0: |
---|
856 | self.cb_plotpanel.Disable() |
---|
857 | self.bt_append_plot.Disable() |
---|
858 | else: |
---|
859 | self.bt_append_plot.Enable() |
---|
860 | self.cb_plotpanel.Enable() |
---|
861 | |
---|
862 | def check_theory_to_freeze(self): |
---|
863 | """ |
---|
864 | """ |
---|
865 | def enable_freeze(self): |
---|
866 | """ |
---|
867 | enable or disable the freeze button |
---|
868 | """ |
---|
869 | n_t_t = 0 |
---|
870 | n_l = 0 |
---|
871 | if self.tree_ctrl_theory != None: |
---|
872 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
873 | n_l = len(self.list_cb_theory) |
---|
874 | if (n_t_t + n_l > 0): |
---|
875 | self.bt_freeze.Enable() |
---|
876 | else: |
---|
877 | self.bt_freeze.Disable() |
---|
878 | |
---|
879 | def enable_selection(self): |
---|
880 | """ |
---|
881 | enable or disable combobo box selection |
---|
882 | """ |
---|
883 | n_t = 0 |
---|
884 | n_t_t = 0 |
---|
885 | if self.tree_ctrl != None: |
---|
886 | n_t = self.tree_ctrl.GetCount() |
---|
887 | if self.tree_ctrl_theory != None: |
---|
888 | n_t_t = self.tree_ctrl_theory.GetCount() |
---|
889 | if n_t + n_t_t > 0 and self.selection_cbox != None: |
---|
890 | self.selection_cbox.Enable() |
---|
891 | else: |
---|
892 | self.selection_cbox.Disable() |
---|
893 | |
---|
894 | |
---|
895 | |
---|
896 | class DataFrame(wx.Frame): |
---|
897 | ## Internal name for the AUI manager |
---|
898 | window_name = "Data Panel" |
---|
899 | ## Title to appear on top of the window |
---|
900 | window_caption = "Data Panel" |
---|
901 | ## Flag to tell the GUI manager that this panel is not |
---|
902 | # tied to any perspective |
---|
903 | ALWAYS_ON = True |
---|
904 | |
---|
905 | def __init__(self, parent=None, owner=None, manager=None,size=(300, 800), |
---|
906 | list_of_perspective=[],list=[], *args, **kwds): |
---|
907 | kwds['size'] = size |
---|
908 | kwds['id'] = -1 |
---|
909 | kwds['title']= "Loaded Data" |
---|
910 | wx.Frame.__init__(self, parent=parent, *args, **kwds) |
---|
911 | self.parent = parent |
---|
912 | self.owner = owner |
---|
913 | self.manager = manager |
---|
914 | self.panel = DataPanel(parent=self, |
---|
915 | #size=size, |
---|
916 | list_of_perspective=list_of_perspective) |
---|
917 | |
---|
918 | def load_data_list(self, list=[]): |
---|
919 | """ |
---|
920 | Fill the list inside its panel |
---|
921 | """ |
---|
922 | self.panel.load_data_list(list=list) |
---|
923 | |
---|
924 | |
---|
925 | |
---|
926 | from dataFitting import Data1D |
---|
927 | from dataFitting import Data2D, Theory1D |
---|
928 | from data_state import DataState |
---|
929 | import sys |
---|
930 | class State(): |
---|
931 | def __init__(self): |
---|
932 | self.msg = "" |
---|
933 | def __str__(self): |
---|
934 | self.msg = "model mane : model1\n" |
---|
935 | self.msg += "params : \n" |
---|
936 | self.msg += "name value\n" |
---|
937 | return msg |
---|
938 | def set_data_state(data=None, path=None, theory=None, state=None): |
---|
939 | dstate = DataState(data=data) |
---|
940 | dstate.set_path(path=path) |
---|
941 | dstate.set_theory(theory, state) |
---|
942 | |
---|
943 | return dstate |
---|
944 | """' |
---|
945 | data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"), |
---|
946 | ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"), |
---|
947 | ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"), |
---|
948 | ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"), |
---|
949 | ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")] |
---|
950 | """ |
---|
951 | if __name__ == "__main__": |
---|
952 | |
---|
953 | app = wx.App() |
---|
954 | try: |
---|
955 | list_of_perspective = [('perspective2', False), ('perspective1', True)] |
---|
956 | data_list = {} |
---|
957 | # state 1 |
---|
958 | data = Data2D() |
---|
959 | data.name = "data2" |
---|
960 | data.id = 1 |
---|
961 | data.append_empty_process() |
---|
962 | process = data.process[len(data.process)-1] |
---|
963 | process.data = "07/01/2010" |
---|
964 | theory = Data2D() |
---|
965 | theory.id = 34 |
---|
966 | theory.name = "theory1" |
---|
967 | path = "path1" |
---|
968 | state = State() |
---|
969 | data_list['1']=set_data_state(data, path,theory, state) |
---|
970 | #state 2 |
---|
971 | data = Data2D() |
---|
972 | data.name = "data2" |
---|
973 | data.id = 76 |
---|
974 | theory = Data2D() |
---|
975 | theory.id = 78 |
---|
976 | theory.name = "CoreShell 07/24/25" |
---|
977 | path = "path2" |
---|
978 | #state3 |
---|
979 | state = State() |
---|
980 | data_list['2']=set_data_state(data, path,theory, state) |
---|
981 | data = Data1D() |
---|
982 | data.id = 3 |
---|
983 | data.name = "data2" |
---|
984 | theory = Theory1D() |
---|
985 | theory.name = "CoreShell" |
---|
986 | theory.id = 4 |
---|
987 | theory.append_empty_process() |
---|
988 | process = theory.process[len(theory.process)-1] |
---|
989 | process.description = "this is my description" |
---|
990 | path = "path3" |
---|
991 | data.append_empty_process() |
---|
992 | process = data.process[len(data.process)-1] |
---|
993 | process.data = "07/22/2010" |
---|
994 | data_list['4']=set_data_state(data, path,theory, state) |
---|
995 | #state 4 |
---|
996 | temp_data_list = {} |
---|
997 | data.name = "data5 erasing data2" |
---|
998 | temp_data_list['4'] = set_data_state(data, path,theory, state) |
---|
999 | #state 5 |
---|
1000 | data = Data2D() |
---|
1001 | data.name = "data3" |
---|
1002 | data.id = 5 |
---|
1003 | data.append_empty_process() |
---|
1004 | process = data.process[len(data.process)-1] |
---|
1005 | process.data = "07/01/2010" |
---|
1006 | theory = Theory1D() |
---|
1007 | theory.name = "Cylinder" |
---|
1008 | path = "path2" |
---|
1009 | state = State() |
---|
1010 | dstate= set_data_state(data, path,theory, state) |
---|
1011 | theory = Theory1D() |
---|
1012 | theory.id = 6 |
---|
1013 | theory.name = "CoreShell" |
---|
1014 | dstate.set_theory(theory) |
---|
1015 | theory = Theory1D() |
---|
1016 | theory.id = 6 |
---|
1017 | theory.name = "CoreShell replacing coreshell in data3" |
---|
1018 | dstate.set_theory(theory) |
---|
1019 | data_list['3'] = dstate |
---|
1020 | #state 6 |
---|
1021 | data_list['6']=set_data_state(None, path,theory, state) |
---|
1022 | data_list['6']=set_data_state(theory=theory, state=None) |
---|
1023 | theory = Theory1D() |
---|
1024 | theory.id = 7 |
---|
1025 | data_list['6']=set_data_state(theory=theory, state=None) |
---|
1026 | data_list['7']=set_data_state(theory=theory, state=None) |
---|
1027 | window = DataFrame(list=data_list) |
---|
1028 | window.load_data_list(list=data_list) |
---|
1029 | window.Show(True) |
---|
1030 | window.load_data_list(list=temp_data_list) |
---|
1031 | except: |
---|
1032 | #raise |
---|
1033 | print "error",sys.exc_value |
---|
1034 | |
---|
1035 | app.MainLoop() |
---|
1036 | |
---|
1037 | |
---|