- Timestamp:
- Mar 4, 2015 10:19:27 AM (10 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 091e71a2
- Parents:
- e46cbc5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/invariant/invariant_panel.py
rd838715 r1128bd31 8 8 import os 9 9 import wx 10 import logging 10 11 from wx.lib.scrolledpanel import ScrolledPanel 11 12 from sas.invariant import invariant … … 21 22 from sas.guiframe.panel_base import PanelBase 22 23 # The minimum q-value to be used when extrapolating 23 Q_MINIMUM 24 Q_MINIMUM = 1e-5 24 25 # The maximum q-value to be used when extrapolating 25 Q_MAXIMUM 26 Q_MAXIMUM = 10 26 27 # the ratio of maximum q value/(qmax of data) to plot the theory data 27 28 Q_MAXIMUM_PLOT = 3 … … 36 37 #default value of the power used for power law 37 38 POWER = 4.0 38 #Invariant panel size 39 #Invariant panel size 39 40 _BOX_WIDTH = 76 40 41 … … 42 43 if sys.platform.count("win32") > 0: 43 44 _STATICBOX_WIDTH = 450 44 PANEL_WIDTH = 500 45 PANEL_WIDTH = 500 45 46 PANEL_HEIGHT = 700 46 47 FONT_VARIANT = 0 … … 68 69 PanelBase.__init__(self, parent) 69 70 self.SetupScrolling() 70 #Font size 71 #Font size 71 72 self.SetWindowVariant(variant=FONT_VARIANT) 72 73 #Object that receive status event 73 74 self.parent = parent.parent 74 75 #plug-in using this panel 75 self._manager = manager 76 self._manager = manager 76 77 #Data uses for computation 77 78 self._data = data 78 self._scale = SCALE 79 self._scale = SCALE 79 80 self._background = BACKGROUND 80 81 self._bmark = None … … 121 122 self._reset_state_list() 122 123 ## Default file location for save 123 self._default_save_location = os.getcwd() 124 self._default_save_location = os.getcwd() 124 125 if self.parent is not None: 125 126 msg = "" … … 127 128 self._default_save_location = \ 128 129 self.parent.get_save_location() 129 130 130 131 self._set_bookmark_flag(False) 131 132 132 133 def get_data(self): 133 134 """ 134 135 """ 135 136 return self._manager.get_data() 136 137 137 138 def get_state(self): 138 139 """ 139 140 """ 140 141 return self.state 141 142 142 143 def set_data(self, data): 143 144 """ … … 150 151 self.get_state_by_num(0) 151 152 data_name = self._data.name 152 data_qmin = min 153 data_qmax = max 153 data_qmin = min(self._data.x) 154 data_qmax = max(self._data.x) 154 155 self.data_name_tcl.SetValue(str(data_name)) 155 156 self.data_min_tcl.SetValue(str(data_qmin)) … … 164 165 self._reset_state_list() 165 166 self._set_bookmark_flag(True) 166 return True 167 167 return True 168 168 169 def _delete_bookmark_items(self): 169 170 """ … … 180 181 continue 181 182 self.popUpMenu.DestroyItem(item) 182 183 183 184 def set_message(self): 184 185 """ … … 190 191 msg += "attention.\nPlease click on Details button." 191 192 self.hint_msg_txt.SetForegroundColour("red") 192 193 193 194 wx.PostEvent(self.parent, 194 StatusEvent(status=msg, info="warning"))195 StatusEvent(status=msg, info="warning")) 195 196 else: 196 197 msg = "For more information, click on Details button." 197 198 self.hint_msg_txt.SetForegroundColour("black") 198 199 wx.PostEvent(self.parent, 199 StatusEvent(status=msg, info="info"))200 StatusEvent(status=msg, info="info")) 200 201 self.hint_msg_txt.SetLabel(msg) 201 202 self.Layout() 202 203 203 204 def set_manager(self, manager): 204 205 """ 205 206 set value for the manager 206 207 """ 207 self._manager = manager 208 208 self._manager = manager 209 209 210 def save_project(self, doc=None): 210 211 """ … … 223 224 else: 224 225 doc = new_doc 225 return doc 226 return doc 226 227 227 228 def set_state(self, state=None, data=None): … … 229 230 set state when loading it from a .inv/.svs file 230 231 """ 231 232 232 233 if state == None and data == None: 233 234 self.state = IState() 234 elif state == None or data == None: 235 elif state == None or data == None: 235 236 return 236 237 else: … … 240 241 return 241 242 242 self.state = new_state 243 self.state.file = data.name 243 self.state = new_state 244 self.state.file = data.name 244 245 245 246 num = self.state.saved_state['state_num'] 246 if num > 0 247 if num > 0: 247 248 self._set_undo_flag(True) 248 249 if num < len(state.state_list) - 1: 249 250 self._set_redo_flag(True) 250 251 251 252 # get bookmarks 252 253 self.bookmark_num = len(self.state.bookmark_list) … … 256 257 #bookmark_num = ind 257 258 value = self.state.bookmark_list[ind] 258 name = "%d] bookmarked at %s on %s" % (ind, value[0], value[1])259 name = "%d] bookmarked at %s on %s" % (ind, value[0], value[1]) 259 260 # append it to menu 260 261 id = wx.NewId() 261 262 self.popUpMenu.Append(id, name, str('')) 262 wx.EVT_MENU(self, id, self._back_to_bookmark) 263 wx.PostEvent(self.parent, AppendBookmarkEvent(title=name, 264 hint='', 265 handler=self._back_to_bookmark)) 263 wx.EVT_MENU(self, id, self._back_to_bookmark) 264 wx.PostEvent(self.parent, 265 AppendBookmarkEvent(title=name, 266 hint='', 267 handler=self._back_to_bookmark)) 266 268 267 269 self.get_state_by_num(state_num=str(num)) 268 269 self._get_input_list() 270 271 self._get_input_list() 270 272 #make sure that the data is reset (especially 271 273 # when loaded from a inv file) 272 274 self.state.data = self._data 273 275 self._set_preview_flag(False) 274 self.new_state = False 276 self.new_state = False 275 277 self.is_state_data = False 276 278 … … 279 281 Clear panel to defaults, used by set_state of manager 280 282 """ 281 283 282 284 self._data = None 283 285 # default data testctrl … … 312 314 msg = "Receive invalid value for background : %s" % (background) 313 315 raise ValueError, msg 314 316 315 317 def get_scale(self): 316 318 """ … … 329 331 else: 330 332 raise ValueError, "Receive invalid value for scale : %s" % (scale) 331 333 332 334 def get_contrast(self): 333 335 """ … … 336 338 par_str = self.contrast_tcl.GetValue().strip() 337 339 contrast = None 338 if par_str != " " and check_float(self.contrast_tcl):340 if par_str != " " and check_float(self.contrast_tcl): 339 341 contrast = float(par_str) 340 342 return contrast 341 343 342 344 def get_extrapolation_type(self, low_q, high_q): 343 345 """ … … 352 354 extrapolation = "both" 353 355 return extrapolation 354 356 355 357 def get_porod_const(self): 356 358 """ … … 362 364 porod_const = float(par_str) 363 365 return porod_const 364 366 365 367 def get_volume(self, inv, contrast, extrapolation): 366 368 """ … … 369 371 if contrast is not None: 370 372 try: 371 v, dv = inv.get_volume_fraction_with_error(contrast=contrast, 372 extrapolation=extrapolation)373 v, dv = inv.get_volume_fraction_with_error(contrast=contrast, 374 extrapolation=extrapolation) 373 375 self.volume_tcl.SetValue(format_number(v)) 374 376 self.volume_err_tcl.SetValue(format_number(dv)) … … 381 383 info="error", 382 384 type="stop")) 383 385 384 386 def get_surface(self, inv, contrast, porod_const, extrapolation): 385 387 """ … … 389 391 try: 390 392 s, ds = inv.get_surface_with_error(contrast=contrast, 391 porod_const=porod_const,392 extrapolation=extrapolation)393 porod_const=porod_const, 394 extrapolation=extrapolation) 393 395 self.surface_tcl.SetValue(format_number(s)) 394 396 self.surface_err_tcl.SetValue(format_number(ds)) … … 399 401 msg += "specific surface: %s" % sys.exc_value 400 402 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error", 401 402 403 type="stop")) 404 403 405 def get_total_qstar(self, inv, extrapolation): 404 406 """ … … 420 422 msg = "Error occurred computing invariant using" 421 423 msg += " extrapolation: %s" % sys.exc_value 422 wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop"))423 424 wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop")) 425 424 426 def get_low_qstar(self, inv, npts_low, low_q=False): 425 427 """ … … 427 429 """ 428 430 if low_q: 429 try: 431 try: 430 432 qstar_low, qstar_low_err = inv.get_qstar_low() 431 433 self.inv_container.qstar_low = qstar_low 432 434 self.inv_container.qstar_low_err = qstar_low_err 433 extrapolated_data = inv.get_extra_data_low(npts_in=npts_low) 434 power_low = inv.get_extrapolation_power(range='low') 435 extrapolated_data = inv.get_extra_data_low(npts_in=npts_low) 436 power_low = inv.get_extrapolation_power(range='low') 435 437 if self.power_law_low.GetValue(): 436 438 self.power_low_tcl.SetValue(format_number(power_low)) 437 439 self._manager.plot_theory(data=extrapolated_data, 438 440 name="Low-Q extrapolation") 439 441 except: 440 442 self.inv_container.qstar_low = "ERROR" … … 449 451 try: 450 452 self._manager.plot_theory(name="Low-Q extrapolation") 451 except: 452 pass453 453 except: 454 logging.error(sys.exc_value) 455 454 456 def get_high_qstar(self, inv, high_q=False): 455 457 """ … … 457 459 """ 458 460 if high_q: 459 try: 461 try: 460 462 qmax_plot = Q_MAXIMUM_PLOT * max(self._data.x) 461 if qmax_plot > Q_MAXIMUM: 463 if qmax_plot > Q_MAXIMUM: 462 464 qmax_plot = Q_MAXIMUM 463 465 qstar_high, qstar_high_err = inv.get_qstar_high() 464 466 self.inv_container.qstar_high = qstar_high 465 467 self.inv_container.qstar_high_err = qstar_high_err 466 power_high = inv.get_extrapolation_power(range='high') 468 power_high = inv.get_extrapolation_power(range='high') 467 469 self.power_high_tcl.SetValue(format_number(power_high)) 468 470 high_out_data = inv.get_extra_data_high(q_end=qmax_plot, 469 471 npts=500) 470 472 self._manager.plot_theory(data=high_out_data, 471 473 name="High-Q extrapolation") 472 474 except: 473 475 #raise … … 483 485 try: 484 486 self._manager.plot_theory(name="High-Q extrapolation") 485 except: 486 pass487 except: 488 logging.error(sys.exc_value) 487 489 488 490 def get_qstar(self, inv): … … 493 495 self.inv_container.qstar = qstar 494 496 self.inv_container.qstar_err = qstar_err 495 497 496 498 def set_extrapolation_low(self, inv, low_q=False): 497 499 """ … … 513 515 power_low = float(power_low) 514 516 else: 515 if low_q 517 if low_q: 516 518 #Raise error only when qstar at low q is requested 517 519 msg = "Expect float for power at low q, " 518 520 msg += " got %s" % (power_low) 519 wx.PostEvent(self.parent, StatusEvent(status=msg, 520 info="error", 521 type="stop")) 522 521 wx.PostEvent(self.parent, 522 StatusEvent(status=msg, 523 info="error", 524 type="stop")) 525 523 526 #Get the number of points to extrapolated 524 npts_low = self.npts_low_tcl.GetValue().lstrip().rstrip() 527 npts_low = self.npts_low_tcl.GetValue().lstrip().rstrip() 525 528 if check_float(self.npts_low_tcl): 526 529 npts_low = float(npts_low) … … 529 532 msg = "Expect float for number of points at low q," 530 533 msg += " got %s" % (npts_low) 531 wx.PostEvent(self.parent, StatusEvent(status=msg, 532 info="error", 533 type="stop")) 534 wx.PostEvent(self.parent, 535 StatusEvent(status=msg, 536 info="error", 537 type="stop")) 534 538 #Set the invariant calculator 535 539 inv.set_extrapolation(range="low", npts=npts_low, 536 function=function_low, power=power_low)537 return inv, npts_low 538 540 function=function_low, power=power_low) 541 return inv, npts_low 542 539 543 540 544 def set_extrapolation_high(self, inv, high_q=False): … … 557 561 msg = "Expect float for power at high q," 558 562 msg += " got %s" % (power_high) 559 wx.PostEvent(self.parent, StatusEvent(status=msg, 560 info="error", 561 type="stop")) 562 563 npts_high = self.npts_high_tcl.GetValue().lstrip().rstrip() 563 wx.PostEvent(self.parent, 564 StatusEvent(status=msg, 565 info="error", 566 type="stop")) 567 568 npts_high = self.npts_high_tcl.GetValue().lstrip().rstrip() 564 569 if check_float(self.npts_high_tcl): 565 570 npts_high = float(npts_high) … … 568 573 msg = "Expect float for number of points at high q," 569 574 msg += " got %s" % (npts_high) 570 wx.PostEvent(self.parent, StatusEvent(status=msg, 571 info="error",572 type="stop"))575 wx.PostEvent(self.parent, StatusEvent(status=msg, 576 info="error", 577 type="stop")) 573 578 inv.set_extrapolation(range="high", npts=npts_high, 574 579 function=function_high, power=power_high) 575 580 return inv, npts_high 576 581 577 582 def display_details(self, event): 578 583 """ 579 584 open another panel for more details on invariant calculation 580 585 """ 581 panel = InvariantDetailsPanel(parent=self, 582 586 panel = InvariantDetailsPanel(parent=self, 587 qstar_container=self.inv_container) 583 588 panel.ShowModal() 584 589 panel.Destroy() 585 590 self.button_calculate.SetFocus() 586 591 587 592 def compute_invariant(self, event=None): 588 593 """ 589 compute invariant 594 compute invariant 590 595 """ 591 596 if self._data == None: … … 594 599 wx.PostEvent(self.parent, StatusEvent(status=msg)) 595 600 # set a state for this computation for saving 596 elif event != None: 601 elif event != None: 597 602 self._set_compute_state(state='compute') 598 603 self._set_bookmark_flag(True) 599 msg = "\n\nStarting a new invariant computation..." 604 msg = "\n\nStarting a new invariant computation..." 600 605 wx.PostEvent(self.parent, StatusEvent(status=msg)) 601 606 602 607 603 608 if self._data is None: 604 609 return 605 610 self.button_details.Enable() 606 #clear outputs textctrl 611 #clear outputs textctrl 607 612 self._reset_output() 608 613 try: … … 613 618 wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop")) 614 619 return 615 620 616 621 low_q = self.enable_low_cbox.GetValue() 617 high_q = self.enable_high_cbox.GetValue() 622 high_q = self.enable_high_cbox.GetValue() 618 623 temp_data = copy.deepcopy(self._data) 619 620 #set invariant calculator 624 625 #set invariant calculator 621 626 inv = invariant.InvariantCalculator(data=temp_data, 622 627 background=background, … … 628 633 msg = "Error occurred computing invariant: %s" % sys.exc_value 629 634 wx.PostEvent(self.parent, StatusEvent(status=msg, 630 info="warning", type="stop"))635 info="warning", type="stop")) 631 636 return 632 637 #check the type of extrapolation 633 638 extrapolation = self.get_extrapolation_type(low_q=low_q, high_q=high_q) 634 639 635 640 #Compute invariant 636 bkg_changed = False637 scale_changed = False638 641 try: 639 642 self.get_qstar(inv=inv) 640 #if scale_changed or bkg_changed:641 #self._manager.plot_data(data=inv.get_data())642 643 643 except: 644 msg = "Error occurred computing invariant: %s" % sys.exc_value645 wx.PostEvent(self.parent, StatusEvent(status=msg, 644 msg = "Error occurred computing invariant: %s" % sys.exc_value 645 wx.PostEvent(self.parent, StatusEvent(status=msg, 646 646 info="warning", 647 647 type="stop")) … … 651 651 try: 652 652 r_msg = 'Low Q: ' 653 #Compute qstar extrapolated to low q range 653 #Compute qstar extrapolated to low q range 654 654 self.get_low_qstar(inv=inv, npts_low=npts_low, low_q=low_q) 655 655 r_msg = 'High Q: ' 656 #Compute qstar extrapolated to high q range 656 #Compute qstar extrapolated to high q range 657 657 self.get_high_qstar(inv=inv, high_q=high_q) 658 658 r_msg = '' 659 #Compute qstar extrapolated to total q range 659 #Compute qstar extrapolated to total q range 660 660 #and set value to txtcrtl 661 661 self.get_total_qstar(inv=inv, extrapolation=extrapolation) 662 662 # Parse additional parameters 663 porod_const = self.get_porod_const() 663 porod_const = self.get_porod_const() 664 664 contrast = self.get_contrast() 665 665 except: 666 666 msg = r_msg + "Error occurred computing invariant: %s" % \ 667 667 sys.exc_value 668 wx.PostEvent(self.parent, StatusEvent(status=msg, 668 wx.PostEvent(self.parent, StatusEvent(status=msg, 669 669 info="error", 670 670 type="stop")) … … 681 681 try: 682 682 self.get_surface(inv=inv, contrast=contrast, 683 porod_const=porod_const,684 685 683 porod_const=porod_const, 684 extrapolation=extrapolation) 685 686 686 except: 687 687 msg = "Error occurred computing invariant: %s" % sys.exc_value … … 689 689 info="warning", 690 690 type="stop")) 691 691 692 692 #compute percentage of each invariant 693 693 self.inv_container.compute_percentage() 694 694 695 695 #display a message 696 696 self.set_message() … … 703 703 self.state.set_report_string() 704 704 self.is_power_out = False 705 wx.PostEvent(self.parent, StatusEvent(status = msg))705 wx.PostEvent(self.parent, StatusEvent(status=msg)) 706 706 707 707 #enable the button_ok for more details 708 708 self._set_preview_flag(True) 709 710 if event != None: 709 710 if event != None: 711 711 self._set_preview_flag(True) 712 712 self._set_save_flag(True) 713 713 wx.PostEvent(self.parent, 714 StatusEvent(status='\nFinished invariant computation...'))714 StatusEvent(status='\nFinished invariant computation...')) 715 715 #self.Show(True) 716 716 self.Refresh() 717 717 718 718 def on_undo(self, event=None): 719 719 """ 720 720 Go back to the previous state 721 721 722 722 : param event: undo button event 723 723 """ … … 729 729 730 730 self.get_state_by_num(state_num=str(pre_state_num)) 731 731 732 732 if float(pre_state_num) <= 0: 733 733 self._set_undo_flag(False) … … 735 735 self._set_undo_flag(True) 736 736 self._set_redo_flag(True) 737 self.is_power_out = False 737 self.is_power_out = False 738 738 self._info_state_num() 739 739 740 740 741 741 def on_redo(self, event=None): 742 742 """ 743 743 Go forward to the previous state 744 744 745 745 : param event: redo button event 746 746 """ … … 750 750 751 751 self.get_state_by_num(state_num=str(next_state_num)) 752 753 if float(next_state_num) +2 > len(self.state.state_list):752 753 if float(next_state_num) + 2 > len(self.state.state_list): 754 754 self._set_redo_flag(False) 755 755 else: 756 756 self._set_redo_flag(True) 757 757 758 758 self._set_undo_flag(True) 759 759 self.is_power_out = False 760 760 self._info_state_num() 761 761 762 762 def on_preview(self, event=None): 763 763 """ 764 764 Invoke report dialog panel 765 765 766 766 : param event: report button event 767 767 """ … … 775 775 dialog = ReportDialog(report_list, None, -1, "") 776 776 dialog.Show() 777 777 778 778 def get_state_by_num(self, state_num=None): 779 779 """ 780 780 Get the state given by number 781 781 782 782 : param state_num: the given state number 783 """ 783 """ 784 784 if state_num == None: 785 785 return 786 786 787 787 backup_state_list = copy.deepcopy(self.state.state_list) 788 788 789 789 # get the previous state 790 790 try: 791 791 current_state = copy.deepcopy(self.state.state_list[str(state_num)]) 792 # get the previously computed state number 792 # get the previously computed state number 793 793 #(computation before the state changes happened) 794 794 current_compute_num = str(current_state['compute_num']) 795 except 795 except: 796 796 raise 797 #raise ValueError, "No such state exists in history" 798 797 799 798 # get the state at pre_compute_num 800 799 comp_state = copy.deepcopy(self.state.state_list[current_compute_num]) … … 808 807 exec "self.%s.SetValue(%s)" % (key, value) 809 808 except: 810 pass811 809 logging.error(sys.exc_value) 810 812 811 self.compute_invariant(event=None) 813 812 814 813 # set the input params at the state at pre_state_num 815 814 for key in current_state: … … 821 820 exec 'self.%s.SetValue(%s)' % (key, value) 822 821 except: 823 pass822 logging.error(sys.exc_value) 824 823 825 824 self._enable_high_q_section(event=None) … … 829 828 self.state.state_num = state_num 830 829 831 830 832 831 def get_bookmark_by_num(self, num=None): 833 832 """ 834 833 Get the bookmark state given by number 835 834 836 835 : param num: the given bookmark number 837 836 838 837 """ 839 838 current_state = {} … … 843 842 # get the previous state 844 843 try: 845 _, _, current_state,comp_state = self.state.bookmark_list[int(num)] 846 except : 847 raise ValueError, "No such bookmark exists" 844 _, _, current_state, comp_state = self.state.bookmark_list[int(num)] 845 except: 846 logging.error(sys.exc_value) 847 raise ValueError, "No such bookmark exists" 848 848 849 849 # set the parameters … … 855 855 exec "self.%s.SetValue(%s)" % (key, value) 856 856 except: 857 pass857 logging.error(sys.exc_value) 858 858 859 859 self.compute_invariant(event=None) … … 866 866 exec 'self.%s.SetValue(%s)' % (key, value) 867 867 except: 868 pass868 logging.error(sys.exc_value) 869 869 self.state.saved_state = copy.deepcopy(current_state) 870 870 871 871 self._enable_high_q_section(event=None) 872 872 self._enable_low_q_section(event=None) … … 880 880 """ 881 881 self.background_tcl.SetValue(str(BACKGROUND)) 882 self.scale_tcl.SetValue(str(SCALE)) 882 self.scale_tcl.SetValue(str(SCALE)) 883 883 self.contrast_tcl.SetValue(str(CONTRAST)) 884 self.porod_constant_tcl.SetValue('') 884 self.porod_constant_tcl.SetValue('') 885 885 self.npts_low_tcl.SetValue(str(NPTS)) 886 886 self.enable_low_cbox.SetValue(False) … … 906 906 self.button_calculate.SetFocus() 907 907 #self.SetupScrolling() 908 908 909 909 def _set_state(self, event): 910 910 """ 911 911 Set the state list 912 912 913 913 :param event: rb/cb event 914 914 """ … … 923 923 924 924 try: 925 if value == None or value.lstrip().rstrip() == '':925 if value == None or value.lstrip().rstrip() == '': 926 926 value = 'None' 927 927 exec 'self.state.%s = %s' % (name, value) 928 exec "self.state.saved_state['%s'] = %s" % 929 930 # set the count part of radio button clicked 928 exec "self.state.saved_state['%s'] = %s" % (name, value) 929 930 # set the count part of radio button clicked 931 931 #False for the saved_state 932 932 for title, content in rb_list: 933 if name == 934 name = content 935 value = False 933 if name == title: 934 name = content 935 value = False 936 936 elif name == content: 937 937 name = title 938 value = False 939 exec "self.state.saved_state['%s'] = %s" % (name, value)940 938 value = False 939 exec "self.state.saved_state['%s'] = %s" % (name, value) 940 941 941 # Instead of changing the future, create a new future. 942 max_state_num = len(self.state.state_list) - 1 943 self.state.saved_state['state_num'] = max_state_num 944 942 max_state_num = len(self.state.state_list) - 1 943 self.state.saved_state['state_num'] = max_state_num 944 945 945 self.state.saved_state['state_num'] += 1 946 946 self.state.state_num = self.state.saved_state['state_num'] 947 947 self.state.state_list[str(self.state.state_num)] = \ 948 948 self.state.clone_state() 949 except: 950 pass951 949 except: 950 logging.error(sys.exc_value) 951 952 952 self._set_undo_flag(True) 953 953 self._set_redo_flag(False) 954 954 #event.Skip() 955 955 956 956 def _set_compute_state(self, state=None): 957 957 """ 958 958 Notify the compute_invariant state to self.state 959 959 960 960 : param state: set 'compute' when the computation is 961 961 activated by the 'compute' button, else None 962 962 963 963 """ 964 964 # reset the default … … 969 969 self.is_power_out = True 970 970 # Instead of changing the future, create a new future. 971 max_state_num = len(self.state.state_list) - 1 972 self.state.saved_state['state_num'] = max_state_num 971 max_state_num = len(self.state.state_list) - 1 972 self.state.saved_state['state_num'] = max_state_num 973 973 # A new computation is also A state 974 974 #copy.deepcopy(self.state.saved_state) … … 977 977 self.state.state_num = temp_saved_states['state_num'] 978 978 979 980 # set the state number of the computation 979 980 # set the state number of the computation 981 981 if state == 'compute': 982 982 temp_saved_states['compute_num'] = self.state.state_num … … 985 985 self.state.state_list[str(self.state.state_num)] = \ 986 986 self.state.clone_state() 987 987 988 988 # A computation is a new state, so delete the states with any higher 989 989 # state numbers 990 for i in range(self.state.state_num +1, len(self.state.state_list)):990 for i in range(self.state.state_num + 1, len(self.state.state_list)): 991 991 try: 992 del (self.state.state_list[str(i)])993 except: 994 pass992 del self.state.state_list[str(i)] 993 except: 994 logging.error(sys.exc_value) 995 995 # Enable the undo button if it was not 996 996 self._set_undo_flag(True) 997 997 self._set_redo_flag(False) 998 998 999 999 def _reset_state_list(self, data=None): 1000 1000 """ … … 1005 1005 #temp_state = self.state.clone_state() 1006 1006 #copy.deepcopy(self.state.saved_state) 1007 # Clear the list 1007 # Clear the list 1008 1008 self.state.state_list.clear() 1009 1009 self.state.bookmark_list.clear() … … 1030 1030 self._set_save_flag(False) 1031 1031 1032 1032 1033 1033 def _on_text(self, event): 1034 1034 """ 1035 1035 Catch text change event to add the state to the state_list 1036 1036 1037 1037 :param event: txtctr event ; assumes not None 1038 1039 """ 1040 if self._data == None: 1038 1039 """ 1040 if self._data == None: 1041 1041 return 1042 1042 # check if this event is from do/undo button … … 1044 1044 #event.Skip() 1045 1045 return 1046 1046 1047 1047 # get the object 1048 1048 obj = event.GetEventObject() … … 1053 1053 # text event is a new state, so delete the states with higher state_num 1054 1054 # i.e., change the future 1055 for i in range(int(state_num) +1, len(self.state.state_list)):1055 for i in range(int(state_num) + 1, len(self.state.state_list)): 1056 1056 try: 1057 del (self.state.state_list[str(i)])1058 except: 1059 pass1060 1057 del self.state.state_list[str(i)] 1058 except: 1059 logging.error(sys.exc_value) 1060 1061 1061 # Instead of changing the future, create a new future. 1062 #max_state_num = len(self.state.state_list)-1 1062 #max_state_num = len(self.state.state_list)-1 1063 1063 #self.state.saved_state['state_num'] = max_state_num 1064 1064 1065 1065 # try to add new state of the text changes in the state_list 1066 1066 try: 1067 if value.strip() == None: 1067 if value.strip() == None: 1068 1068 value = '' 1069 1069 exec "self.state.%s = '%s'" % (name, value) 1070 exec "self.state.saved_state['%s'] = '%s'" % 1070 exec "self.state.saved_state['%s'] = '%s'" % (name, value) 1071 1071 exec "self.state.input_list['%s'] = '%s'" % (name, value) 1072 1072 if not self.is_power_out: … … 1078 1078 self.state.clone_state() 1079 1079 except: 1080 pass1080 logging.error(sys.exc_value) 1081 1081 1082 1082 #event.Skip() … … 1085 1085 self._set_bookmark_flag(True) 1086 1086 self._set_preview_flag(False) 1087 1088 def _on_out_text(self, event): 1089 """ 1090 Catch ouput text change to add the state 1091 1087 1088 def _on_out_text(self, event): 1089 """ 1090 Catch ouput text change to add the state 1091 1092 1092 :param event: txtctr event ; assumes not None 1093 1094 """ 1093 1094 """ 1095 1095 # get the object 1096 1096 obj = event.GetEventObject() … … 1098 1098 value = str(obj.GetValue()) 1099 1099 try: 1100 exec "self.state.saved_state['%s'] = '%s'" % 1100 exec "self.state.saved_state['%s'] = '%s'" % (name, value) 1101 1101 self.state.state_list[str(self.state.state_num)] = \ 1102 1102 self.state.clone_state() 1103 1103 except: 1104 pass1104 logging.error(sys.exc_value) 1105 1105 #if event != None: event.Skip() 1106 1106 1107 def _get_input_list(self): 1107 def _get_input_list(self): 1108 1108 """ 1109 1109 get input_list; called by set_state 1110 """ 1110 """ 1111 1111 # get state num of the last compute state 1112 1112 compute_num = self.state.saved_state['compute_num'] 1113 1113 # find values and put into the input list 1114 for key1, value1 in self.state.state_list[str(compute_num)].iteritems(): 1115 for key, _ in self.state.input_list.iteritems(): 1114 for key1, value1 in self.state.state_list[str(compute_num)].iteritems(): 1115 for key, _ in self.state.input_list.iteritems(): 1116 1116 if key == key1: 1117 1117 self.state.input_list[key] = value1 1118 1118 break 1119 1119 1120 1120 def _set_bookmark_menu(self): 1121 1121 """ … … 1132 1132 self.popUpMenu.AppendSeparator() 1133 1133 self.Bind(wx.EVT_CONTEXT_MENU, self._on_context_menu) 1134 1134 1135 1135 def on_bookmark(self, event): 1136 1136 """ 1137 1137 Save the panel state in memory and add the list on 1138 1138 the popup menu on bookmark context menu event 1139 """ 1140 if self._data == None: 1139 """ 1140 if self._data == None: 1141 1141 return 1142 if event == None: 1142 if event == None: 1143 1143 return 1144 1144 self.bookmark_num += 1 … … 1148 1148 compute_num = self.state.saved_state['compute_num'] 1149 1149 # name and message of the bookmark list 1150 msg = "State saved at %s on %s"% (my_time, date)1151 ## post help message for the selected model1150 msg = "State saved at %s on %s" % (my_time, date) 1151 ## post help message for the selected model 1152 1152 msg += " Right click on the panel to retrieve this state" 1153 1153 #wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1154 name = "%d] bookmarked at %s on %s" % (self.bookmark_num, my_time, date)1155 1154 name = "%d] bookmarked at %s on %s" % (self.bookmark_num, my_time, date) 1155 1156 1156 # append it to menu 1157 1157 id = wx.NewId() … … 1161 1161 comp_state = copy.deepcopy(self.state.state_list[str(compute_num)]) 1162 1162 self.state.bookmark_list[self.bookmark_num] = [my_time, date, 1163 state, comp_state]1163 state, comp_state] 1164 1164 self.state.toXML(self, doc=None, entry_node=None) 1165 1165 1166 1166 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info")) 1167 wx.PostEvent(self.parent, 1168 AppendBookmarkEvent(title=name, 1167 wx.PostEvent(self.parent, 1168 AppendBookmarkEvent(title=name, 1169 1169 hint=str(msg), 1170 1170 handler=self._back_to_bookmark)) 1171 1171 1172 1172 def _back_to_bookmark(self, event): … … 1178 1178 self._manager.on_perspective(event) 1179 1179 menu = event.GetEventObject() 1180 ## post help message for the selected model 1180 ## post help message for the selected model 1181 1181 msg = menu.GetHelpString(event.GetId()) 1182 1182 msg += " reloaded" 1183 wx.PostEvent(self.parent, StatusEvent(status = msg))1184 1183 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1184 1185 1185 name = menu.GetLabel(event.GetId()) 1186 1187 num, time= name.split(']')1188 current_state_num = self.state.state_num 1186 1187 num, _ = name.split(']') 1188 current_state_num = self.state.state_num 1189 1189 self.get_bookmark_by_num(num) 1190 1190 state_num = int(current_state_num) + 1 1191 1191 1192 1192 self.state.saved_state['state_num'] = state_num 1193 1193 #copy.deepcopy(self.state.saved_state) 1194 1194 self.state.state_list[str(state_num)] = self.state.clone_state() 1195 1195 self.state.state_num = state_num 1196 1196 1197 1197 self._set_undo_flag(True) 1198 1198 self._info_bookmark_num(event) 1199 1199 1200 1200 def _info_bookmark_num(self, event=None): 1201 1201 """ 1202 1202 print the bookmark number in info 1203 1203 1204 1204 : event: popUpMenu event 1205 1205 """ 1206 if event == None: 1206 if event == None: 1207 1207 return 1208 1208 # get the object … … 1211 1211 text = item.GetText() 1212 1212 num = text.split(']')[0] 1213 msg = "bookmark num = %s " % num1214 1215 wx.PostEvent(self.parent, StatusEvent(status = msg))1216 1213 msg = "bookmark num = %s " % num 1214 1215 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1216 1217 1217 def _info_state_num(self): 1218 1218 """ … … 1221 1221 msg = "state num = " 1222 1222 msg += self.state.state_num 1223 1224 wx.PostEvent(self.parent, StatusEvent(status =msg))1225 1223 1224 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1225 1226 1226 def _get_time_stamp(self): 1227 1227 """ 1228 1228 return time and date stings 1229 1229 """ 1230 # date and time 1230 # date and time 1231 1231 year, month, day, hour, minute, second, _, _, _ = \ 1232 1232 time.localtime() 1233 1233 my_time = str(hour) + ":" + str(minute) + ":" + str(second) 1234 date = str( 1234 date = str(month) + "/" + str(day) + "/" + str(year) 1235 1235 return my_time, date 1236 1237 1238 def on_save(self, evt=None): 1236 1237 1238 def on_save(self, evt=None): 1239 1239 """ 1240 1240 Save invariant state into a file … … 1257 1257 else: 1258 1258 return None 1259 1259 1260 1260 dlg.Destroy() 1261 1261 # MAC always needs the extension for saving … … 1264 1264 fName = os.path.splitext(path)[0] + extens 1265 1265 self._manager.save_file(filepath=fName, state=self.state) 1266 1266 1267 1267 def _show_message(self, mssg='', msg='Warning'): 1268 1268 """ … … 1271 1271 # no message for now 1272 1272 return True 1273 1273 1274 1274 def _reset_output(self): 1275 1275 """ … … 1285 1285 self.inv_container = InvariantContainer() 1286 1286 1287 1287 1288 1288 def _on_context_menu(self, event): 1289 1289 """ … … 1292 1292 pos = event.GetPosition() 1293 1293 pos = self.ScreenToClient(pos) 1294 1295 self.PopupMenu(self.popUpMenu, pos) 1296 1294 1295 self.PopupMenu(self.popUpMenu, pos) 1296 1297 1297 def _define_structure(self): 1298 1298 """ 1299 1299 Define main sizers needed for this panel 1300 1300 """ 1301 ## Box sizers must be defined first before 1301 ## Box sizers must be defined first before 1302 1302 #defining buttons/textctrls (MAC). 1303 1303 self.main_sizer = wx.BoxSizer(wx.VERTICAL) … … 1309 1309 data_name_box = wx.StaticBox(self, -1, "I(q) Data Source") 1310 1310 self.data_name_boxsizer = wx.StaticBoxSizer(data_name_box, wx.VERTICAL) 1311 self.data_name_boxsizer.SetMinSize((_STATICBOX_WIDTH, -1))1311 self.data_name_boxsizer.SetMinSize((_STATICBOX_WIDTH, -1)) 1312 1312 self.hint_msg_sizer = wx.BoxSizer(wx.HORIZONTAL) 1313 1313 self.data_name_sizer = wx.BoxSizer(wx.HORIZONTAL) 1314 1314 1315 1315 self.data_range_sizer = wx.BoxSizer(wx.HORIZONTAL) 1316 1316 #Sizer related to inputs 1317 self.sizer_input = 1317 self.sizer_input = wx.FlexGridSizer(2, 6, 0, 0) 1318 1318 #Sizer related to inputs 1319 1319 inputs_box = wx.StaticBox(self, -1, "Customized Inputs") … … 1323 1323 extrapolation_box = wx.StaticBox(self, -1, "Extrapolation") 1324 1324 self.extrapolation_sizer = wx.StaticBoxSizer(extrapolation_box, 1325 1325 wx.VERTICAL) 1326 1326 self.extrapolation_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) 1327 1327 self.extrapolation_range_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 1330 1330 low_q_box = wx.StaticBox(self, -1, "Low Q") 1331 1331 self.low_extrapolation_sizer = wx.StaticBoxSizer(low_q_box, wx.VERTICAL) 1332 1332 1333 1333 self.low_q_sizer = wx.GridBagSizer(5, 5) 1334 1334 #Sizer related to extrapolation at low q range … … 1346 1346 #Sizer related to save button 1347 1347 self.save_button_sizer = wx.BoxSizer(wx.HORIZONTAL) 1348 1348 1349 1349 def _layout_data_name(self): 1350 1350 """ 1351 1351 Draw widgets related to data's name 1352 1352 """ 1353 #Sizer hint 1353 #Sizer hint 1354 1354 hint_msg = "" 1355 1356 self.hint_msg_txt = wx.StaticText(self, -1, hint_msg) 1355 1356 self.hint_msg_txt = wx.StaticText(self, -1, hint_msg) 1357 1357 self.hint_msg_txt.SetForegroundColour("red") 1358 1358 msg = "Highlight = mouse the mouse's cursor on the data until" … … 1361 1361 self.hint_msg_sizer.Add(self.hint_msg_txt) 1362 1362 #Data name [string] 1363 data_name_txt = wx.StaticText(self, -1, 'Name:') 1364 1365 self.data_name_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH *4, 20),1366 style=0) 1363 data_name_txt = wx.StaticText(self, -1, 'Name:') 1364 1365 self.data_name_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH * 4, 20), 1366 style=0) 1367 1367 self.data_name_tcl.SetToolTipString("Data's name.") 1368 self.data_name_sizer.AddMany([(data_name_txt, 0, wx.LEFT |wx.RIGHT, 10),1369 1368 self.data_name_sizer.AddMany([(data_name_txt, 0, wx.LEFT | wx.RIGHT, 10), 1369 (self.data_name_tcl, 0, wx.EXPAND)]) 1370 1370 #Data range [string] 1371 data_range_txt = wx.StaticText(self, -1, 'Total Q Range (1/A): ') 1372 data_min_txt = wx.StaticText(self, -1, 'Min : ') 1371 data_range_txt = wx.StaticText(self, -1, 'Total Q Range (1/A): ') 1372 data_min_txt = wx.StaticText(self, -1, 'Min : ') 1373 1373 self.data_min_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 1374 1374 style=0, name='data_min_tcl') 1375 1375 self.data_min_tcl.SetToolTipString("The minimum value of q range.") 1376 data_max_txt = wx.StaticText(self, -1, 'Max : ') 1376 data_max_txt = wx.StaticText(self, -1, 'Max : ') 1377 1377 self.data_max_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 1378 style=0, name='data_max_tcl') 1378 style=0, name='data_max_tcl') 1379 1379 self.data_max_tcl.SetToolTipString("The maximum value of q range.") 1380 1380 self.data_range_sizer.AddMany([(data_range_txt, 0, wx.RIGHT, 5), … … 1383 1383 (data_max_txt, 0, wx.RIGHT, 5), 1384 1384 (self.data_max_tcl, 0, wx.RIGHT, 10)]) 1385 self.data_name_boxsizer.AddMany([(self.hint_msg_sizer, 0 1386 (self.data_name_sizer, 0, wx.ALL, 10),1387 (self.data_range_sizer, 0, wx.ALL, 10)])1388 1385 self.data_name_boxsizer.AddMany([(self.hint_msg_sizer, 0, wx.ALL, 5), 1386 (self.data_name_sizer, 0, wx.ALL, 10), 1387 (self.data_range_sizer, 0, wx.ALL, 10)]) 1388 1389 1389 def _enable_fit_power_law_low(self, event=None): 1390 1390 """ 1391 1391 Enable and disable the power value editing 1392 1392 """ 1393 if event != None: 1393 if event != None: 1394 1394 self._set_bookmark_flag(True) 1395 1395 self._set_preview_flag(False) 1396 1396 1397 1397 if self.fix_enable_low.IsEnabled(): 1398 1398 1399 1399 if self.fix_enable_low.GetValue(): 1400 1400 self.fit_enable_low.SetValue(False) … … 1404 1404 self.power_low_tcl.Disable() 1405 1405 self._set_state(event=event) 1406 1406 1407 1407 def _enable_low_q_section(self, event=None): 1408 1408 """ 1409 1409 Disable or enable some button if the user enable low q extrapolation 1410 1410 """ 1411 if event != None: 1411 if event != None: 1412 1412 self._set_bookmark_flag(True) 1413 1413 self._set_preview_flag(False) 1414 1414 1415 1415 if self.enable_low_cbox.GetValue(): 1416 1416 self.npts_low_tcl.Enable() … … 1426 1426 self.guinier.Disable() 1427 1427 self.power_law_low.Disable() 1428 1428 1429 1429 self._enable_power_law_low() 1430 1430 self._enable_fit_power_law_low() 1431 1431 self._set_state(event=event) 1432 1432 self.button_calculate.SetFocus() 1433 1433 1434 1434 def _enable_power_law_low(self, event=None): 1435 1435 """ 1436 1436 Enable editing power law section at low q range 1437 1437 """ 1438 if event != None: 1438 if event != None: 1439 1439 self._set_bookmark_flag(True) 1440 1440 self._set_preview_flag(False) … … 1451 1451 self._enable_fit_power_law_low() 1452 1452 self._set_state(event=event) 1453 1453 1454 1454 def _layout_extrapolation_low(self): 1455 1455 """ … … 1460 1460 name='enable_low_cbox') 1461 1461 wx.EVT_CHECKBOX(self, self.enable_low_cbox.GetId(), 1462 1462 self._enable_low_q_section) 1463 1463 self.fix_enable_low = wx.RadioButton(self, -1, 'Fix', 1464 (10, 10), style=wx.RB_GROUP,1465 name='fix_enable_low')1464 (10, 10), style=wx.RB_GROUP, 1465 name='fix_enable_low') 1466 1466 self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_low, 1467 1467 id=self.fix_enable_low.GetId()) 1468 1468 self.fit_enable_low = wx.RadioButton(self, -1, 'Fit', (10, 10), 1469 1469 name='fit_enable_low') 1470 self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_low, 1471 1470 self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_low, 1471 id=self.fit_enable_low.GetId()) 1472 1472 self.guinier = wx.RadioButton(self, -1, 'Guinier', 1473 1474 1473 (10, 10), style=wx.RB_GROUP, 1474 name='guinier') 1475 1475 self.Bind(wx.EVT_RADIOBUTTON, self._enable_power_law_low, 1476 id=self.guinier.GetId())1476 id=self.guinier.GetId()) 1477 1477 self.power_law_low = wx.RadioButton(self, -1, 'Power Law', 1478 1478 (10, 10), name='power_law_low') 1479 self.Bind(wx.EVT_RADIOBUTTON, self._enable_power_law_low, 1480 1481 1479 self.Bind(wx.EVT_RADIOBUTTON, self._enable_power_law_low, 1480 id=self.power_law_low.GetId()) 1481 1482 1482 npts_low_txt = wx.StaticText(self, -1, 'Npts') 1483 1483 self.npts_low_tcl = InvTextCtrl(self, -1, 1484 size=(_BOX_WIDTH *2/3, -1),1484 size=(_BOX_WIDTH * 2 / 3, -1), 1485 1485 name='npts_low_tcl') 1486 1486 wx.EVT_TEXT(self, self.npts_low_tcl.GetId(), self._on_text) … … 1489 1489 self.npts_low_tcl.SetToolTipString(msg_hint) 1490 1490 power_txt = wx.StaticText(self, -1, 'Power') 1491 self.power_low_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH *2/3, -1),1491 self.power_low_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH * 2 / 3, -1), 1492 1492 name='power_low_tcl') 1493 1493 wx.EVT_TEXT(self, self.power_low_tcl.GetId(), self._on_text) 1494 1494 1495 1495 power_hint_txt = "Exponent to apply to the Power_law function." 1496 1496 self.power_low_tcl.SetToolTipString(power_hint_txt) … … 1498 1498 ix = 0 1499 1499 self.low_q_sizer.Add(self.enable_low_cbox, (iy, ix), (1, 5), 1500 wx.TOP|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1500 wx.TOP | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1501 1501 iy += 1 1502 1502 ix = 0 1503 1503 self.low_q_sizer.Add(npts_low_txt, (iy, ix), (1, 1), 1504 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1504 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1505 1505 ix += 1 1506 self.low_q_sizer.Add(self.npts_low_tcl, (iy, ix), (1, 1),1507 wx.EXPAND|wx.ADJUST_MINSIZE, 0)1506 self.low_q_sizer.Add(self.npts_low_tcl, (iy, ix), (1, 1), 1507 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1508 1508 iy += 1 1509 1509 ix = 0 1510 self.low_q_sizer.Add(self.guinier, (iy, ix), (1, 2),1511 wx.LEFT |wx.EXPAND|wx.ADJUST_MINSIZE, 15)1510 self.low_q_sizer.Add(self.guinier, (iy, ix), (1, 2), 1511 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1512 1512 iy += 1 1513 1513 ix = 0 1514 1514 self.low_q_sizer.Add(self.power_law_low, (iy, ix), (1, 2), 1515 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1515 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1516 1516 # Parameter controls for power law 1517 1517 ix = 1 1518 1518 iy += 1 1519 1519 self.low_q_sizer.Add(self.fix_enable_low, (iy, ix), (1, 1), 1520 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)1520 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1521 1521 ix += 1 1522 self.low_q_sizer.Add(self.fit_enable_low, (iy, ix), (1,1),1523 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)1522 self.low_q_sizer.Add(self.fit_enable_low, (iy, ix), (1, 1), 1523 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1524 1524 ix = 1 1525 1525 iy += 1 1526 1526 self.low_q_sizer.Add(power_txt, (iy, ix), (1, 1), 1527 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)1527 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1528 1528 ix += 1 1529 1529 self.low_q_sizer.Add(self.power_low_tcl, (iy, ix), (1, 1), 1530 wx.EXPAND|wx.ADJUST_MINSIZE, 0)1530 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1531 1531 self.low_extrapolation_sizer.Add(self.low_q_sizer) 1532 1532 1533 1533 def _enable_fit_power_law_high(self, event=None): 1534 1534 """ 1535 1535 Enable and disable the power value editing 1536 1536 """ 1537 if event != None: 1537 if event != None: 1538 1538 self._set_bookmark_flag(True) 1539 1539 1540 1540 self._set_preview_flag(False) 1541 1541 if self.fix_enable_high.IsEnabled(): … … 1547 1547 self.power_high_tcl.Disable() 1548 1548 self._set_state(event=event) 1549 1549 1550 1550 def _enable_high_q_section(self, event=None): 1551 1551 """ 1552 1552 Disable or enable some button if the user enable high q extrapolation 1553 1553 """ 1554 if event != None: 1554 if event != None: 1555 1555 self._set_bookmark_flag(True) 1556 1556 self._set_preview_flag(False) … … 1570 1570 self._set_state(event=event) 1571 1571 self.button_calculate.SetFocus() 1572 1572 1573 1573 def _layout_extrapolation_high(self): 1574 1574 """ … … 1579 1579 name='enable_high_cbox') 1580 1580 wx.EVT_CHECKBOX(self, self.enable_high_cbox.GetId(), 1581 1581 self._enable_high_q_section) 1582 1582 self.fix_enable_high = wx.RadioButton(self, -1, 'Fix', 1583 (10, 10), style=wx.RB_GROUP,1584 name='fix_enable_high')1583 (10, 10), style=wx.RB_GROUP, 1584 name='fix_enable_high') 1585 1585 self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_high, 1586 1586 id=self.fix_enable_high.GetId()) 1587 1587 self.fit_enable_high = wx.RadioButton(self, -1, 'Fit', (10, 10), 1588 name='fit_enable_high') 1589 self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_high, 1590 1591 1588 name='fit_enable_high') 1589 self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_high, 1590 id=self.fit_enable_high.GetId()) 1591 1592 1592 self.power_law_high = wx.StaticText(self, -1, 'Power Law') 1593 1593 msg_hint = "Check to extrapolate data at high-Q" 1594 1594 self.power_law_high.SetToolTipString(msg_hint) 1595 1595 npts_high_txt = wx.StaticText(self, -1, 'Npts') 1596 self.npts_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH *2/3, -1),1596 self.npts_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH * 2 / 3, -1), 1597 1597 name='npts_high_tcl') 1598 1598 wx.EVT_TEXT(self, self.npts_high_tcl.GetId(), self._on_text) … … 1601 1601 self.npts_high_tcl.SetToolTipString(msg_hint) 1602 1602 power_txt = wx.StaticText(self, -1, 'Power') 1603 self.power_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH *2/3, -1),1603 self.power_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH * 2 / 3, -1), 1604 1604 name='power_high_tcl') 1605 1605 wx.EVT_TEXT(self, self.power_high_tcl.GetId(), self._on_text) … … 1609 1609 ix = 0 1610 1610 self.high_q_sizer.Add(self.enable_high_cbox, (iy, ix), (1, 5), 1611 wx.TOP|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1611 wx.TOP | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1612 1612 iy += 1 1613 1613 ix = 0 1614 1614 self.high_q_sizer.Add(npts_high_txt, (iy, ix), (1, 1), 1615 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1615 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1616 1616 ix += 1 1617 1617 self.high_q_sizer.Add(self.npts_high_tcl, (iy, ix), (1, 1), 1618 wx.EXPAND|wx.ADJUST_MINSIZE, 0)1618 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1619 1619 iy += 1 1620 1620 ix = 0 1621 self.high_q_sizer.Add(self.power_law_high, (iy, ix), (1, 2),1622 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1623 1621 self.high_q_sizer.Add(self.power_law_high, (iy, ix), (1, 2), 1622 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1623 1624 1624 # Parameter controls for power law 1625 1625 ix = 1 1626 1626 iy += 1 1627 self.high_q_sizer.Add(self.fix_enable_high, (iy, ix), (1, 1),1628 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)1627 self.high_q_sizer.Add(self.fix_enable_high, (iy, ix), (1, 1), 1628 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1629 1629 ix += 1 1630 self.high_q_sizer.Add(self.fit_enable_high, (iy, ix), (1, 1),1631 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)1630 self.high_q_sizer.Add(self.fit_enable_high, (iy, ix), (1, 1), 1631 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1632 1632 ix = 1 1633 1633 iy += 1 1634 self.high_q_sizer.Add(power_txt, (iy, ix), (1, 1),1635 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1634 self.high_q_sizer.Add(power_txt, (iy, ix), (1, 1), 1635 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1636 1636 ix += 1 1637 self.high_q_sizer.Add(self.power_high_tcl, (iy, ix), 1638 wx.EXPAND|wx.ADJUST_MINSIZE, 0)1639 self.high_extrapolation_sizer.Add(self.high_q_sizer, 0, 1640 1641 1637 self.high_q_sizer.Add(self.power_high_tcl, (iy, ix), (1, 1), 1638 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1639 self.high_extrapolation_sizer.Add(self.high_q_sizer, 0, 1640 wx.BOTTOM, 20) 1641 1642 1642 def _layout_extrapolation(self): 1643 1643 """ … … 1647 1647 extra_hint_txt = wx.StaticText(self, -1, extra_hint) 1648 1648 #Extrapolation range [string] 1649 extrapolation_min_txt = wx.StaticText(self, -1, 'Min:') 1650 self.extrapolation_min_tcl = OutputTextCtrl(self, -1, 1651 size=(_BOX_WIDTH, 20), style=0,1652 name='extrapolation_min_tcl')1649 extrapolation_min_txt = wx.StaticText(self, -1, 'Min:') 1650 self.extrapolation_min_tcl = OutputTextCtrl(self, -1, 1651 size=(_BOX_WIDTH, 20), style=0, 1652 name='extrapolation_min_tcl') 1653 1653 self.extrapolation_min_tcl.SetValue(str(Q_MINIMUM)) 1654 1654 hint_msg = "The minimum extrapolated q value." 1655 1655 self.extrapolation_min_tcl.SetToolTipString(hint_msg) 1656 extrapolation_max_txt = wx.StaticText(self, -1, 'Max:') 1656 extrapolation_max_txt = wx.StaticText(self, -1, 'Max:') 1657 1657 self.extrapolation_max_tcl = OutputTextCtrl(self, -1, 1658 size=(_BOX_WIDTH, 20),1659 style=0,1660 name='extrapolation_max_tcl')1658 size=(_BOX_WIDTH, 20), 1659 style=0, 1660 name='extrapolation_max_tcl') 1661 1661 self.extrapolation_max_tcl.SetValue(str(Q_MAXIMUM)) 1662 1662 hint_msg = "The maximum extrapolated q value." 1663 1663 self.extrapolation_max_tcl.SetToolTipString(hint_msg) 1664 self.extrapolation_range_sizer.AddMany([(extra_hint_txt, 0, 1664 self.extrapolation_range_sizer.AddMany([(extra_hint_txt, 0, 1665 1665 wx.LEFT, 5), 1666 1666 (extrapolation_min_txt, 0, 1667 1667 wx.LEFT, 10), 1668 1668 (self.extrapolation_min_tcl, 1669 1669 0, wx.LEFT, 5), 1670 1670 (extrapolation_max_txt, 0, 1671 1671 wx.LEFT, 20), 1672 1672 (self.extrapolation_max_tcl, 1673 1673 0, wx.LEFT, 5)]) 1674 1674 self._layout_extrapolation_low() 1675 1675 self._layout_extrapolation_high() 1676 self.extrapolation_low_high_sizer.AddMany(\ 1677 [(self.low_extrapolation_sizer, 1678 0, wx.LEFT|wx.BOTTOM|wx.TOP, 5), 1679 (self.high_extrapolation_sizer, 1680 0, wx.LEFT|wx.BOTTOM|wx.TOP, 5)]) 1676 self.extrapolation_low_high_sizer.AddMany([(self.low_extrapolation_sizer, 1677 0, wx.LEFT | wx.BOTTOM | wx.TOP, 5), 1678 (self.high_extrapolation_sizer, 1679 0, wx.LEFT | wx.BOTTOM | wx.TOP, 5)]) 1681 1680 self.extrapolation_sizer.AddMany([(self.extrapolation_range_sizer), 1682 (self.extrapolation_low_high_sizer)])1683 1681 (self.extrapolation_low_high_sizer)]) 1682 1684 1683 def _layout_volume_surface_sizer(self): 1685 1684 """ … … 1688 1687 unit_volume = '' 1689 1688 unit_surface = '[1/A]' 1690 uncertainty = "+/-" 1689 uncertainty = "+/-" 1691 1690 volume_txt = wx.StaticText(self, -1, 'Volume Fraction') 1692 1691 self.volume_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, -1), … … 1700 1699 self.volume_err_tcl.SetToolTipString(hint_msg) 1701 1700 volume_units_txt = wx.StaticText(self, -1, unit_volume) 1702 1701 1703 1702 surface_txt = wx.StaticText(self, -1, 'Specific Surface') 1704 1703 self.surface_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, -1), … … 1715 1714 ix = 0 1716 1715 self.volume_surface_sizer.Add(volume_txt, (iy, ix), (1, 1), 1717 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1716 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1718 1717 ix += 1 1719 1718 self.volume_surface_sizer.Add(self.volume_tcl, (iy, ix), (1, 1), 1720 wx.EXPAND|wx.ADJUST_MINSIZE, 20)1719 wx.EXPAND | wx.ADJUST_MINSIZE, 20) 1721 1720 ix += 1 1722 1721 self.volume_surface_sizer.Add(wx.StaticText(self, -1, uncertainty), 1723 (iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 10)1722 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1724 1723 ix += 1 1725 1724 self.volume_surface_sizer.Add(self.volume_err_tcl, (iy, ix), (1, 1), 1726 wx.EXPAND|wx.ADJUST_MINSIZE, 10)1725 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1727 1726 ix += 1 1728 1727 self.volume_surface_sizer.Add(volume_units_txt, (iy, ix), (1, 1), 1729 wx.EXPAND|wx.ADJUST_MINSIZE, 10)1728 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1730 1729 iy += 1 1731 1730 ix = 0 1732 1731 self.volume_surface_sizer.Add(surface_txt, (iy, ix), (1, 1), 1733 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1732 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1734 1733 ix += 1 1735 1734 self.volume_surface_sizer.Add(self.surface_tcl, (iy, ix), (1, 1), 1736 wx.EXPAND|wx.ADJUST_MINSIZE, 20)1735 wx.EXPAND | wx.ADJUST_MINSIZE, 20) 1737 1736 ix += 1 1738 1737 self.volume_surface_sizer.Add(wx.StaticText(self, -1, uncertainty), 1739 (iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 10)1738 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1740 1739 ix += 1 1741 1740 self.volume_surface_sizer.Add(self.surface_err_tcl, (iy, ix), (1, 1), 1742 wx.EXPAND|wx.ADJUST_MINSIZE, 10)1741 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1743 1742 ix += 1 1744 1743 self.volume_surface_sizer.Add(surface_units_txt, (iy, ix), (1, 1), 1745 wx.EXPAND|wx.ADJUST_MINSIZE, 10)1744 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1746 1745 static_line = wx.StaticLine(self, -1) 1747 1746 iy += 1 1748 1747 ix = 0 1749 1748 1750 1749 def _layout_invariant_sizer(self): 1751 1750 """ 1752 1751 Draw widgets related to invariant 1753 1752 """ 1754 uncertainty = "+/-" 1753 uncertainty = "+/-" 1755 1754 unit_invariant = '[1/(cm*A^3)]' 1756 1755 invariant_total_txt = wx.StaticText(self, -1, 'Invariant Total [Q*]') … … 1762 1761 self.invariant_total_err_tcl = OutputTextCtrl(self, -1, 1763 1762 size=(_BOX_WIDTH, -1), 1764 name='invariant_total_err_tcl')1763 name='invariant_total_err_tcl') 1765 1764 hint_msg = "Uncertainty on invariant." 1766 1765 self.invariant_total_err_tcl.SetToolTipString(hint_msg) 1767 invariant_total_units_txt = wx.StaticText(self, -1, unit_invariant, 1768 size=(80, -1))1769 1766 invariant_total_units_txt = wx.StaticText(self, -1, unit_invariant, 1767 size=(80, -1)) 1768 1770 1769 #Invariant total 1771 1770 iy = 0 1772 1771 ix = 0 1773 1772 self.invariant_sizer.Add(invariant_total_txt, (iy, ix), (1, 1), 1774 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1773 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 1775 1774 ix += 1 1776 1775 self.invariant_sizer.Add(self.invariant_total_tcl, (iy, ix), (1, 1), 1777 wx.EXPAND|wx.ADJUST_MINSIZE, 10)1776 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1778 1777 ix += 1 1779 self.invariant_sizer.Add( 1780 (iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 10)1778 self.invariant_sizer.Add(wx.StaticText(self, -1, uncertainty), 1779 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1781 1780 ix += 1 1782 1781 self.invariant_sizer.Add(self.invariant_total_err_tcl, (iy, ix), (1, 1), 1783 wx.EXPAND|wx.ADJUST_MINSIZE, 10)1782 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1784 1783 ix += 1 1785 self.invariant_sizer.Add(invariant_total_units_txt, (iy, ix), (1, 1),1786 wx.EXPAND|wx.ADJUST_MINSIZE, 10)1787 1784 self.invariant_sizer.Add(invariant_total_units_txt, (iy, ix), (1, 1), 1785 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 1786 1788 1787 def _layout_inputs_sizer(self): 1789 1788 """ 1790 1789 Draw widgets related to inputs 1791 1790 """ 1792 contrast_txt = wx.StaticText(self, -1, 'Contrast:') 1791 contrast_txt = wx.StaticText(self, -1, 'Contrast:') 1793 1792 self.contrast_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 1794 1793 style=0, name='contrast_tcl') … … 1796 1795 contrast_hint_txt = "Contrast" 1797 1796 self.contrast_tcl.SetToolTipString(contrast_hint_txt) 1798 contrast_unit_txt = wx.StaticText(self, -1, '[1/A^2]', size=(40, -1))1799 porod_const_txt = wx.StaticText(self, -1, 1800 'Porod\nConstant:\n(optional)\n') 1801 porod_unit_txt = wx.StaticText(self, -1, '[1/(cm*A^4)]', size=(80, -1))1802 self.porod_constant_tcl = InvTextCtrl(self, -1, 1797 contrast_unit_txt = wx.StaticText(self, -1, '[1/A^2]', size=(40, -1)) 1798 porod_const_txt = wx.StaticText(self, -1, 1799 'Porod\nConstant:\n(optional)\n') 1800 porod_unit_txt = wx.StaticText(self, -1, '[1/(cm*A^4)]', size=(80, -1)) 1801 self.porod_constant_tcl = InvTextCtrl(self, -1, 1803 1802 size=(_BOX_WIDTH, 20), style=0, 1804 name='porod_constant_tcl') 1803 name='porod_constant_tcl') 1805 1804 wx.EVT_TEXT(self, self.porod_constant_tcl.GetId(), self._on_text) 1806 1805 porod_const_hint_txt = "Porod Constant" 1807 1806 self.porod_constant_tcl.SetToolTipString(porod_const_hint_txt) 1808 1809 background_txt = wx.StaticText(self, -1, 'Background:') 1807 1808 background_txt = wx.StaticText(self, -1, 'Background:') 1810 1809 self.background_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 1811 style=0, name='background_tcl') 1810 style=0, name='background_tcl') 1812 1811 wx.EVT_TEXT(self, self.background_tcl.GetId(), self._on_text) 1813 1812 background_hint_txt = "Background" 1814 1813 self.background_tcl.SetToolTipString(background_hint_txt) 1815 background_unit_txt = wx.StaticText(self, -1, '[1/cm]') 1816 scale_txt = wx.StaticText(self, -1, 'Scale:') 1814 background_unit_txt = wx.StaticText(self, -1, '[1/cm]') 1815 scale_txt = wx.StaticText(self, -1, 'Scale:') 1817 1816 self.scale_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0, 1818 1817 name='scale_tcl') … … 1820 1819 scale_hint_txt = "Scale" 1821 1820 self.scale_tcl.SetToolTipString(scale_hint_txt) 1822 self.sizer_input.AddMany([(background_txt, 0, wx.LEFT |wx.BOTTOM, 5),1823 (self.background_tcl, 0, wx.LEFT|wx.BOTTOM, 5),1824 (background_unit_txt, 0, wx.LEFT|wx.BOTTOM, 5),1825 (scale_txt, 0, wx.LEFT|wx.BOTTOM, 10),1826 (self.scale_tcl, 0, wx.LEFT|wx.BOTTOM|wx.RIGHT, 5),1827 (10, 10),1828 (contrast_txt, 0, wx.LEFT|wx.BOTTOM, 5),1829 (self.contrast_tcl, 0, wx.LEFT|wx.BOTTOM, 5),1830 (contrast_unit_txt, 0, wx.LEFT|wx.BOTTOM, 5),1831 (porod_const_txt, 0, wx.LEFT, 10),1832 (self.porod_constant_tcl, 0, wx.LEFT|wx.BOTTOM|wx.RIGHT, 5),1833 (porod_unit_txt, 0, wx.LEFT|wx.BOTTOM, 5)])1821 self.sizer_input.AddMany([(background_txt, 0, wx.LEFT | wx.BOTTOM, 5), 1822 (self.background_tcl, 0, wx.LEFT | wx.BOTTOM, 5), 1823 (background_unit_txt, 0, wx.LEFT | wx.BOTTOM, 5), 1824 (scale_txt, 0, wx.LEFT | wx.BOTTOM, 10), 1825 (self.scale_tcl, 0, wx.LEFT | wx.BOTTOM | wx.RIGHT, 5), 1826 (10, 10), 1827 (contrast_txt, 0, wx.LEFT | wx.BOTTOM, 5), 1828 (self.contrast_tcl, 0, wx.LEFT | wx.BOTTOM, 5), 1829 (contrast_unit_txt, 0, wx.LEFT | wx.BOTTOM, 5), 1830 (porod_const_txt, 0, wx.LEFT, 10), 1831 (self.porod_constant_tcl, 0, wx.LEFT | wx.BOTTOM | wx.RIGHT, 5), 1832 (porod_unit_txt, 0, wx.LEFT | wx.BOTTOM, 5)]) 1834 1833 self.inputs_sizer.Add(self.sizer_input) 1835 1834 1836 1835 def _layout_outputs_sizer(self): 1837 1836 """ … … 1842 1841 static_line = wx.StaticLine(self, -1) 1843 1842 self.outputs_sizer.AddMany([(self.volume_surface_sizer, 1844 0, wx.TOP|wx.BOTTOM, 10),1843 0, wx.TOP | wx.BOTTOM, 10), 1845 1844 (static_line, 0, wx.EXPAND, 0), 1846 (self.invariant_sizer, 0, wx.TOP|wx.BOTTOM, 10)])1847 def _layout_button(self): 1845 (self.invariant_sizer, 0, wx.TOP | wx.BOTTOM, 10)]) 1846 def _layout_button(self): 1848 1847 """ 1849 1848 Do the layout for the button widgets 1850 """ 1849 """ 1851 1850 #compute button 1852 1851 id = wx.NewId() … … 1854 1853 name='compute_invariant') 1855 1854 self.button_calculate.SetToolTipString("Compute invariant") 1856 self.Bind(wx.EVT_BUTTON, self.compute_invariant, id=id) 1855 self.Bind(wx.EVT_BUTTON, self.compute_invariant, id=id) 1857 1856 #detail button 1858 1857 id = wx.NewId() … … 1863 1862 details = "Details on Invariant Total Calculations" 1864 1863 details_txt = wx.StaticText(self, -1, details) 1865 self.button_sizer.AddMany([(details_txt, 0 ,1866 wx.RIGHT |wx.BOTTOM|wx.TOP, 10),1867 (self.button_details, 0 1868 (self.button_calculate, 0,1869 wx.RIGHT|wx.TOP|wx.BOTTOM, 10)])1864 self.button_sizer.AddMany([(details_txt, 0, 1865 wx.RIGHT | wx.BOTTOM | wx.TOP, 10), 1866 (self.button_details, 0, wx.ALL, 10), 1867 (self.button_calculate, 0, 1868 wx.RIGHT | wx.TOP | wx.BOTTOM, 10)]) 1870 1869 def _do_layout(self): 1871 1870 """ … … 1879 1878 self._layout_button() 1880 1879 self.main_sizer.AddMany([(self.data_name_boxsizer, 0, wx.ALL, 10), 1881 1882 wx.LEFT |wx.RIGHT|wx.BOTTOM, 10),1883 (self.button_sizer, 0, wx.LEFT|wx.RIGHT, 15),1880 (self.outputs_sizer, 0, 1881 wx.LEFT | wx.RIGHT | wx.BOTTOM, 10), 1882 (self.button_sizer, 0, wx.LEFT | wx.RIGHT, 15), 1884 1883 (self.inputs_sizer, 0, 1885 wx.LEFT |wx.RIGHT|wx.BOTTOM, 10),1886 1887 wx.LEFT |wx.RIGHT|wx.BOTTOM, 10)])1884 wx.LEFT | wx.RIGHT | wx.BOTTOM, 10), 1885 (self.extrapolation_sizer, 0, 1886 wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)]) 1888 1887 self.SetSizer(self.main_sizer) 1889 1888 self.SetAutoLayout(True) 1890 1891 1889 1890 1892 1891 class InvariantDialog(wx.Dialog): 1893 1892 """ … … 1897 1896 data=None, title="Invariant", base=None): 1898 1897 wx.Dialog.__init__(self, parent, id, title, size=(PANEL_WIDTH, 1899 1898 PANEL_HEIGHT)) 1900 1899 self.panel = InvariantPanel(self) 1901 1900 self.Centre() 1902 1901 self.Show(True) 1903 1902 1904 1903 class InvariantWindow(wx.Frame): 1905 1904 """ 1906 1905 Invariant Window 1907 1906 """ 1908 def __init__(self, parent=None, id=1, graph=None, 1907 def __init__(self, parent=None, id=1, graph=None, 1909 1908 data=None, title="Invariant", base=None): 1910 1911 wx.Frame.__init__(self, parent, id, title, size=(PANEL_WIDTH + 100,1912 PANEL_HEIGHT+100))1909 1910 wx.Frame.__init__(self, parent, id, title, size=(PANEL_WIDTH + 100, 1911 PANEL_HEIGHT + 100)) 1913 1912 from sas.dataloader.loader import Loader 1914 1913 self.loader = Loader() 1915 import invariant1916 1914 path = "C:/ECLPS/workspace/trunk/sasdataloader/test/ascii_test_3.txt" 1917 1915 data = self.loader.load(path) … … 1922 1920 self.Centre() 1923 1921 self.Show(True) 1924 1922 1925 1923 class MyApp(wx.App): 1926 1924 """ … … 1935 1933 frame.Show(True) 1936 1934 self.SetTopWindow(frame) 1937 1935 1938 1936 return True 1939 1937 1940 1938 # end of class MyApp 1941 1939
Note: See TracChangeset
for help on using the changeset viewer.