Changeset 6f16e25 in sasview for src/sas/perspectives/fitting/basepage.py
- Timestamp:
- Oct 21, 2015 6:35:00 AM (9 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:
- 85130cb
- Parents:
- 2d88fc4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/basepage.py
r2c8dc19 r6f16e25 15 15 from wx.lib.scrolledpanel import ScrolledPanel 16 16 from sas.guiframe.panel_base import PanelBase 17 from sas.guiframe.utils import format_number, check_float 17 from sas.guiframe.utils import format_number, check_float, IdList 18 18 from sas.guiframe.events import PanelOnFocusEvent 19 19 from sas.guiframe.events import StatusEvent … … 57 57 ## Title to appear on top of the window 58 58 window_caption = "Fit Page " 59 # These two buttons have specific IDs since they seem to be created more 60 # frequently than they need to. In particular, set_dispers_sizer() is 61 # called by _on_select_model 62 ID_BOOKMARK = wx.NewId() 63 ID_DISPERSER_HELP = wx.NewId() 64 _id_pool = IdList() 59 65 60 66 def __init__(self, parent, color='blue', **kwargs): … … 66 72 #Set window's font size 67 73 self.SetWindowVariant(variant=FONT_VARIANT) 68 69 74 self.SetBackgroundColour(color) 75 76 self._ids = iter(self._id_pool) 70 77 ## parent of the page 71 78 self.parent = parent … … 199 206 self.popUpMenu = wx.Menu() 200 207 201 id = wx.NewId()202 self._keep = wx.MenuItem(self.popUpMenu, id, "Add bookmark",208 wx_id = self._ids.next() 209 self._keep = wx.MenuItem(self.popUpMenu, wx_id, "Add bookmark", 203 210 " Keep the panel status to recall it later") 204 211 self.popUpMenu.AppendItem(self._keep) … … 206 213 self._set_bookmark_flag(False) 207 214 self._set_save_flag(False) 208 wx.EVT_MENU(self, id, self.on_bookmark)215 wx.EVT_MENU(self, wx_id, self.on_bookmark) 209 216 self.popUpMenu.AppendSeparator() 210 217 … … 594 601 fill sizer containing dispersity info 595 602 """ 603 #print "==== entering set_dispers_sizer ===" 596 604 self.sizer4.Clear(True) 597 605 name = "Polydispersity and Orientational Distribution" 598 box_description = wx.StaticBox(self, -1, name)606 box_description = wx.StaticBox(self, wx.ID_ANY, name) 599 607 box_description.SetForegroundColour(wx.BLUE) 600 608 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 601 609 #---------------------------------------------------- 602 self.disable_disp = wx.RadioButton(self, -1, 'Off', (10, 10),610 self.disable_disp = wx.RadioButton(self, wx.ID_ANY, 'Off', (10, 10), 603 611 style=wx.RB_GROUP) 604 self.enable_disp = wx.RadioButton(self, -1, 'On', (10, 30))612 self.enable_disp = wx.RadioButton(self, wx.ID_ANY, 'On', (10, 30)) 605 613 # best size for MAC and PC 606 614 if ON_MAC: … … 608 616 else: 609 617 size_q = (20, 15) 610 self.disp_help_bt = wx.Button(self, wx.NewId(), '?',618 self.disp_help_bt = wx.Button(self, self.ID_DISPERSER_HELP, '?', 611 619 style=wx.BU_EXACTFIT, 612 620 size=size_q) … … 624 632 sizer_dispersion.Add((20, 20)) 625 633 name = "" # Polydispersity and \nOrientational Distribution " 626 sizer_dispersion.Add(wx.StaticText(self, -1, name))634 sizer_dispersion.Add(wx.StaticText(self, wx.ID_ANY, name)) 627 635 sizer_dispersion.Add(self.enable_disp) 628 636 sizer_dispersion.Add((20, 20)) … … 795 803 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 796 804 797 id = wx.NewId() 798 self.popUpMenu.Append(id, name, str(msg)) 799 wx.EVT_MENU(self, id, self.onResetModel) 805 self.popUpMenu.Append(self.ID_BOOKMARK, name, str(msg)) 806 wx.EVT_MENU(self, self.ID_BOOKMARK, self.onResetModel) 800 807 wx.PostEvent(self._manager.parent, 801 808 AppendBookmarkEvent(title=name, … … 1438 1445 reset the context menu 1439 1446 """ 1447 ids = iter(self._id_pool) # Reusing ids for context menu 1440 1448 for name, _ in self.state.saved_states.iteritems(): 1441 1449 self.number_saved_state += 1 1442 1450 ## Add item in the context menu 1443 id = wx.NewId()1451 wx_id = ids.next() 1444 1452 msg = 'Save model and state %g' % self.number_saved_state 1445 self.popUpMenu.Append( id, name, msg)1446 wx.EVT_MENU(self, id, self.onResetModel)1453 self.popUpMenu.Append(wx_id, name, msg) 1454 wx.EVT_MENU(self, wx_id, self.onResetModel) 1447 1455 1448 1456 def _reset_plotting_range(self, state): … … 1831 1839 sld_data.name = 'SLD' 1832 1840 sld_data.axes = self.sld_axes 1833 self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, id= -1) 1841 self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, 1842 id=wx.ID_ANY) 1834 1843 self.panel.ShowModal() 1835 1844 … … 2421 2430 self.sizer4_4.Clear(True) 2422 2431 text = "No polydispersity available for this model" 2423 model_disp = wx.StaticText(self, -1, text)2432 model_disp = wx.StaticText(self, wx.ID_ANY, text) 2424 2433 self.sizer4_4.Add(model_disp, (iy, ix), (1, 1), 2425 2434 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) … … 2851 2860 name = self.formfactorbox.GetValue() 2852 2861 _PageAnchor = '#' + name.lower() 2853 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation,2862 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 2854 2863 _PageAnchor, name + " Help") 2855 2864 else: 2856 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "",2857 2865 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 2866 "", "General Model Help") 2858 2867 2859 2868 … … 2906 2915 2907 2916 _TreeLocation = "_images/M_angles_pic.bmp" 2908 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "",2917 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 2909 2918 "Magnetic Angle Defintions") 2910 2919 … … 2926 2935 2927 2936 _TreeLocation = "user/perspectives/fitting/mag_help.html" 2928 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "",2937 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 2929 2938 "Polarized Beam/Magnetc Help") 2930 2939 … … 2973 2982 _TreeLocation = "user/perspectives/fitting/pd_help.html" 2974 2983 _PageAnchor = "" 2975 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation,2984 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 2976 2985 _PageAnchor, "Polydispersity Help") 2977 2986 … … 3517 3526 fill sizer containing model info 3518 3527 """ 3528 # This should only be called once per fit tab 3529 #print "==== Entering _fill_model_sizer" 3519 3530 ##Add model function Details button in fitpanel. 3520 3531 ##The following 3 lines are for Mac. Let JHC know before modifying... … … 3522 3533 self.formfactorbox = None 3523 3534 self.multifactorbox = None 3524 self.mbox_description = wx.StaticBox(self, -1, str(title))3535 self.mbox_description = wx.StaticBox(self, wx.ID_ANY, str(title)) 3525 3536 boxsizer1 = wx.StaticBoxSizer(self.mbox_description, wx.VERTICAL) 3526 3537 sizer_cat = wx.BoxSizer(wx.HORIZONTAL) 3527 3538 self.mbox_description.SetForegroundColour(wx.RED) 3528 id = wx.NewId() 3529 self.model_func = wx.Button(self, id, 'Help', size=(80, 23)) 3530 self.model_func.Bind(wx.EVT_BUTTON, self.on_function_help_clicked, id=id) 3539 wx_id = self._ids.next() 3540 self.model_func = wx.Button(self, wx_id, 'Help', size=(80, 23)) 3541 self.model_func.Bind(wx.EVT_BUTTON, self.on_function_help_clicked, 3542 id=wx_id) 3531 3543 self.model_func.SetToolTipString("Full Model Function Help") 3532 id = wx.NewId() 3533 self.model_help = wx.Button(self, id, 'Description', size=(80, 23)) 3534 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, id=id) 3544 wx_id = self._ids.next() 3545 self.model_help = wx.Button(self, wx_id, 'Description', size=(80, 23)) 3546 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, 3547 id=wx_id) 3535 3548 self.model_help.SetToolTipString("Short Model Function Description") 3536 id = wx.NewId()3537 self.model_view = wx.Button(self, id, "Show 2D", size=(80, 23))3538 self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id= id)3549 wx_id = self._ids.next() 3550 self.model_view = wx.Button(self, wx_id, "Show 2D", size=(80, 23)) 3551 self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=wx_id) 3539 3552 hint = "toggle view of model from 1D to 2D or 2D to 1D" 3540 3553 self.model_view.SetToolTipString(hint) 3541 3554 3542 cat_set_box = wx.StaticBox(self, -1, 'Category')3555 cat_set_box = wx.StaticBox(self, wx.ID_ANY, 'Category') 3543 3556 sizer_cat_box = wx.StaticBoxSizer(cat_set_box, wx.HORIZONTAL) 3544 3557 sizer_cat_box.SetMinSize((200, 50)) 3545 self.categorybox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 3558 self.categorybox = wx.ComboBox(self, wx.ID_ANY, 3559 style=wx.CB_READONLY) 3546 3560 self.categorybox.SetToolTip(wx.ToolTip("Select a Category/Type")) 3547 3561 self._populate_listbox() 3548 wx.EVT_COMBOBOX(self.categorybox, -1, self._show_combox)3549 #self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes',3562 wx.EVT_COMBOBOX(self.categorybox, wx.ID_ANY, self._show_combox) 3563 #self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes', 3550 3564 # style=wx.RB_GROUP) 3551 #self.shape_indep_rbutton = wx.RadioButton(self, -1,3565 #self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY, 3552 3566 # "Shape-Independent") 3553 #self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 3554 #self.plugin_rbutton = wx.RadioButton(self, -1, "Uncategorized") 3567 #self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY, 3568 # "Structure Factor ") 3569 #self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY, 3570 # "Uncategorized") 3555 3571 3556 3572 #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, … … 3564 3580 #MAC needs SetValue 3565 3581 3566 show_cat_button = wx.Button(self, -1, "Modify")3582 show_cat_button = wx.Button(self, wx.ID_ANY, "Modify") 3567 3583 cat_tip = "Modify model categories \n" 3568 3584 cat_tip += "(also accessible from the menu bar)." … … 3590 3606 mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL) 3591 3607 3592 self.text1 = wx.StaticText(self, -1, "")3593 self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)")3594 self.mutifactor_text = wx.StaticText(self, -1, "No. of Shells: ")3595 self.mutifactor_text1 = wx.StaticText(self, -1, "")3596 self.show_sld_button = wx.Button(self, -1, "Show SLD Profile")3608 self.text1 = wx.StaticText(self, wx.ID_ANY, "") 3609 self.text2 = wx.StaticText(self, wx.ID_ANY, "P(Q)*S(Q)") 3610 self.mutifactor_text = wx.StaticText(self, wx.ID_ANY, "No. of Shells: ") 3611 self.mutifactor_text1 = wx.StaticText(self, wx.ID_ANY, "") 3612 self.show_sld_button = wx.Button(self, wx.ID_ANY, "Show SLD Profile") 3597 3613 self.show_sld_button.Bind(wx.EVT_BUTTON, self._on_show_sld) 3598 3614 3599 self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)3615 self.formfactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 3600 3616 self.formfactorbox.SetToolTip(wx.ToolTip("Select a Model")) 3601 3617 if self.model != None: 3602 3618 self.formfactorbox.SetValue(self.model.name) 3603 self.structurebox = wx.ComboBox(self, -1, style=wx.CB_READONLY)3604 self.multifactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)3619 self.structurebox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 3620 self.multifactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 3605 3621 self.initialize_combox() 3606 wx.EVT_COMBOBOX(self.formfactorbox, -1, self._on_select_model)3607 3608 wx.EVT_COMBOBOX(self.structurebox, -1, self._on_select_model)3609 wx.EVT_COMBOBOX(self.multifactorbox, -1, self._on_select_model)3622 wx.EVT_COMBOBOX(self.formfactorbox, wx.ID_ANY, self._on_select_model) 3623 3624 wx.EVT_COMBOBOX(self.structurebox, wx.ID_ANY, self._on_select_model) 3625 wx.EVT_COMBOBOX(self.multifactorbox, wx.ID_ANY, self._on_select_model) 3610 3626 ## check model type to show sizer 3611 3627 if self.model != None:
Note: See TracChangeset
for help on using the changeset viewer.