1 | |
---|
2 | import sys, os |
---|
3 | import wx |
---|
4 | import numpy |
---|
5 | import time |
---|
6 | import copy |
---|
7 | from sans.guiframe.utils import format_number,check_float |
---|
8 | from sans.guicomm.events import StatusEvent |
---|
9 | import pagestate |
---|
10 | from pagestate import PageState |
---|
11 | (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() |
---|
12 | (PreviousStateEvent, EVT_PREVIOUS_STATE) = wx.lib.newevent.NewEvent() |
---|
13 | (NextStateEvent, EVT_NEXT_STATE) = wx.lib.newevent.NewEvent() |
---|
14 | _BOX_WIDTH = 80 |
---|
15 | |
---|
16 | class BasicPage(wx.ScrolledWindow): |
---|
17 | """ |
---|
18 | This class provide general structure of fitpanel page |
---|
19 | """ |
---|
20 | ## Internal name for the AUI manager |
---|
21 | window_name = "Basic Page" |
---|
22 | ## Title to appear on top of the window |
---|
23 | window_caption = "Basic page " |
---|
24 | |
---|
25 | def __init__(self,parent, page_info): |
---|
26 | wx.ScrolledWindow.__init__(self, parent, |
---|
27 | style= wx.FULL_REPAINT_ON_RESIZE ) |
---|
28 | ##window_name |
---|
29 | self.window_name = page_info.window_name |
---|
30 | ##window_caption |
---|
31 | self.window_caption = page_info.window_caption |
---|
32 | ## parent of the page |
---|
33 | self.parent = parent |
---|
34 | ## manager is the fitting plugin |
---|
35 | self.manager= page_info.manager |
---|
36 | ## owner of the page (fitting plugin) |
---|
37 | self.event_owner= page_info.event_owner |
---|
38 | ## current model |
---|
39 | self.model = page_info.model |
---|
40 | ## data |
---|
41 | self.data = page_info.data |
---|
42 | ## dictionary containing list of models |
---|
43 | self.model_list_box = page_info.model_list_box |
---|
44 | ## Data member to store the dispersion object created |
---|
45 | self._disp_obj_dict = {} |
---|
46 | ## selected parameters to apply dispersion |
---|
47 | self.disp_cb_dict ={} |
---|
48 | ## smearer object |
---|
49 | self.smearer = None |
---|
50 | |
---|
51 | ##list of model parameters. each item must have same length |
---|
52 | ## each item related to a given parameters |
---|
53 | ##[cb state, name, value, "+/-", error of fit, min, max , units] |
---|
54 | self.parameters=[] |
---|
55 | ## list of parameters to fit , must be like self.parameters |
---|
56 | self.param_toFit=[] |
---|
57 | ## list of looking like parameters but with non fittable parameters info |
---|
58 | self.fixed_param=[] |
---|
59 | ## list of looking like parameters but with fittable parameters info |
---|
60 | self.fittable_param=[] |
---|
61 | ##list of dispersion parameters |
---|
62 | self.disp_list=[] |
---|
63 | ## list of orientation parameters |
---|
64 | self.orientation_params=[] |
---|
65 | self.orientation_params_disp=[] |
---|
66 | if self.model !=None: |
---|
67 | self.disp_list= self.model.getDispParamList() |
---|
68 | |
---|
69 | ##enable model 2D draw |
---|
70 | self.enable2D= False |
---|
71 | ## check that the fit range is correct to plot the model again |
---|
72 | self.fitrange= True |
---|
73 | ## Q range |
---|
74 | self.qmin_x= 0.0001 |
---|
75 | self.qmax_x= 0.13 |
---|
76 | self.num_points= 50 |
---|
77 | |
---|
78 | ## Create memento to save the current state |
---|
79 | self.state= PageState(parent= self.parent,model=self.model, data=self.data) |
---|
80 | ## flag to determine if state has change |
---|
81 | self.state_change= False |
---|
82 | ## save customized array |
---|
83 | self.values=[] |
---|
84 | self.weights=[] |
---|
85 | ## retrieve saved state |
---|
86 | self.number_saved_state= 0 |
---|
87 | ## dictionary of saved state |
---|
88 | self.saved_states={} |
---|
89 | |
---|
90 | ## Create context menu for page |
---|
91 | self.popUpMenu = wx.Menu() |
---|
92 | id = wx.NewId() |
---|
93 | self._undo = wx.MenuItem(self.popUpMenu,id, "Undo","cancel the previous action") |
---|
94 | self.popUpMenu.AppendItem(self._undo) |
---|
95 | self._undo.Enable(False) |
---|
96 | wx.EVT_MENU(self, id, self.onUndo) |
---|
97 | |
---|
98 | id = wx.NewId() |
---|
99 | self._redo = wx.MenuItem(self.popUpMenu,id,"Redo"," Restore the previous action") |
---|
100 | self.popUpMenu.AppendItem(self._redo) |
---|
101 | self._redo.Enable(False) |
---|
102 | wx.EVT_MENU(self, id, self.onRedo) |
---|
103 | |
---|
104 | ## Default locations |
---|
105 | self._default_save_location = os.getcwd() |
---|
106 | ## save initial state on context menu |
---|
107 | #self.onSave(event=None) |
---|
108 | self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) |
---|
109 | |
---|
110 | ## create the basic structure of the panel with empty sizer |
---|
111 | self.define_page_structure() |
---|
112 | ## drawing Initial dispersion parameters sizer |
---|
113 | self.set_dispers_sizer() |
---|
114 | self._fill_save_sizer() |
---|
115 | ## layout |
---|
116 | self.set_layout() |
---|
117 | |
---|
118 | |
---|
119 | def onContextMenu(self, event): |
---|
120 | """ |
---|
121 | Retrieve the state selected state |
---|
122 | """ |
---|
123 | # Skipping the save state functionality for release 0.9.0 |
---|
124 | #return |
---|
125 | |
---|
126 | pos = event.GetPosition() |
---|
127 | pos = self.ScreenToClient(pos) |
---|
128 | |
---|
129 | self.PopupMenu(self.popUpMenu, pos) |
---|
130 | |
---|
131 | |
---|
132 | def onUndo(self, event): |
---|
133 | """ |
---|
134 | Cancel the previous action |
---|
135 | """ |
---|
136 | print "enable undo" |
---|
137 | event = PreviousStateEvent(page = self) |
---|
138 | wx.PostEvent(self.parent, event) |
---|
139 | |
---|
140 | |
---|
141 | def onRedo(self, event): |
---|
142 | """ |
---|
143 | Restore the previous action cancelled |
---|
144 | """ |
---|
145 | print "enable redo" |
---|
146 | event = NextStateEvent(page= self) |
---|
147 | wx.PostEvent(self.parent, event) |
---|
148 | |
---|
149 | |
---|
150 | def define_page_structure(self): |
---|
151 | """ |
---|
152 | Create empty sizer for a panel |
---|
153 | """ |
---|
154 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
155 | self.sizer0 = wx.BoxSizer(wx.VERTICAL) |
---|
156 | self.sizer1 = wx.BoxSizer(wx.VERTICAL) |
---|
157 | self.sizer2 = wx.BoxSizer(wx.VERTICAL) |
---|
158 | self.sizer3 = wx.BoxSizer(wx.VERTICAL) |
---|
159 | self.sizer4 = wx.BoxSizer(wx.VERTICAL) |
---|
160 | self.sizer5 = wx.BoxSizer(wx.VERTICAL) |
---|
161 | self.sizer6 = wx.BoxSizer(wx.VERTICAL) |
---|
162 | |
---|
163 | self.sizer0.SetMinSize((375,-1)) |
---|
164 | self.sizer1.SetMinSize((375,-1)) |
---|
165 | self.sizer2.SetMinSize((375,-1)) |
---|
166 | self.sizer3.SetMinSize((375,-1)) |
---|
167 | self.sizer4.SetMinSize((375,-1)) |
---|
168 | self.sizer5.SetMinSize((375,-1)) |
---|
169 | self.sizer6.SetMinSize((375,-1)) |
---|
170 | |
---|
171 | self.vbox.Add(self.sizer0) |
---|
172 | self.vbox.Add(self.sizer1) |
---|
173 | self.vbox.Add(self.sizer2) |
---|
174 | self.vbox.Add(self.sizer3) |
---|
175 | self.vbox.Add(self.sizer4) |
---|
176 | self.vbox.Add(self.sizer5) |
---|
177 | self.vbox.Add(self.sizer6) |
---|
178 | |
---|
179 | |
---|
180 | def set_layout(self): |
---|
181 | """ |
---|
182 | layout |
---|
183 | """ |
---|
184 | self.vbox.Layout() |
---|
185 | self.vbox.Fit(self) |
---|
186 | self.SetSizer(self.vbox) |
---|
187 | |
---|
188 | self.set_scroll() |
---|
189 | self.Centre() |
---|
190 | |
---|
191 | |
---|
192 | def set_scroll(self): |
---|
193 | self.SetScrollbars(20,20,200,100) |
---|
194 | self.Layout() |
---|
195 | self.SetAutoLayout(True) |
---|
196 | |
---|
197 | |
---|
198 | def set_owner(self,owner): |
---|
199 | """ |
---|
200 | set owner of fitpage |
---|
201 | @param owner: the class responsible of plotting |
---|
202 | """ |
---|
203 | self.event_owner = owner |
---|
204 | self.state.event_owner = owner |
---|
205 | |
---|
206 | def set_manager(self, manager): |
---|
207 | """ |
---|
208 | set panel manager |
---|
209 | @param manager: instance of plugin fitting |
---|
210 | """ |
---|
211 | self.manager = manager |
---|
212 | self.state.manager = manager |
---|
213 | |
---|
214 | def populate_box(self, dict): |
---|
215 | """ |
---|
216 | Store list of model |
---|
217 | @param dict: dictionary containing list of models |
---|
218 | """ |
---|
219 | self.model_list_box = dict |
---|
220 | self.state.model_list_box = self.model_list_box |
---|
221 | |
---|
222 | |
---|
223 | |
---|
224 | def set_dispers_sizer(self): |
---|
225 | """ |
---|
226 | fill sizer containing dispersity info |
---|
227 | """ |
---|
228 | self.sizer4.Clear(True) |
---|
229 | name="Polydispersity and Orientational Distribution" |
---|
230 | box_description= wx.StaticBox(self, -1,name) |
---|
231 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
232 | #---------------------------------------------------- |
---|
233 | self.disable_disp = wx.RadioButton(self, -1, 'Off', (10, 10), style=wx.RB_GROUP) |
---|
234 | self.enable_disp = wx.RadioButton(self, -1, 'On', (10, 30)) |
---|
235 | |
---|
236 | |
---|
237 | self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, id=self.disable_disp.GetId()) |
---|
238 | self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, id=self.enable_disp.GetId()) |
---|
239 | |
---|
240 | sizer_dispersion = wx.BoxSizer(wx.HORIZONTAL) |
---|
241 | sizer_dispersion.Add((20,20)) |
---|
242 | name=""#Polydispersity and \nOrientational Distribution " |
---|
243 | sizer_dispersion.Add(wx.StaticText(self,-1,name)) |
---|
244 | sizer_dispersion.Add(self.enable_disp ) |
---|
245 | sizer_dispersion.Add((20,20)) |
---|
246 | sizer_dispersion.Add(self.disable_disp ) |
---|
247 | sizer_dispersion.Add((10,10)) |
---|
248 | |
---|
249 | ## fill a sizer with the combobox to select dispersion type |
---|
250 | sizer_select_dispers = wx.BoxSizer(wx.HORIZONTAL) |
---|
251 | self.model_disp = wx.StaticText(self, -1, 'Distribution Function ') |
---|
252 | |
---|
253 | import sans.models.dispersion_models |
---|
254 | self.polydisp= sans.models.dispersion_models.models |
---|
255 | self.disp_box = wx.ComboBox(self, -1) |
---|
256 | |
---|
257 | for key in self.polydisp.iterkeys(): |
---|
258 | name = str(key.__name__) |
---|
259 | if name=="ArrayDispersion": |
---|
260 | # Remove the option until the rest of the code is ready for it |
---|
261 | self.disp_box.Append("Select customized Model",key) |
---|
262 | |
---|
263 | else: |
---|
264 | self.disp_box.Append(name,key) |
---|
265 | self.disp_box.SetSelection(0) |
---|
266 | |
---|
267 | wx.EVT_COMBOBOX(self.disp_box,-1, self._on_select_Disp) |
---|
268 | |
---|
269 | sizer_select_dispers.Add((10,10)) |
---|
270 | sizer_select_dispers.Add(self.model_disp) |
---|
271 | sizer_select_dispers.Add(self.disp_box,0, |
---|
272 | wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,border=5) |
---|
273 | #sizer_select_dispers.Add((10,10)) |
---|
274 | self.model_disp.Hide() |
---|
275 | self.disp_box.Hide() |
---|
276 | |
---|
277 | boxsizer1.Add( sizer_dispersion,0, |
---|
278 | wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,border=5) |
---|
279 | #boxsizer1.Add( (10,10) ) |
---|
280 | boxsizer1.Add( sizer_select_dispers ) |
---|
281 | self.sizer4_4 = wx.GridBagSizer(5,5) |
---|
282 | boxsizer1.Add( self.sizer4_4 ) |
---|
283 | #----------------------------------------------------- |
---|
284 | self.sizer4.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
285 | self.sizer4_4.Layout() |
---|
286 | self.sizer4.Layout() |
---|
287 | self.Layout() |
---|
288 | self.SetScrollbars(20,20,200,100) |
---|
289 | self.Refresh() |
---|
290 | ## saving the state of enable dispersity button |
---|
291 | self.state.enable_disp= self.enable_disp.GetValue() |
---|
292 | self.state.disable_disp= self.disable_disp.GetValue() |
---|
293 | |
---|
294 | |
---|
295 | def select_disp_angle(self, event): |
---|
296 | """ |
---|
297 | Event for when a user select a parameter to average over. |
---|
298 | @param event: check box event |
---|
299 | """ |
---|
300 | self.values=[] |
---|
301 | self.weights=[] |
---|
302 | # Go through the list of dispersion check boxes to identify which one has changed |
---|
303 | for p in self.disp_cb_dict: |
---|
304 | # Catch which one of the box was just checked or unchecked. |
---|
305 | if event.GetEventObject() == self.disp_cb_dict[p]: |
---|
306 | |
---|
307 | |
---|
308 | if self.disp_cb_dict[p].GetValue() == True: |
---|
309 | # The user wants this parameter to be averaged. |
---|
310 | # Pop up the file selection dialog. |
---|
311 | path = self._selectDlg() |
---|
312 | |
---|
313 | # If nothing was selected, just return |
---|
314 | if path is None: |
---|
315 | self.disp_cb_dict[p].SetValue(False) |
---|
316 | return |
---|
317 | try: |
---|
318 | self._default_save_location = os.path.dirname(path) |
---|
319 | except: |
---|
320 | pass |
---|
321 | try: |
---|
322 | self.values,self.weights = self.read_file(path) |
---|
323 | except: |
---|
324 | msg="Could not read input file" |
---|
325 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg)) |
---|
326 | return |
---|
327 | |
---|
328 | # If any of the two arrays is empty, notify the user that we won't |
---|
329 | # proceed |
---|
330 | if self.values is None or self.weights is None or \ |
---|
331 | self.values ==[] or self.weights ==[]: |
---|
332 | wx.PostEvent(self.parent.parent, StatusEvent(status=\ |
---|
333 | "The loaded %s distrubtion is corrupted or empty" % p)) |
---|
334 | return |
---|
335 | |
---|
336 | # Tell the user that we are about to apply the distribution |
---|
337 | wx.PostEvent(self.parent.parent, StatusEvent(status=\ |
---|
338 | "Applying loaded %s distribution: %s" % (p, path))) |
---|
339 | |
---|
340 | # Create the dispersion objects |
---|
341 | from sans.models.dispersion_models import ArrayDispersion |
---|
342 | disp_model = ArrayDispersion() |
---|
343 | disp_model.set_weights(self.values, self.weights) |
---|
344 | |
---|
345 | # Store the object to make it persist outside the scope of this method |
---|
346 | #TODO: refactor model to clean this up? |
---|
347 | self._disp_obj_dict[p] = disp_model |
---|
348 | self.state._disp_obj_dict [p]= disp_model |
---|
349 | self.state.values=[] |
---|
350 | self.state.weights=[] |
---|
351 | self.state.values = self.values |
---|
352 | self.state.weights = self.weights |
---|
353 | # Set the new model as the dispersion object for the selected parameter |
---|
354 | self.model.set_dispersion(p, disp_model) |
---|
355 | # Store a reference to the weights in the model object so that |
---|
356 | # it's not lost when we use the model within another thread. |
---|
357 | #TODO: total hack - fix this |
---|
358 | self.state.model= self.model.clone() |
---|
359 | #if not hasattr(self.model, "_persistency_dict"): |
---|
360 | self.model._persistency_dict = {} |
---|
361 | self.model._persistency_dict[p] = [self.values, self.weights] |
---|
362 | self.state.model._persistency_dict[p] = [self.values, self.weights] |
---|
363 | else: |
---|
364 | # The parameter was un-selected. Go back to Gaussian model (with 0 pts) |
---|
365 | self._reset_dispersity() |
---|
366 | |
---|
367 | ## Redraw the model |
---|
368 | |
---|
369 | self._draw_model() |
---|
370 | ## post state to fit panel |
---|
371 | |
---|
372 | self.state.disp_cb_dict[p]= self.disp_cb_dict[p].GetValue() |
---|
373 | #event = PageInfoEvent(page = self) |
---|
374 | #wx.PostEvent(self.parent, event) |
---|
375 | return |
---|
376 | |
---|
377 | |
---|
378 | def onResetModel(self, event): |
---|
379 | """ |
---|
380 | Reset model state |
---|
381 | """ |
---|
382 | ## post help message for the selected model |
---|
383 | msg = self.popUpMenu.GetHelpString(event.GetId()) |
---|
384 | msg +=" reloaded" |
---|
385 | wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) |
---|
386 | |
---|
387 | name= self.popUpMenu.GetLabel(event.GetId()) |
---|
388 | if name in self.saved_states.keys(): |
---|
389 | previous_state = self.saved_states[name] |
---|
390 | self.reset_page(previous_state) |
---|
391 | |
---|
392 | |
---|
393 | def onSave(self, event): |
---|
394 | """ |
---|
395 | save history of the data and model |
---|
396 | """ |
---|
397 | |
---|
398 | if self.model==None: |
---|
399 | return |
---|
400 | if hasattr(self,"enable_disp"): |
---|
401 | self.state.enable_disp = copy.deepcopy(self.enable_disp.GetValue()) |
---|
402 | if hasattr(self, "disp_box"): |
---|
403 | self.state.disp_box = copy.deepcopy(self.disp_box.GetSelection()) |
---|
404 | |
---|
405 | self.state.model = self.model.clone() |
---|
406 | #if not hasattr(self.model, "_persistency_dict"): |
---|
407 | #self.model._persistency_dict = {} |
---|
408 | #self.state.model._persistency_dict= copy.deepcopy(self.model._persistency_dict) |
---|
409 | |
---|
410 | new_state = self.state.clone() |
---|
411 | new_state.enable2D = copy.deepcopy(self.enable2D) |
---|
412 | ##Add model state on context menu |
---|
413 | self.number_saved_state += 1 |
---|
414 | name= self.model.name+"[%g]"%self.number_saved_state |
---|
415 | self.saved_states[name]= new_state |
---|
416 | |
---|
417 | ## Add item in the context menu |
---|
418 | |
---|
419 | year, month, day,hour,minute,second,tda,ty,tm_isdst= time.localtime() |
---|
420 | my_time= str(hour)+" : "+str(minute)+" : "+str(second)+" " |
---|
421 | date= str( month)+"|"+str(day)+"|"+str(year) |
---|
422 | msg= "Model saved at %s on %s"%(my_time, date) |
---|
423 | ## post help message for the selected model |
---|
424 | msg +=" Saved! right click on this page to retrieve this model" |
---|
425 | wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) |
---|
426 | |
---|
427 | id = wx.NewId() |
---|
428 | self.popUpMenu.Append(id,name,str(msg)) |
---|
429 | wx.EVT_MENU(self, id, self.onResetModel) |
---|
430 | |
---|
431 | |
---|
432 | def onSetFocus(self, evt): |
---|
433 | """ |
---|
434 | highlight the current textcrtl and hide the error text control shown |
---|
435 | after fitting |
---|
436 | """ |
---|
437 | |
---|
438 | if hasattr(self,"text2_3"): |
---|
439 | self.text2_3.Hide() |
---|
440 | if len(self.parameters)>0: |
---|
441 | for item in self.parameters: |
---|
442 | ## hide statictext +/- |
---|
443 | if item[3]!=None: |
---|
444 | item[3].Hide() |
---|
445 | ## hide textcrtl for error after fit |
---|
446 | if item[4]!=None: |
---|
447 | item[4].Clear() |
---|
448 | item[4].Hide() |
---|
449 | if len(self.fittable_param)>0: |
---|
450 | for item in self.fittable_param: |
---|
451 | ## hide statictext +/- |
---|
452 | if item[3]!=None: |
---|
453 | item[3].Hide() |
---|
454 | ## hide textcrtl for error after fit |
---|
455 | if item[4]!=None: |
---|
456 | item[4].Clear() |
---|
457 | item[4].Hide() |
---|
458 | self.Layout() |
---|
459 | # Get a handle to the TextCtrl |
---|
460 | widget = evt.GetEventObject() |
---|
461 | # Select the whole control, after this event resolves |
---|
462 | wx.CallAfter(widget.SetSelection, -1,-1) |
---|
463 | return |
---|
464 | |
---|
465 | |
---|
466 | def read_file(self, path): |
---|
467 | """ |
---|
468 | Read two columns file |
---|
469 | @param path: the path to the file to read |
---|
470 | """ |
---|
471 | try: |
---|
472 | if path==None: |
---|
473 | wx.PostEvent(self.parent.parent, StatusEvent(status=\ |
---|
474 | " Selected Distribution was not loaded: %s"%path)) |
---|
475 | return None, None |
---|
476 | input_f = open(path, 'r') |
---|
477 | buff = input_f.read() |
---|
478 | lines = buff.split('\n') |
---|
479 | |
---|
480 | angles = [] |
---|
481 | weights=[] |
---|
482 | for line in lines: |
---|
483 | toks = line.split() |
---|
484 | try: |
---|
485 | angle = float(toks[0]) |
---|
486 | weight = float(toks[1]) |
---|
487 | except: |
---|
488 | # Skip non-data lines |
---|
489 | pass |
---|
490 | angles.append(angle) |
---|
491 | weights.append(weight) |
---|
492 | return numpy.array(angles), numpy.array(weights) |
---|
493 | except: |
---|
494 | raise |
---|
495 | |
---|
496 | |
---|
497 | def createMemento(self): |
---|
498 | """ |
---|
499 | return the current state of the page |
---|
500 | """ |
---|
501 | return self.state.clone() |
---|
502 | |
---|
503 | |
---|
504 | def save_current_state(self): |
---|
505 | """ |
---|
506 | Store current state |
---|
507 | """ |
---|
508 | ## save model option |
---|
509 | if self.model!= None: |
---|
510 | self.disp_list= self.model.getDispParamList() |
---|
511 | self.state.disp_list= copy.deepcopy(self.disp_list) |
---|
512 | self.state.model = self.model.clone() |
---|
513 | |
---|
514 | self.state.enable2D = copy.deepcopy(self.enable2D) |
---|
515 | self.state.values= copy.deepcopy(self.values) |
---|
516 | self.state.weights = copy.deepcopy( self.weights) |
---|
517 | ## save data |
---|
518 | self.state.data= copy.deepcopy(self.data) |
---|
519 | |
---|
520 | try: |
---|
521 | n = self.disp_box.GetCurrentSelection() |
---|
522 | dispersity= self.disp_box.GetClientData(n) |
---|
523 | name= dispersity.__name__ |
---|
524 | if name == "GaussianDispersion": |
---|
525 | if hasattr(self,"cb1"): |
---|
526 | self.state.cb1= self.cb1.GetValue() |
---|
527 | except: |
---|
528 | pass |
---|
529 | |
---|
530 | if hasattr(self,"enable_disp"): |
---|
531 | self.state.enable_disp= self.enable_disp.GetValue() |
---|
532 | self.state.disable_disp = self.disable_disp.GetValue() |
---|
533 | |
---|
534 | self.state.smearer = copy.deepcopy(self.smearer) |
---|
535 | if hasattr(self,"enable_smearer"): |
---|
536 | self.state.enable_smearer = copy.deepcopy(self.enable_smearer.GetValue()) |
---|
537 | self.state.disable_smearer = copy.deepcopy(self.disable_smearer.GetValue()) |
---|
538 | |
---|
539 | if hasattr(self,"disp_box"): |
---|
540 | self.state.disp_box = self.disp_box.GetCurrentSelection() |
---|
541 | if len(self.disp_cb_dict)>0: |
---|
542 | for k , v in self.disp_cb_dict.iteritems(): |
---|
543 | if v ==None : |
---|
544 | self.state.disp_cb_dict[k]= v |
---|
545 | else: |
---|
546 | try: |
---|
547 | self.state.disp_cb_dict[k]=v.GetValue() |
---|
548 | except: |
---|
549 | self.state.disp_cb_dict[k]= None |
---|
550 | |
---|
551 | if len(self._disp_obj_dict)>0: |
---|
552 | for k , v in self._disp_obj_dict.iteritems(): |
---|
553 | self.state._disp_obj_dict[k]= v |
---|
554 | self.state.values = copy.deepcopy(self.values) |
---|
555 | self.state.weights = copy.deepcopy(self.weights) |
---|
556 | ## save plotting range |
---|
557 | self._save_plotting_range() |
---|
558 | |
---|
559 | self.state.orientation_params =[] |
---|
560 | self.state.orientation_params_disp =[] |
---|
561 | self.state.parameters =[] |
---|
562 | self.state.fittable_param =[] |
---|
563 | self.state.fixed_param =[] |
---|
564 | |
---|
565 | ## save checkbutton state and txtcrtl values |
---|
566 | self._copy_parameters_state(self.orientation_params, |
---|
567 | self.state.orientation_params) |
---|
568 | self._copy_parameters_state(self.orientation_params_disp, |
---|
569 | self.state.orientation_params_disp) |
---|
570 | self._copy_parameters_state(self.parameters, self.state.parameters) |
---|
571 | self._copy_parameters_state(self.fittable_param, self.state.fittable_param) |
---|
572 | self._copy_parameters_state(self.fixed_param, self.state.fixed_param) |
---|
573 | |
---|
574 | |
---|
575 | def reset_page_helper(self, state): |
---|
576 | """ |
---|
577 | Use page_state and change the state of existing page |
---|
578 | @precondition: the page is already drawn or created |
---|
579 | @postcondition: the state of the underlying data change as well as the |
---|
580 | state of the graphic interface |
---|
581 | """ |
---|
582 | if state ==None: |
---|
583 | self._undo.Enable(False) |
---|
584 | return |
---|
585 | self.model= state.model |
---|
586 | self.data = state.data |
---|
587 | self.smearer= state.smearer |
---|
588 | self.enable2D= state.enable2D |
---|
589 | ## set the state of the radio box |
---|
590 | self.shape_rbutton.SetValue(state.shape_rbutton ) |
---|
591 | self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) |
---|
592 | self.struct_rbutton.SetValue(state.struct_rbutton ) |
---|
593 | self.plugin_rbutton.SetValue(state.plugin_rbutton) |
---|
594 | ##draw sizer containing model parameters value for the current model |
---|
595 | self._set_model_sizer_selection( self.model ) |
---|
596 | self.set_model_param_sizer(self.model) |
---|
597 | |
---|
598 | ## reset value of combox box |
---|
599 | self.structurebox.SetSelection(state.structurecombobox ) |
---|
600 | self.formfactorbox.SetSelection(state.formfactorcombobox) |
---|
601 | ## enable the view 2d button if this is a modelpage type |
---|
602 | if hasattr(self,"model_view"): |
---|
603 | if not self.enable2D: |
---|
604 | self.model_view.Enable() |
---|
605 | else: |
---|
606 | self.model_view.Disable() |
---|
607 | ## set the select all check box to the a given state |
---|
608 | if hasattr(self, "cb1"): |
---|
609 | self.cb1.SetValue(state.cb1) |
---|
610 | |
---|
611 | ## reset state of checkbox,textcrtl and regular parameters value |
---|
612 | self._reset_parameters_state(self.orientation_params_disp, |
---|
613 | state.orientation_params_disp) |
---|
614 | self._reset_parameters_state(self.orientation_params, |
---|
615 | state.orientation_params) |
---|
616 | self._reset_parameters_state(self.parameters,state.parameters) |
---|
617 | |
---|
618 | ## display dispersion info layer |
---|
619 | self.enable_disp.SetValue(state.enable_disp) |
---|
620 | self.disable_disp.SetValue(state.disable_disp) |
---|
621 | |
---|
622 | if hasattr(self, "disp_box"): |
---|
623 | self.disp_box.SetSelection(state.disp_box) |
---|
624 | |
---|
625 | self.disp_cb_dict = {} |
---|
626 | for k,v in self.state.disp_cb_dict.iteritems(): |
---|
627 | self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) |
---|
628 | self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) |
---|
629 | |
---|
630 | self._disp_obj_dict={} |
---|
631 | for k , v in self.state._disp_obj_dict.iteritems(): |
---|
632 | self._disp_obj_dict[k]=v |
---|
633 | |
---|
634 | self._set_dipers_Param(event=None) |
---|
635 | ##plotting range restore |
---|
636 | self._reset_plotting_range(state) |
---|
637 | ## smearing info restore |
---|
638 | if hasattr(self,"enable_smearer"): |
---|
639 | ## set smearing value whether or not the data contain the smearing info |
---|
640 | self.enable_smearer.SetValue(state.enable_smearer) |
---|
641 | self.disable_smearer.SetValue(state.disable_smearer) |
---|
642 | self.tcChi.SetLabel(str( state.tcChi)) |
---|
643 | self.sizer5.Layout() |
---|
644 | self.Layout() |
---|
645 | self.Refresh() |
---|
646 | #self.compute_chisqr(smearer= self.smearer) |
---|
647 | |
---|
648 | ## reset state of checkbox,textcrtl and dispersity parameters value |
---|
649 | self._reset_parameters_state(self.fittable_param,state.fittable_param) |
---|
650 | self._reset_parameters_state(self.fixed_param,state.fixed_param) |
---|
651 | |
---|
652 | |
---|
653 | ## draw the model with previous parameters value |
---|
654 | self._onparamEnter_helper() |
---|
655 | |
---|
656 | ## reset context menu items |
---|
657 | self._reset_context_menu() |
---|
658 | |
---|
659 | ## set the value of the current state to the state given as parameter |
---|
660 | self.state = state.clone() |
---|
661 | |
---|
662 | |
---|
663 | |
---|
664 | def _selectDlg(self): |
---|
665 | """ |
---|
666 | open a dialog file to selected the customized dispersity |
---|
667 | """ |
---|
668 | import os |
---|
669 | dlg = wx.FileDialog(self, "Choose a weight file", |
---|
670 | self._default_save_location , "", "*.*", wx.OPEN) |
---|
671 | path = None |
---|
672 | if dlg.ShowModal() == wx.ID_OK: |
---|
673 | path = dlg.GetPath() |
---|
674 | dlg.Destroy() |
---|
675 | return path |
---|
676 | |
---|
677 | |
---|
678 | def _reset_context_menu(self): |
---|
679 | """ |
---|
680 | reset the context menu |
---|
681 | """ |
---|
682 | for name, state in self.state.saved_states.iteritems(): |
---|
683 | self.number_saved_state += 1 |
---|
684 | ## Add item in the context menu |
---|
685 | id = wx.NewId() |
---|
686 | self.popUpMenu.Append(id,name, 'Save model and state %g'%self.number_saved_state) |
---|
687 | wx.EVT_MENU(self, id, self.onResetModel) |
---|
688 | |
---|
689 | |
---|
690 | def _reset_plotting_range(self, state): |
---|
691 | """ |
---|
692 | Reset the plotting range to a given state |
---|
693 | """ |
---|
694 | self.qmin.SetValue(str(state.qmin)) |
---|
695 | self.qmax.SetValue(str(state.qmax)) |
---|
696 | if self.state.npts!=None: |
---|
697 | self.npts.SetValue(str(state.npts)) |
---|
698 | |
---|
699 | |
---|
700 | def _save_typeOfmodel(self): |
---|
701 | """ |
---|
702 | save radiobutton containing the type model that can be selected |
---|
703 | """ |
---|
704 | self.state.shape_rbutton = self.shape_rbutton.GetValue() |
---|
705 | self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() |
---|
706 | self.state.struct_rbutton = self.struct_rbutton.GetValue() |
---|
707 | self.state.plugin_rbutton = self.plugin_rbutton.GetValue() |
---|
708 | self.state.structurebox= self.structurebox.GetCurrentSelection() |
---|
709 | self.state.formfactorbox = self.formfactorbox.GetCurrentSelection() |
---|
710 | |
---|
711 | self._undo.Enable(True) |
---|
712 | ## post state to fit panel |
---|
713 | event = PageInfoEvent(page = self) |
---|
714 | wx.PostEvent(self.parent, event) |
---|
715 | |
---|
716 | |
---|
717 | def _save_plotting_range(self ): |
---|
718 | """ |
---|
719 | save the state of plotting range |
---|
720 | """ |
---|
721 | self.state.qmin = self.qmin_x |
---|
722 | self.state.qmax = self.qmax_x |
---|
723 | if self.npts!=None: |
---|
724 | self.state.npts= self.num_points |
---|
725 | |
---|
726 | |
---|
727 | def _onparamEnter_helper(self): |
---|
728 | """ |
---|
729 | check if values entered by the user are changed and valid to replot |
---|
730 | model |
---|
731 | use : _check_value_enter |
---|
732 | """ |
---|
733 | self._undo.Enable(True) |
---|
734 | if self.model !=None: |
---|
735 | |
---|
736 | |
---|
737 | # Flag to register when a parameter has changed. |
---|
738 | is_modified = False |
---|
739 | is_modified =self._check_value_enter( self.fittable_param ,is_modified) |
---|
740 | is_modified =self._check_value_enter( self.fixed_param ,is_modified) |
---|
741 | is_modified =self._check_value_enter( self.parameters ,is_modified) |
---|
742 | |
---|
743 | self.sizer3.Layout() |
---|
744 | self.Layout() |
---|
745 | self.Refresh() |
---|
746 | # Here we should check whether the boundaries have been modified. |
---|
747 | # If qmin and qmax have been modified, update qmin and qmax and |
---|
748 | # set the is_modified flag to True |
---|
749 | from sans.guiframe.utils import check_value |
---|
750 | if check_value( self.qmin, self.qmax): |
---|
751 | if float(self.qmin.GetValue()) != self.qmin_x: |
---|
752 | self.qmin_x = float(self.qmin.GetValue()) |
---|
753 | is_modified = True |
---|
754 | if float(self.qmax.GetValue()) != self.qmax_x: |
---|
755 | self.qmax_x = float(self.qmax.GetValue()) |
---|
756 | is_modified = True |
---|
757 | self.fitrange = True |
---|
758 | else: |
---|
759 | self.fitrange = False |
---|
760 | if self.npts != None: |
---|
761 | if check_float(self.npts): |
---|
762 | if float(self.npts.GetValue()) != self.num_points: |
---|
763 | self.num_points = float(self.npts.GetValue()) |
---|
764 | is_modified = True |
---|
765 | else: |
---|
766 | msg= "Cannot Plot :Must enter a number!!! " |
---|
767 | wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) |
---|
768 | |
---|
769 | |
---|
770 | ## if any value is modify draw model with new value |
---|
771 | if is_modified: |
---|
772 | self.state_change= True |
---|
773 | self._draw_model() |
---|
774 | self.save_current_state() |
---|
775 | |
---|
776 | |
---|
777 | def _reset_parameters_state(self, listtorestore,statelist): |
---|
778 | """ |
---|
779 | Reset the parameters at the given state |
---|
780 | """ |
---|
781 | if len(statelist)==0 or len(listtorestore)==0 : |
---|
782 | return |
---|
783 | if len(statelist)!= len(listtorestore) : |
---|
784 | return |
---|
785 | for j in range(len(listtorestore)): |
---|
786 | item_page = listtorestore[j] |
---|
787 | item_page_info = statelist[j] |
---|
788 | ##change the state of the check box for simple parameters |
---|
789 | if item_page[0]!=None: |
---|
790 | item_page[0].SetValue(item_page_info[0]) |
---|
791 | |
---|
792 | if item_page[2]!=None: |
---|
793 | item_page[2].SetValue(item_page_info[2]) |
---|
794 | |
---|
795 | if item_page[3]!=None: |
---|
796 | ## show or hide text +/- |
---|
797 | if item_page_info[2]: |
---|
798 | item_page[3].Show(True) |
---|
799 | else: |
---|
800 | item_page[3].Hide() |
---|
801 | if item_page[4]!=None: |
---|
802 | ## show of hide the text crtl for fitting error |
---|
803 | if item_page_info[4][0]: |
---|
804 | item_page[4].Show(True) |
---|
805 | item_page[4].SetValue(item_page_info[4][1]) |
---|
806 | else: |
---|
807 | item_page[3].Hide() |
---|
808 | if item_page[5]!=None: |
---|
809 | ## show of hide the text crtl for fitting error |
---|
810 | if item_page_info[5][0]: |
---|
811 | item_page[5].Show(True) |
---|
812 | item_page[5].SetValue(item_page_info[4][1]) |
---|
813 | else: |
---|
814 | item_page[5].Hide() |
---|
815 | |
---|
816 | if item_page[6]!=None: |
---|
817 | ## show of hide the text crtl for fitting error |
---|
818 | if item_page_info[6][0]: |
---|
819 | item_page[6].Show(True) |
---|
820 | item_page[6].SetValue(item_page_info[6][1]) |
---|
821 | else: |
---|
822 | item_page[6].Hide() |
---|
823 | |
---|
824 | |
---|
825 | def _copy_parameters_state(self, listtocopy, statelist): |
---|
826 | """ |
---|
827 | copy the state of button |
---|
828 | @param listtocopy: the list of check button to copy |
---|
829 | @param statelist: list of state object to store the current state |
---|
830 | """ |
---|
831 | |
---|
832 | if len(listtocopy)==0: |
---|
833 | return |
---|
834 | |
---|
835 | for item in listtocopy: |
---|
836 | checkbox_state = None |
---|
837 | if item[0]!= None: |
---|
838 | checkbox_state= item[0].GetValue() |
---|
839 | parameter_name = item[1] |
---|
840 | parameter_value = None |
---|
841 | if item[2]!=None: |
---|
842 | parameter_value = item[2].GetValue() |
---|
843 | static_text = None |
---|
844 | if item[3]!=None: |
---|
845 | static_text = item[3].IsShown() |
---|
846 | error_value = None |
---|
847 | error_state = None |
---|
848 | if item[4]!= None: |
---|
849 | error_value = item[4].GetValue() |
---|
850 | error_state = item[4].IsShown() |
---|
851 | |
---|
852 | min_value = None |
---|
853 | min_state = None |
---|
854 | if item[5]!= None: |
---|
855 | min_value = item[5].GetValue() |
---|
856 | min_state = item[5].IsShown() |
---|
857 | |
---|
858 | max_value = None |
---|
859 | max_state = None |
---|
860 | if item[6]!= None: |
---|
861 | max_value = item[6].GetValue() |
---|
862 | max_state = item[6].IsShown() |
---|
863 | unit=None |
---|
864 | if item[7]!=None: |
---|
865 | unit = item[7].GetLabel() |
---|
866 | |
---|
867 | statelist.append([checkbox_state, parameter_name, parameter_value, |
---|
868 | static_text ,[error_state,error_value], |
---|
869 | [min_state,min_value],[max_state , max_value],unit]) |
---|
870 | |
---|
871 | |
---|
872 | |
---|
873 | def _set_model_sizer_selection(self, model): |
---|
874 | """ |
---|
875 | Display the sizer according to the type of the current model |
---|
876 | """ |
---|
877 | if model ==None: |
---|
878 | return |
---|
879 | if hasattr(model ,"model2"): |
---|
880 | |
---|
881 | class_name= model.model2.__class__ |
---|
882 | name= model.model2.name |
---|
883 | flag= name != "NoStructure" |
---|
884 | if flag and (class_name in self.model_list_box["Structure Factors"]): |
---|
885 | self.structurebox.Enable() |
---|
886 | self.text2.Enable() |
---|
887 | items = self.structurebox.GetItems() |
---|
888 | self.sizer1.Layout() |
---|
889 | self.SetScrollbars(20,20,200,100) |
---|
890 | for i in range(len(items)): |
---|
891 | if items[i]== str(name): |
---|
892 | self.structurebox.SetSelection(i) |
---|
893 | break |
---|
894 | |
---|
895 | if hasattr(model ,"model1"): |
---|
896 | class_name = model.model1.__class__ |
---|
897 | name = model.model1.name |
---|
898 | self.formfactorbox.Clear() |
---|
899 | |
---|
900 | for k, list in self.model_list_box.iteritems(): |
---|
901 | if k in["P(Q)*S(Q)","Shapes" ] and class_name in self.model_list_box["Shapes"]: |
---|
902 | self.shape_rbutton.SetValue(True) |
---|
903 | ## fill the form factor list with new model |
---|
904 | self._populate_box(self.formfactorbox,self.model_list_box["Shapes"]) |
---|
905 | items = self.formfactorbox.GetItems() |
---|
906 | ## set comboxbox to the selected item |
---|
907 | for i in range(len(items)): |
---|
908 | if items[i]== str(name): |
---|
909 | self.formfactorbox.SetSelection(i) |
---|
910 | break |
---|
911 | return |
---|
912 | elif k == "Shape-Independent": |
---|
913 | self.shape_indep_rbutton.SetValue(True) |
---|
914 | elif k == "Structure Factors": |
---|
915 | self.struct_rbutton.SetValue(True) |
---|
916 | else: |
---|
917 | self.plugin_rbutton.SetValue(True) |
---|
918 | |
---|
919 | if class_name in list: |
---|
920 | ## fill the form factor list with new model |
---|
921 | self._populate_box(self.formfactorbox, list) |
---|
922 | items = self.formfactorbox.GetItems() |
---|
923 | ## set comboxbox to the selected item |
---|
924 | for i in range(len(items)): |
---|
925 | if items[i]== str(name): |
---|
926 | self.formfactorbox.SetSelection(i) |
---|
927 | break |
---|
928 | break |
---|
929 | else: |
---|
930 | |
---|
931 | ## Select the model from the menu |
---|
932 | class_name = model.__class__ |
---|
933 | name = model.name |
---|
934 | self.formfactorbox.Clear() |
---|
935 | items = self.formfactorbox.GetItems() |
---|
936 | |
---|
937 | for k, list in self.model_list_box.iteritems(): |
---|
938 | if k in["P(Q)*S(Q)","Shapes" ] and class_name in self.model_list_box["Shapes"]: |
---|
939 | if class_name in self.model_list_box["P(Q)*S(Q)"]: |
---|
940 | self.structurebox.Enable() |
---|
941 | self.structurebox.SetSelection(0) |
---|
942 | self.text2.Enable() |
---|
943 | else: |
---|
944 | self.structurebox.Disable() |
---|
945 | self.structurebox.SetSelection(0) |
---|
946 | self.text2.Disable() |
---|
947 | |
---|
948 | self.shape_rbutton.SetValue(True) |
---|
949 | ## fill the form factor list with new model |
---|
950 | self._populate_box(self.formfactorbox,self.model_list_box["Shapes"]) |
---|
951 | items = self.formfactorbox.GetItems() |
---|
952 | ## set comboxbox to the selected item |
---|
953 | for i in range(len(items)): |
---|
954 | if items[i]== str(name): |
---|
955 | self.formfactorbox.SetSelection(i) |
---|
956 | break |
---|
957 | return |
---|
958 | elif k == "Shape-Independent": |
---|
959 | self.shape_indep_rbutton.SetValue(True) |
---|
960 | elif k == "Structure Factors": |
---|
961 | self.struct_rbutton.SetValue(True) |
---|
962 | else: |
---|
963 | self.plugin_rbutton.SetValue(True) |
---|
964 | if class_name in list: |
---|
965 | self.structurebox.SetSelection(0) |
---|
966 | self.structurebox.Disable() |
---|
967 | self.text2.Disable() |
---|
968 | ## fill the form factor list with new model |
---|
969 | self._populate_box(self.formfactorbox, list) |
---|
970 | items = self.formfactorbox.GetItems() |
---|
971 | ## set comboxbox to the selected item |
---|
972 | for i in range(len(items)): |
---|
973 | if items[i]== str(name): |
---|
974 | self.formfactorbox.SetSelection(i) |
---|
975 | break |
---|
976 | break |
---|
977 | ## save state and post |
---|
978 | |
---|
979 | |
---|
980 | |
---|
981 | def _draw_model(self): |
---|
982 | """ |
---|
983 | Method to draw or refresh a plotted model. |
---|
984 | The method will use the data member from the model page |
---|
985 | to build a call to the fitting perspective manager. |
---|
986 | |
---|
987 | [Note to coder: This way future changes will be done in only one place.] |
---|
988 | """ |
---|
989 | if self.model !=None: |
---|
990 | temp_smear=None |
---|
991 | if hasattr(self, "enable_smearer"): |
---|
992 | if self.enable_smearer.GetValue(): |
---|
993 | temp_smear= self.smearer |
---|
994 | |
---|
995 | self.manager.draw_model(self.model, data=self.data, |
---|
996 | smearer= temp_smear, |
---|
997 | qmin=float(self.qmin_x), qmax=float(self.qmax_x), |
---|
998 | qstep= float(self.num_points), |
---|
999 | enable2D=self.enable2D) |
---|
1000 | |
---|
1001 | |
---|
1002 | def _set_model_sizer(self, sizer, title="", object=None): |
---|
1003 | """ |
---|
1004 | Use lists to fill a sizer for model info |
---|
1005 | """ |
---|
1006 | |
---|
1007 | sizer.Clear(True) |
---|
1008 | box_description= wx.StaticBox(self, -1,str(title)) |
---|
1009 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
1010 | #-------------------------------------------------------- |
---|
1011 | self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', style=wx.RB_GROUP) |
---|
1012 | self.shape_indep_rbutton = wx.RadioButton(self, -1, "Shape-Independent") |
---|
1013 | self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") |
---|
1014 | self.plugin_rbutton = wx.RadioButton(self, -1, "Customized Models") |
---|
1015 | |
---|
1016 | self.Bind( wx.EVT_RADIOBUTTON, self._show_combox, |
---|
1017 | id= self.shape_rbutton.GetId() ) |
---|
1018 | self.Bind( wx.EVT_RADIOBUTTON, self._show_combox, |
---|
1019 | id= self.shape_indep_rbutton.GetId() ) |
---|
1020 | self.Bind( wx.EVT_RADIOBUTTON, self._show_combox, |
---|
1021 | id= self.struct_rbutton.GetId() ) |
---|
1022 | self.Bind( wx.EVT_RADIOBUTTON, self._show_combox, |
---|
1023 | id= self.plugin_rbutton.GetId() ) |
---|
1024 | |
---|
1025 | |
---|
1026 | sizer_radiobutton = wx.GridSizer(2, 2,5, 5) |
---|
1027 | sizer_radiobutton.Add(self.shape_rbutton) |
---|
1028 | sizer_radiobutton.Add(self.shape_indep_rbutton) |
---|
1029 | sizer_radiobutton.Add(self.plugin_rbutton) |
---|
1030 | sizer_radiobutton.Add(self.struct_rbutton) |
---|
1031 | |
---|
1032 | sizer_selection = wx.BoxSizer(wx.HORIZONTAL) |
---|
1033 | |
---|
1034 | self.text1 = wx.StaticText( self,-1,"" ) |
---|
1035 | self.text2 = wx.StaticText( self,-1,"P(Q)*S(Q)" ) |
---|
1036 | |
---|
1037 | |
---|
1038 | self.formfactorbox = wx.ComboBox(self, -1,style=wx.CB_READONLY) |
---|
1039 | if self.model!=None: |
---|
1040 | self.formfactorbox.SetValue(self.model.name) |
---|
1041 | |
---|
1042 | |
---|
1043 | self.structurebox = wx.ComboBox(self, -1,style=wx.CB_READONLY) |
---|
1044 | wx.EVT_COMBOBOX(self.formfactorbox,-1, self._on_select_model) |
---|
1045 | wx.EVT_COMBOBOX(self.structurebox,-1, self._on_select_model) |
---|
1046 | |
---|
1047 | |
---|
1048 | ## fill combox box |
---|
1049 | if len(self.model_list_box)>0: |
---|
1050 | self._populate_box( self.formfactorbox,self.model_list_box["Shapes"]) |
---|
1051 | |
---|
1052 | if len(self.model_list_box)>0: |
---|
1053 | self._populate_box( self.structurebox, |
---|
1054 | self.model_list_box["Structure Factors"]) |
---|
1055 | self.structurebox.Insert("None", 0,None) |
---|
1056 | self.structurebox.SetSelection(0) |
---|
1057 | self.structurebox.Disable() |
---|
1058 | self.text2.Disable() |
---|
1059 | |
---|
1060 | if self.model.__class__ in self.model_list_box["P(Q)*S(Q)"]: |
---|
1061 | self.structurebox.Enable() |
---|
1062 | self.text2.Enable() |
---|
1063 | |
---|
1064 | ## check model type to show sizer |
---|
1065 | if self.model !=None: |
---|
1066 | self._set_model_sizer_selection( self.model ) |
---|
1067 | |
---|
1068 | sizer_selection.Add(self.text1) |
---|
1069 | sizer_selection.Add((5,5)) |
---|
1070 | sizer_selection.Add(self.formfactorbox) |
---|
1071 | sizer_selection.Add((5,5)) |
---|
1072 | sizer_selection.Add(self.text2) |
---|
1073 | sizer_selection.Add((5,5)) |
---|
1074 | sizer_selection.Add(self.structurebox) |
---|
1075 | sizer_selection.Add((5,5)) |
---|
1076 | |
---|
1077 | boxsizer1.Add( sizer_radiobutton ) |
---|
1078 | boxsizer1.Add( (20,20)) |
---|
1079 | boxsizer1.Add( sizer_selection ) |
---|
1080 | if object !=None: |
---|
1081 | boxsizer1.Add( (-72,-72)) |
---|
1082 | boxsizer1.Add( object, 0, wx.ALIGN_RIGHT| wx.RIGHT, 10) |
---|
1083 | boxsizer1.Add( (60,60)) |
---|
1084 | #-------------------------------------------------------- |
---|
1085 | sizer.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
1086 | sizer.Layout() |
---|
1087 | self.SetScrollbars(20,20,200,100) |
---|
1088 | |
---|
1089 | |
---|
1090 | def _show_combox(self, event): |
---|
1091 | """ |
---|
1092 | Show combox box associate with type of model selected |
---|
1093 | """ |
---|
1094 | ## Don't want to populate combo box again if the event comes from check box |
---|
1095 | if self.shape_rbutton.GetValue()and\ |
---|
1096 | event.GetEventObject()==self.shape_rbutton: |
---|
1097 | ##fill the combobox with form factor list |
---|
1098 | self.structurebox.SetSelection(0) |
---|
1099 | self.structurebox.Disable() |
---|
1100 | self.formfactorbox.Clear() |
---|
1101 | self._populate_box( self.formfactorbox,self.model_list_box["Shapes"]) |
---|
1102 | |
---|
1103 | if self.shape_indep_rbutton.GetValue()and\ |
---|
1104 | event.GetEventObject()==self.shape_indep_rbutton: |
---|
1105 | ##fill the combobox with shape independent factor list |
---|
1106 | self.structurebox.SetSelection(0) |
---|
1107 | self.structurebox.Disable() |
---|
1108 | self.formfactorbox.Clear() |
---|
1109 | self._populate_box( self.formfactorbox, |
---|
1110 | self.model_list_box["Shape-Independent"]) |
---|
1111 | |
---|
1112 | if self.struct_rbutton.GetValue() and\ |
---|
1113 | event.GetEventObject()==self.struct_rbutton: |
---|
1114 | ##fill the combobox with structure factor list |
---|
1115 | self.structurebox.SetSelection(0) |
---|
1116 | self.structurebox.Disable() |
---|
1117 | self.formfactorbox.Clear() |
---|
1118 | self._populate_box( self.formfactorbox, |
---|
1119 | self.model_list_box["Structure Factors"]) |
---|
1120 | |
---|
1121 | if self.plugin_rbutton.GetValue()and\ |
---|
1122 | event.GetEventObject()==self.plugin_rbutton: |
---|
1123 | |
---|
1124 | ##fill the combobox with form factor list |
---|
1125 | self.structurebox.Disable() |
---|
1126 | self.formfactorbox.Clear() |
---|
1127 | self._populate_box( self.formfactorbox, |
---|
1128 | self.model_list_box["Customized Models"]) |
---|
1129 | |
---|
1130 | self._on_select_model(event=None) |
---|
1131 | self._save_typeOfmodel() |
---|
1132 | self.sizer4_4.Layout() |
---|
1133 | self.sizer4.Layout() |
---|
1134 | self.Layout() |
---|
1135 | self.Refresh() |
---|
1136 | self.SetScrollbars(20,20,200,100) |
---|
1137 | |
---|
1138 | def _populate_box(self, combobox, list): |
---|
1139 | """ |
---|
1140 | fill combox box with dict item |
---|
1141 | @param list: contains item to fill the combox |
---|
1142 | item must model class |
---|
1143 | """ |
---|
1144 | for models in list: |
---|
1145 | model= models() |
---|
1146 | name = model.__class__.__name__ |
---|
1147 | if models.__name__!="NoStructure": |
---|
1148 | if hasattr(model, "name"): |
---|
1149 | name = model.name |
---|
1150 | combobox.Append(name,models) |
---|
1151 | |
---|
1152 | return 0 |
---|
1153 | |
---|
1154 | |
---|
1155 | def _on_select_model_helper(self): |
---|
1156 | """ |
---|
1157 | call back for model selection |
---|
1158 | """ |
---|
1159 | ## reset dictionary containing reference to dispersion |
---|
1160 | self._disp_obj_dict = {} |
---|
1161 | self.disp_cb_dict ={} |
---|
1162 | f_id = self.formfactorbox.GetCurrentSelection() |
---|
1163 | form_factor = self.formfactorbox.GetClientData( f_id ) |
---|
1164 | if not form_factor in self.model_list_box["multiplication"]: |
---|
1165 | self.structurebox.Disable() |
---|
1166 | self.structurebox.SetSelection(0) |
---|
1167 | self.text2.Disable() |
---|
1168 | else: |
---|
1169 | self.structurebox.Enable() |
---|
1170 | self.text2.Enable() |
---|
1171 | |
---|
1172 | s_id = self.structurebox.GetCurrentSelection() |
---|
1173 | struct_factor = self.structurebox.GetClientData( s_id ) |
---|
1174 | |
---|
1175 | if struct_factor !=None: |
---|
1176 | from sans.models.MultiplicationModel import MultiplicationModel |
---|
1177 | self.model= MultiplicationModel(form_factor(),struct_factor()) |
---|
1178 | |
---|
1179 | else: |
---|
1180 | if form_factor != None: |
---|
1181 | self.model= form_factor() |
---|
1182 | else: |
---|
1183 | self.model = None |
---|
1184 | return self.model |
---|
1185 | |
---|
1186 | ## post state to fit panel |
---|
1187 | self.state.model =self.model |
---|
1188 | self.disp_list =self.model.getDispParamList() |
---|
1189 | self.state.disp_list = self.disp_list |
---|
1190 | self.state.structurecombobox =self.structurebox.GetCurrentSelection() |
---|
1191 | self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection() |
---|
1192 | self.sizer4_4.Layout() |
---|
1193 | self.sizer4.Layout() |
---|
1194 | self.Layout() |
---|
1195 | self.SetScrollbars(20,20,200,100) |
---|
1196 | self.Refresh() |
---|
1197 | |
---|
1198 | |
---|
1199 | |
---|
1200 | def _onparamEnter(self,event): |
---|
1201 | """ |
---|
1202 | when enter value on panel redraw model according to changed |
---|
1203 | """ |
---|
1204 | tcrtl= event.GetEventObject() |
---|
1205 | ## save current state |
---|
1206 | self.save_current_state() |
---|
1207 | if event !=None: |
---|
1208 | self._undo.Enable(True) |
---|
1209 | event = PageInfoEvent(page = self) |
---|
1210 | wx.PostEvent(self.parent, event) |
---|
1211 | |
---|
1212 | if check_float(tcrtl): |
---|
1213 | |
---|
1214 | self._onparamEnter_helper() |
---|
1215 | else: |
---|
1216 | msg= "Cannot Plot :Must enter a number!!! " |
---|
1217 | wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) |
---|
1218 | return |
---|
1219 | |
---|
1220 | |
---|
1221 | def _check_value_enter(self, list, modified): |
---|
1222 | """ |
---|
1223 | @param list: model parameter and panel info |
---|
1224 | each item of the list should be as follow: |
---|
1225 | item=[cb state, name, value, "+/-", error of fit, min, max , units] |
---|
1226 | """ |
---|
1227 | is_modified = modified |
---|
1228 | if len(list)==0: |
---|
1229 | return is_modified |
---|
1230 | for item in list: |
---|
1231 | try: |
---|
1232 | name = str(item[1]) |
---|
1233 | if hasattr(self,"text2_3"): |
---|
1234 | self.text2_3.Hide() |
---|
1235 | ## check model parameters range |
---|
1236 | ## check minimun value |
---|
1237 | param_min= None |
---|
1238 | param_max= None |
---|
1239 | if item[5]!= None: |
---|
1240 | if item[5].GetValue().lstrip().rstrip()!="": |
---|
1241 | param_min = float(item[5].GetValue()) |
---|
1242 | |
---|
1243 | ## check maximum value |
---|
1244 | if item[6]!= None: |
---|
1245 | if item[6].GetValue().lstrip().rstrip()!="": |
---|
1246 | param_max = float(item[6].GetValue()) |
---|
1247 | |
---|
1248 | from sans.guiframe.utils import check_value |
---|
1249 | if param_min != None and param_max !=None: |
---|
1250 | if not check_value(item[5], item[6]): |
---|
1251 | msg= "Wrong Fit range entered for parameter " |
---|
1252 | msg+= "name %s of model %s "%(name, self.model.name) |
---|
1253 | wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) |
---|
1254 | if name in self.model.details.keys(): |
---|
1255 | self.model.details[name][1:]= param_min,param_max |
---|
1256 | |
---|
1257 | ## hide statictext +/- |
---|
1258 | if item[3]!=None: |
---|
1259 | item[3].Hide() |
---|
1260 | ## hide textcrtl for error after fit |
---|
1261 | if item[4]!=None: |
---|
1262 | item[4].Clear() |
---|
1263 | item[4].Hide() |
---|
1264 | |
---|
1265 | value= float(item[2].GetValue()) |
---|
1266 | |
---|
1267 | # If the value of the parameter has changed, |
---|
1268 | # +update the model and set the is_modified flag |
---|
1269 | if value != self.model.getParam(name): |
---|
1270 | self.model.setParam(name,value) |
---|
1271 | is_modified = True |
---|
1272 | |
---|
1273 | except: |
---|
1274 | msg= "Model Drawing Error:wrong value entered : %s"% sys.exc_value |
---|
1275 | wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) |
---|
1276 | return |
---|
1277 | |
---|
1278 | return is_modified |
---|
1279 | |
---|
1280 | |
---|
1281 | def _set_dipers_Param(self, event): |
---|
1282 | """ |
---|
1283 | Add more item to select user dispersity |
---|
1284 | """ |
---|
1285 | self._reset_dispersity() |
---|
1286 | if self.model ==None: |
---|
1287 | self.model_disp.Hide() |
---|
1288 | self.disp_box.Hide() |
---|
1289 | self.sizer4_4.Clear(True) |
---|
1290 | ## save the state of the dispersity |
---|
1291 | #self.save_current_state() |
---|
1292 | return |
---|
1293 | |
---|
1294 | if self.enable_disp.GetValue(): |
---|
1295 | self.model_disp.Show(True) |
---|
1296 | self.disp_box.Show(True) |
---|
1297 | ## layout for model containing no dispersity parameters |
---|
1298 | self.disp_list= self.model.getDispParamList() |
---|
1299 | if len(self.disp_list)==0: |
---|
1300 | self._layout_sizer_noDipers() |
---|
1301 | else: |
---|
1302 | ## set gaussian sizer |
---|
1303 | self._on_select_Disp(event=None) |
---|
1304 | else: |
---|
1305 | self.model_disp.Hide() |
---|
1306 | self.disp_box.Hide() |
---|
1307 | self.disp_box.SetSelection(0) |
---|
1308 | self.sizer4_4.Clear(True) |
---|
1309 | |
---|
1310 | ## post state to fit panel |
---|
1311 | self.save_current_state() |
---|
1312 | if event !=None: |
---|
1313 | self._undo.Enable(True) |
---|
1314 | event = PageInfoEvent(page = self) |
---|
1315 | wx.PostEvent(self.parent, event) |
---|
1316 | |
---|
1317 | self.sizer4_4.Layout() |
---|
1318 | self.sizer4.Layout() |
---|
1319 | self.Layout() |
---|
1320 | self.Refresh() |
---|
1321 | self.SetScrollbars(20,20,200,100) |
---|
1322 | |
---|
1323 | |
---|
1324 | |
---|
1325 | def _layout_sizer_noDipers(self): |
---|
1326 | """ |
---|
1327 | Draw a sizer with no dispersity info |
---|
1328 | """ |
---|
1329 | ix=0 |
---|
1330 | iy=1 |
---|
1331 | self.fittable_param=[] |
---|
1332 | self.fixed_param=[] |
---|
1333 | self.orientation_params_disp=[] |
---|
1334 | |
---|
1335 | self.model_disp.Hide() |
---|
1336 | self.disp_box.Hide() |
---|
1337 | self.sizer4_4.Clear(True) |
---|
1338 | model_disp = wx.StaticText(self, -1, 'No PolyDispersity for this model') |
---|
1339 | self.sizer4_4.Add(model_disp,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
1340 | self.sizer4_4.Layout() |
---|
1341 | self.sizer4.Layout() |
---|
1342 | self.SetScrollbars(20,20,200,100) |
---|
1343 | |
---|
1344 | |
---|
1345 | def _reset_dispersity(self): |
---|
1346 | """ |
---|
1347 | put gaussian dispersity into current model |
---|
1348 | """ |
---|
1349 | if len(self.param_toFit)>0: |
---|
1350 | for item in self.fittable_param: |
---|
1351 | if item in self.param_toFit: |
---|
1352 | self.param_toFit.remove(item) |
---|
1353 | for item in self.orientation_params_disp: |
---|
1354 | if item in self.param_toFit: |
---|
1355 | self.param_toFit.remove(item) |
---|
1356 | |
---|
1357 | self.fittable_param=[] |
---|
1358 | self.fixed_param=[] |
---|
1359 | self.orientation_params_disp=[] |
---|
1360 | self.values=[] |
---|
1361 | self.weights=[] |
---|
1362 | |
---|
1363 | |
---|
1364 | from sans.models.dispersion_models import GaussianDispersion |
---|
1365 | if len(self.disp_cb_dict)==0: |
---|
1366 | self.sizer4_4.Clear(True) |
---|
1367 | self.sizer4_4.Layout() |
---|
1368 | self.sizer4.Layout() |
---|
1369 | self.Layout() |
---|
1370 | self.Refresh() |
---|
1371 | self.SetScrollbars(20,20,200,100) |
---|
1372 | return |
---|
1373 | |
---|
1374 | |
---|
1375 | for p in self.disp_cb_dict: |
---|
1376 | # The parameter was un-selected. Go back to Gaussian model (with 0 pts) |
---|
1377 | disp_model = GaussianDispersion() |
---|
1378 | # Store the object to make it persist outside the scope of this method |
---|
1379 | #TODO: refactor model to clean this up? |
---|
1380 | self._disp_obj_dict[p] = disp_model |
---|
1381 | # Set the new model as the dispersion object for the selected parameter |
---|
1382 | self.model.set_dispersion(p, disp_model) |
---|
1383 | # Redraw the model |
---|
1384 | |
---|
1385 | self._draw_model() |
---|
1386 | ## save state into |
---|
1387 | self.save_current_state() |
---|
1388 | self.sizer4_4.Layout() |
---|
1389 | self.sizer4.Layout() |
---|
1390 | self.Layout() |
---|
1391 | self.SetScrollbars(20,20,200,100) |
---|
1392 | self.Refresh() |
---|
1393 | |
---|
1394 | |
---|
1395 | |
---|
1396 | def _on_select_Disp(self,event): |
---|
1397 | """ |
---|
1398 | allow selecting different dispersion |
---|
1399 | self.disp_list should change type later .now only gaussian |
---|
1400 | """ |
---|
1401 | |
---|
1402 | n = self.disp_box.GetCurrentSelection() |
---|
1403 | dispersity= self.disp_box.GetClientData(n) |
---|
1404 | name= dispersity.__name__ |
---|
1405 | if name == "GaussianDispersion": |
---|
1406 | self._set_sizer_gaussian() |
---|
1407 | |
---|
1408 | if name == "ArrayDispersion": |
---|
1409 | self._set_sizer_arraydispersion() |
---|
1410 | |
---|
1411 | self.state.disp_box= n |
---|
1412 | |
---|
1413 | self.sizer4_4.Layout() |
---|
1414 | self.sizer4.Layout() |
---|
1415 | self.Layout() |
---|
1416 | self.SetScrollbars(20,20,200,100) |
---|
1417 | self.Refresh() |
---|
1418 | |
---|
1419 | |
---|
1420 | |
---|
1421 | |
---|
1422 | def _set_sizer_arraydispersion(self): |
---|
1423 | """ |
---|
1424 | draw sizer with array dispersity parameters |
---|
1425 | """ |
---|
1426 | if len(self.param_toFit)>0: |
---|
1427 | for item in self.fittable_param: |
---|
1428 | if item in self.param_toFit: |
---|
1429 | self.param_toFit.remove(item) |
---|
1430 | for item in self.orientation_params_disp: |
---|
1431 | if item in self.param_toFit: |
---|
1432 | self.param_toFit.remove(item) |
---|
1433 | |
---|
1434 | self.fittable_param=[] |
---|
1435 | self.fixed_param=[] |
---|
1436 | self.orientation_params_disp=[] |
---|
1437 | self.sizer4_4.Clear(True) |
---|
1438 | ix=0 |
---|
1439 | iy=1 |
---|
1440 | disp1 = wx.StaticText(self, -1, 'Array Dispersion') |
---|
1441 | self.sizer4_4.Add(disp1,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
1442 | |
---|
1443 | # Look for model parameters to which we can apply an ArrayDispersion model |
---|
1444 | # Add a check box for each parameter. |
---|
1445 | self.disp_cb_dict = {} |
---|
1446 | for p in self.model.dispersion.keys(): |
---|
1447 | ix+=1 |
---|
1448 | self.disp_cb_dict[p] = wx.CheckBox(self, -1, p, (10, 10)) |
---|
1449 | |
---|
1450 | wx.EVT_CHECKBOX(self, self.disp_cb_dict[p].GetId(), self.select_disp_angle) |
---|
1451 | self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
1452 | |
---|
1453 | ix =0 |
---|
1454 | iy +=1 |
---|
1455 | self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
1456 | self.sizer4_4.Layout() |
---|
1457 | self.sizer4.Layout() |
---|
1458 | self.SetScrollbars(20,20,200,100) |
---|
1459 | ## save state into |
---|
1460 | self._copy_parameters_state(self.orientation_params_disp, |
---|
1461 | self.state.orientation_params_disp) |
---|
1462 | self._copy_parameters_state(self.fittable_param, self.state.fittable_param) |
---|
1463 | self._copy_parameters_state(self.fixed_param, self.state.fixed_param) |
---|
1464 | |
---|
1465 | |
---|
1466 | def _set_range_sizer(self, title, object1=None,object=None): |
---|
1467 | """ |
---|
1468 | Fill the |
---|
1469 | """ |
---|
1470 | self.sizer5.Clear(True) |
---|
1471 | box_description= wx.StaticBox(self, -1,str(title)) |
---|
1472 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
1473 | #-------------------------------------------------------------- |
---|
1474 | self.qmin = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) |
---|
1475 | self.qmin.SetValue(str(self.qmin_x)) |
---|
1476 | self.qmin.SetToolTipString("Minimun value of Q in linear scale.") |
---|
1477 | self.qmin.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
1478 | self.qmin.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
1479 | self.qmin.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) |
---|
1480 | |
---|
1481 | self.qmax = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) |
---|
1482 | self.qmax.SetValue(str(self.qmax_x)) |
---|
1483 | self.qmax.SetToolTipString("Maximum value of Q in linear scale.") |
---|
1484 | self.qmax.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
1485 | self.qmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
1486 | self.qmax.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) |
---|
1487 | |
---|
1488 | sizer_horizontal=wx.BoxSizer(wx.HORIZONTAL) |
---|
1489 | sizer= wx.GridSizer(3, 3,5, 5) |
---|
1490 | |
---|
1491 | sizer.Add((5,5)) |
---|
1492 | sizer.Add(wx.StaticText(self, -1, 'Min')) |
---|
1493 | sizer.Add(wx.StaticText(self, -1, 'Max')) |
---|
1494 | sizer.Add(wx.StaticText(self, -1, 'Q range')) |
---|
1495 | |
---|
1496 | sizer.Add(self.qmin) |
---|
1497 | sizer.Add(self.qmax) |
---|
1498 | sizer_horizontal.Add(sizer) |
---|
1499 | if object!=None: |
---|
1500 | sizer_horizontal.Add(object) |
---|
1501 | |
---|
1502 | if object1!=None: |
---|
1503 | boxsizer1.Add(object1) |
---|
1504 | boxsizer1.Add((10,10)) |
---|
1505 | boxsizer1.Add(sizer_horizontal) |
---|
1506 | ## save state |
---|
1507 | self.save_current_state() |
---|
1508 | #---------------------------------------------------------------- |
---|
1509 | self.sizer5.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
1510 | self.sizer5.Layout() |
---|
1511 | self.Layout() |
---|
1512 | self.SetScrollbars(20,20,200,100) |
---|
1513 | |
---|
1514 | |
---|
1515 | def _fill_save_sizer(self): |
---|
1516 | """ |
---|
1517 | Draw the layout for saving option |
---|
1518 | """ |
---|
1519 | # Skipping save state functionality for release 0.9.0 |
---|
1520 | #return |
---|
1521 | |
---|
1522 | self.sizer6.Clear(True) |
---|
1523 | box_description= wx.StaticBox(self, -1,"Save Status") |
---|
1524 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
1525 | sizer_save = wx.BoxSizer(wx.HORIZONTAL) |
---|
1526 | |
---|
1527 | self.btSave_title = wx.StaticText(self, -1, 'Save the current panel status') |
---|
1528 | self.btSave = wx.Button(self,wx.NewId(),'Save') |
---|
1529 | self.btSave.Bind(wx.EVT_BUTTON, self.onSave,id= self.btSave.GetId()) |
---|
1530 | self.btSave.SetToolTipString("Save current panel status") |
---|
1531 | |
---|
1532 | sizer_save.Add(self.btSave_title) |
---|
1533 | sizer_save.Add((20,20),0, wx.LEFT|wx.RIGHT|wx.EXPAND,45) |
---|
1534 | |
---|
1535 | sizer_save.Add(self.btSave) |
---|
1536 | |
---|
1537 | boxsizer1.Add(sizer_save) |
---|
1538 | self.sizer6.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
1539 | self.sizer6.Layout() |
---|
1540 | self.SetScrollbars(20,20,200,100) |
---|
1541 | |
---|
1542 | |
---|
1543 | |
---|