- Timestamp:
- Apr 4, 2014 11:30:45 AM (11 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:
- f87dc4c
- Parents:
- fc049b7
- Location:
- src/sans/perspectives/fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/perspectives/fitting/fitting.py
rb6a181b r767514a 804 804 Dialog to select ftol for Scipy 805 805 """ 806 #if event != None:807 # event.Skip()808 806 from ftol_dialog import ChangeFtol 809 panel = ChangeFtol(self.parent, self) 810 panel.ShowModal() 811 807 dialog = ChangeFtol(self.parent, self) 808 result = dialog.ShowModal() 809 if result == wx.ID_OK: 810 value = dialog.get_ftol() 811 if value is not None: 812 self.set_ftol(value) 813 msg = "The ftol (LeastSq) is set to %s." % value 814 else: 815 msg = "Error in the selection... No change in ftol." 816 # post event for info 817 wx.PostEvent(self.parent, 818 StatusEvent(status=msg, info='warning')) 819 dialog.Destroy() 820 812 821 def stop_fit(self, uid): 813 822 """ -
src/sans/perspectives/fitting/ftol_dialog.py
r5777106 r767514a 15 15 import wx 16 16 import sys 17 from sans.guiframe.events import StatusEvent18 17 # default ftol 19 18 F_TOL = 1.49012e-08 … … 37 36 wx.Dialog.__init__(self, parent, id, title, 38 37 size=(PANEL_WIDTH, PANEL_HEIGHT)) 39 # parent40 self.parent = base41 # default ftol42 self.ftol = SANS_F_TOL43 38 # font size 44 39 self.SetWindowVariant(variant=FONT_VARIANT) … … 46 41 panel = wx.Panel(self, -1) 47 42 vbox = wx.BoxSizer(wx.VERTICAL) 48 wx.StaticBox(panel, -1, 'FTol selection (Leastsq)', (5, 6), 49 (PANEL_WIDTH * 0.9, PANEL_HEIGHT * 0.7)) 50 default_bt = wx.RadioButton(panel, -1, 'SansView Default (5e-05)', 51 (15, 30), 52 style=wx.RB_GROUP) 53 default_bt.SetValue(True) 54 default_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 55 sci_default_bt = wx.RadioButton(panel, -1, 56 'Scipy Default (1.49012e-08)', (15, 55)) 57 sci_default_bt.SetValue(False) 58 sci_default_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 59 high_bt = wx.RadioButton(panel, -1, '1e-06', (15, 80)) 60 high_bt.SetValue(False) 61 high_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 62 mid_bt = wx.RadioButton(panel, -1, '1e-05', (15, 105)) 63 mid_bt.SetValue(False) 64 mid_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 65 low_bt = wx.RadioButton(panel, -1, '1e-04', (15, 130)) 66 low_bt.SetValue(False) 67 low_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 43 wx.StaticBox(panel, -1, 'FTol selection (Leastsq)', (5, 6), (PANEL_WIDTH * 0.9, PANEL_HEIGHT * 0.7)) 44 self.default_bt = wx.RadioButton(panel, -1, 'SansView Default (5e-05)', (15, 30), style=wx.RB_GROUP) 45 self.default_bt.SetValue(True) 46 self.default_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 47 self.sci_default_bt = wx.RadioButton(panel, -1, 'Scipy Default (1.49012e-08)', (15, 55)) 48 self.sci_default_bt.SetValue(False) 49 self.sci_default_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 50 self.high_bt = wx.RadioButton(panel, -1, '1e-06', (15, 80)) 51 self.high_bt.SetValue(False) 52 self.high_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 53 self.mid_bt = wx.RadioButton(panel, -1, '1e-05', (15, 105)) 54 self.mid_bt.SetValue(False) 55 self.mid_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 56 self.low_bt = wx.RadioButton(panel, -1, '1e-04', (15, 130)) 57 self.low_bt.SetValue(False) 58 self.low_bt.Bind(wx.EVT_RADIOBUTTON, self.OnFtolSelection) 68 59 self.custom_bt = wx.RadioButton(panel, -1, 'Custom', (15, 155)) 69 60 self.custom_bt.SetValue(False) … … 71 62 self.custombox = wx.TextCtrl(panel, -1, '', (95, 155)) 72 63 self.custombox.Disable() 64 73 65 hbox = wx.BoxSizer(wx.HORIZONTAL) 74 okButton = wx.Button(self, -1, 'Set', size=(70, 30)) 66 okButton = wx.Button(self, wx.ID_OK, 'Set', size=(70, 30)) 67 closeButton = wx.Button(self,wx.ID_CANCEL, 'Cancel', size=(70, 30)) 75 68 hbox.Add(okButton, 1, wx.RIGHT, 5) 76 okButton.Bind(wx.EVT_BUTTON, self.OnClose)77 vbox.Add(panel )69 hbox.Add(closeButton, 1, wx.RIGHT, 5) 70 vbox.Add(panel, 1, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10) 78 71 vbox.Add(hbox, 1, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10) 79 # set sizer72 80 73 self.SetSizer(vbox) 81 74 82 75 def OnFtolSelection(self, event=None): 83 76 """ 84 Changes the ftol on selection of the radio button77 Changes the ftol on selection of the radio button 85 78 """ 86 event.Skip() 87 # event object and selection 88 button = event.GetEventObject() 89 selection = button.GetLabel() 90 # get float value 91 if selection.count('SansView') > 0: 92 ftol = SANS_F_TOL 93 self.custombox.Disable() 94 elif selection.count('Scipy') > 0: 95 ftol = F_TOL 96 self.custombox.Disable() 97 elif selection == 'Custom': 98 ftol = F_TOL 99 self.custombox.Enable(True) 100 else: 101 ftol = float(selection) 102 self.custombox.Disable() 103 self.ftol = ftol 79 self.custombox.Enable(self.custom_bt.GetValue()) 104 80 105 def OnClose(self, event):81 def get_ftol(self): 106 82 """ 107 Close event83 Get the ftol value 108 84 """ 109 # clear event 110 event.Skip() 111 flag = True 112 # I case of the custom ftol 85 if self.default_bt.GetValue(): 86 return SANS_F_TOL 87 elif self.sci_default_bt.GetValue(): 88 return F_TOL 89 elif self.low_bt.GetValue(): 90 return 1.0e-4 91 elif self.mid_bt.GetValue(): 92 return 1.0e-5 93 elif self.high_bt.GetValue(): 94 return 1.0e-6 113 95 if self.custom_bt.GetValue(): 114 96 try: 115 ftol = float(self.custombox.GetValue()) 116 self.ftol = ftol 97 return float(self.custombox.GetValue()) 117 98 except: 118 flag = False 119 if flag: 120 # set ftol in fitting 121 self.parent.set_ftol(self.ftol) 122 msg = "The ftol (LeastSq) is set to %s." % self.ftol 123 else: 124 msg = "Error in the selection... No changes in ftol." 125 # post event for info 126 wx.PostEvent(self.parent.parent, 127 StatusEvent(status=msg, info='warning')) 128 129 self.Destroy() 99 return None 100 return SANS_F_TOL
Note: See TracChangeset
for help on using the changeset viewer.