Changes in src/sas/perspectives/fitting/fitpage.py [85ccd3a:5265420] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/fitpage.py
r85ccd3a r5265420 26 26 from sas.perspectives.fitting.basepage import PageInfoEvent as PageInfoEvent 27 27 from sas.models.qsmearing import smear_selection 28 from .basepage import ModelTextCtrl 28 29 29 30 … … 284 285 285 286 #textcntrl for custom resolution 286 self.smear_pinhole_max = self.ModelTextCtrl(self, -1,287 self.smear_pinhole_max = ModelTextCtrl(self, -1, 287 288 size=(_BOX_WIDTH - 25, 20), 288 289 style=wx.TE_PROCESS_ENTER, 289 290 text_enter_callback=self.onPinholeSmear) 290 self.smear_pinhole_min = self.ModelTextCtrl(self, -1,291 self.smear_pinhole_min = ModelTextCtrl(self, -1, 291 292 size=(_BOX_WIDTH - 25, 20), 292 293 style=wx.TE_PROCESS_ENTER, 293 294 text_enter_callback=self.onPinholeSmear) 294 self.smear_slit_height = self.ModelTextCtrl(self, -1,295 self.smear_slit_height = ModelTextCtrl(self, -1, 295 296 size=(_BOX_WIDTH - 25, 20), 296 297 style=wx.TE_PROCESS_ENTER, 297 298 text_enter_callback=self.onSlitSmear) 298 self.smear_slit_width = self.ModelTextCtrl(self, -1,299 self.smear_slit_width = ModelTextCtrl(self, -1, 299 300 size=(_BOX_WIDTH - 25, 20), 300 301 style=wx.TE_PROCESS_ENTER, … … 303 304 ## smear 304 305 self.smear_data_left = BGTextCtrl(self, -1, 305 size=(_BOX_WIDTH - 25, 20), style=0)306 size=(_BOX_WIDTH - 25, 20), style=0) 306 307 self.smear_data_left.SetValue(str(self.dq_l)) 307 308 self.smear_data_right = BGTextCtrl(self, -1, 308 size=(_BOX_WIDTH - 25, 20), style=0)309 size=(_BOX_WIDTH - 25, 20), style=0) 309 310 self.smear_data_right.SetValue(str(self.dq_r)) 310 311 … … 355 356 self.Npts_fit.SetToolTipString(\ 356 357 " Npts : number of points selected for fitting") 357 self.Npts_total = self.ModelTextCtrl(self, -1,358 size=(_BOX_WIDTH, 20),359 style=wx.TE_PROCESS_ENTER,360 text_enter_callback=self._onQrangeEnter)358 self.Npts_total = ModelTextCtrl(self, -1, 359 size=(_BOX_WIDTH, 20), 360 style=wx.TE_PROCESS_ENTER, 361 text_enter_callback=self._onQrangeEnter) 361 362 self.Npts_total.SetValue(format_number(self.npts_x)) 362 363 self.Npts_total.SetToolTipString(\ … … 515 516 self.sizer5.Clear(True) 516 517 517 self.qmin = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),518 519 520 521 518 self.qmin = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 519 style=wx.TE_PROCESS_ENTER, 520 set_focus_callback=self.qrang_set_focus, 521 text_enter_callback=self._onQrangeEnter, 522 name='qmin') 522 523 self.qmin.SetValue(str(self.qmin_x)) 523 524 q_tip = "Click outside of the axes\n to remove the lines." … … 526 527 self.qmin.SetToolTipString(qmin_tip) 527 528 528 self.qmax = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),529 530 531 532 529 self.qmax = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 530 style=wx.TE_PROCESS_ENTER, 531 set_focus_callback=self.qrang_set_focus, 532 text_enter_callback=self._onQrangeEnter, 533 name='qmax') 533 534 self.qmax.SetValue(str(self.qmax_x)) 534 535 qmax_tip = "Maximum value of Q.\n" … … 686 687 ix = 1 687 688 value = self.model.getParam(name1) 688 ctl1 = self.ModelTextCtrl(self, -1,689 690 689 ctl1 = ModelTextCtrl(self, -1, 690 size=(_BOX_WIDTH / 1.3, 20), 691 style=wx.TE_PROCESS_ENTER) 691 692 ctl1.SetLabel('PD[ratio]') 692 693 poly_text = "Polydispersity (STD/mean) of %s\n" % item … … 715 716 716 717 ix = 4 717 ctl3 = self.ModelTextCtrl(self, -1,718 719 720 718 ctl3 = ModelTextCtrl(self, -1, 719 size=(_BOX_WIDTH / 2, 20), 720 style=wx.TE_PROCESS_ENTER, 721 text_enter_callback=self._onparamRangeEnter) 721 722 722 723 self.sizer4_4.Add(ctl3, (iy, ix), (1, 1), … … 724 725 725 726 ix = 5 726 ctl4 = self.ModelTextCtrl(self, -1,727 728 727 ctl4 = ModelTextCtrl(self, -1, 728 size=(_BOX_WIDTH / 2, 20), 729 style=wx.TE_PROCESS_ENTER, 729 730 text_enter_callback=self._onparamRangeEnter) 730 731 … … 738 739 ix = 6 739 740 value = self.model.getParam(name2) 740 Tctl = self.ModelTextCtrl(self, -1,741 742 741 Tctl = ModelTextCtrl(self, -1, 742 size=(_BOX_WIDTH / 2.2, 20), 743 style=wx.TE_PROCESS_ENTER) 743 744 744 745 Tctl.SetValue(str(format_number(value))) … … 750 751 ix = 7 751 752 value = self.model.getParam(name3) 752 Tct2 = self.ModelTextCtrl(self, -1,753 754 753 Tct2 = ModelTextCtrl(self, -1, 754 size=(_BOX_WIDTH / 2.2, 20), 755 style=wx.TE_PROCESS_ENTER) 755 756 756 757 Tct2.SetValue(str(format_number(value))) … … 811 812 ix = 1 812 813 value = self.model.getParam(name1) 813 ctl1 = self.ModelTextCtrl(self, -1,814 815 814 ctl1 = ModelTextCtrl(self, -1, 815 size=(_BOX_WIDTH / 1.3, 20), 816 style=wx.TE_PROCESS_ENTER) 816 817 poly_tip = "Absolute Sigma for %s." % item 817 818 ctl1.SetToolTipString(poly_tip) … … 859 860 860 861 ix = 4 861 ctl3 = self.ModelTextCtrl(self, -1,862 863 862 ctl3 = ModelTextCtrl(self, -1, 863 size=(_BOX_WIDTH / 2, 20), 864 style=wx.TE_PROCESS_ENTER, 864 865 text_enter_callback=self._onparamRangeEnter) 865 866 … … 870 871 871 872 ix = 5 872 ctl4 = self.ModelTextCtrl(self, -1,873 size=(_BOX_WIDTH / 2, 20),874 style=wx.TE_PROCESS_ENTER,873 ctl4 = ModelTextCtrl(self, -1, 874 size=(_BOX_WIDTH / 2, 20), 875 style=wx.TE_PROCESS_ENTER, 875 876 text_enter_callback=self._onparamRangeEnter) 876 877 self.sizer4_4.Add(ctl4, (iy, ix), (1, 1), … … 886 887 ix = 6 887 888 value = self.model.getParam(name2) 888 Tctl = self.ModelTextCtrl(self, -1,889 890 889 Tctl = ModelTextCtrl(self, -1, 890 size=(_BOX_WIDTH / 2.2, 20), 891 style=wx.TE_PROCESS_ENTER) 891 892 892 893 Tctl.SetValue(str(format_number(value))) … … 906 907 ix = 7 907 908 value = self.model.getParam(name3) 908 Tct2 = self.ModelTextCtrl(self, -1,909 910 909 Tct2 = ModelTextCtrl(self, -1, 910 size=(_BOX_WIDTH / 2.2, 20), 911 style=wx.TE_PROCESS_ENTER) 911 912 912 913 Tct2.SetValue(str(format_number(value))) … … 1061 1062 label = "Fit" 1062 1063 color = "black" 1063 self.btFit.Enable(False)1064 #self.btFit.Enable(False) 1064 1065 self.btFit.SetLabel(label) 1065 1066 self.btFit.SetForegroundColour(color) … … 1140 1141 self.state.formfactorcombobox = self.formfactorbox.GetLabel() 1141 1142 self.enable_fit_button() 1142 if self.model !=None:1143 if self.model is not None: 1143 1144 self.m_name = self.model.name 1144 1145 self.state.m_name = self.m_name … … 1152 1153 self._keep.Enable(not self.batch_on) 1153 1154 self._set_save_flag(True) 1154 # Reset smearer, model and data1155 if not copy_flag:1156 self.disable_smearer.SetValue(True)1157 self.enable_smearer.SetValue(False)1158 1155 1159 1156 # more disables for 2D … … 1162 1159 try: 1163 1160 # update smearer sizer 1164 #if not self.enable_smearer.GetValue():1165 # self.disable_smearer.SetValue(True)1166 1161 self.onSmear(None) 1167 1162 temp_smear = None … … 1268 1263 elif self.data.__class__.__name__ != "Data2D" and \ 1269 1264 not self.enable2D: 1265 enable_smearer = not self.disable_smearer.GetValue() 1270 1266 self._manager.set_smearer(smearer=temp_smearer, 1271 1267 fid=self.data.id, … … 1273 1269 qmin=float(self.qmin_x), 1274 1270 qmax=float(self.qmax_x), 1275 enable_smearer=not self.disable_smearer.GetValue(),1276 draw=True)1271 enable_smearer=enable_smearer, 1272 draw=True) 1277 1273 if flag: 1278 1274 #self.compute_chisqr(smearer= temp_smearer) … … 1772 1768 self.current_smearer = smear_selection(data, self.model) 1773 1769 flag = self.disable_smearer.GetValue() 1774 self.disable_smearer.SetValue(flag) 1775 if self.current_smearer == None: 1770 if self.current_smearer is None: 1776 1771 self.enable_smearer.Disable() 1777 1772 else: … … 1959 1954 if flag: 1960 1955 #set model view button 1961 if not self.enable_smearer.GetValue():1962 self.disable_smearer.SetValue(True)1963 1956 self.onSmear(None) 1964 1957 … … 2132 2125 if numpy.isfinite(float(cov[ind])): 2133 2126 val_err = format_number(cov[ind], True) 2134 if not self.is_mac: 2135 item[3].Show(True) 2136 item[4].Show(True) 2137 item[4].SetForegroundColour(wx.BLACK) 2138 item[4].SetValue(val_err) 2139 has_error = True 2140 else: 2141 val_err = 'NaN' 2142 if not self.is_mac: 2143 item[3].Show(True) 2144 item[4].Show(True) 2145 item[4].SetForegroundColour(wx.RED) 2146 item[4].SetValue(val_err) 2147 has_error = True 2127 else: 2128 val_err = 'NaN' 2129 if not self.is_mac: 2130 item[3].Show(True) 2131 item[4].Show(True) 2132 item[4].SetForegroundColour(wx.RED) 2133 item[4].SetValue(val_err) 2134 has_error = True 2148 2135 i += 1 2149 2136 else: … … 2196 2183 2197 2184 """ 2198 if self.model == None:2199 self.disable_smearer.SetValue(True)2200 if event == None:2201 return2202 msg = "Please select a Model first..."2203 wx.MessageBox(msg, 'Info')2204 wx.PostEvent(self._manager.parent,2205 StatusEvent(status="Smear: %s" % msg))2206 return2207 2208 2185 # Need update param values 2209 2186 self._update_paramv_on_fit() … … 2345 2322 ## set smearing value whether or not the data contain the smearing info 2346 2323 2324 enable_smearer = not self.disable_smearer.GetValue() 2347 2325 self._manager.set_smearer(smearer=self.current_smearer, 2348 fid=self.data.id,2349 qmin=float(self.qmin_x),2350 qmax=float(self.qmax_x),2351 enable_smearer=not self.disable_smearer.GetValue(),2352 uid=self.uid)2326 fid=self.data.id, 2327 qmin=float(self.qmin_x), 2328 qmax=float(self.qmax_x), 2329 enable_smearer=enable_smearer, 2330 uid=self.uid) 2353 2331 return msg 2354 2332 … … 2378 2356 are compute when fitting 2379 2357 """ 2380 if self.model == None:2381 self.disable_smearer.SetValue(True)2382 if event == None:2383 return2384 msg = "Please select a Model first..."2385 wx.MessageBox(msg, 'Info')2386 wx.PostEvent(self._manager.parent,2387 StatusEvent(status="Smear: %s" % msg))2388 return2389 2390 2358 # Need update param values 2391 2359 self._update_paramv_on_fit() … … 2475 2443 of the values entered for slit smear 2476 2444 """ 2477 if self.data.__class__.__name__ == "Data2D" or \ 2478 self.enable2D: 2445 if self.data.__class__.__name__ == "Data2D" or self.enable2D: 2479 2446 return 2480 2447 # make sure once more if it is smearer … … 2513 2480 self.current_smearer = smear_selection(data, self.model) 2514 2481 ## set smearing value whether or not the data contain the smearing info 2482 enable_smearer = not self.disable_smearer.GetValue() 2515 2483 self._manager.set_smearer(smearer=self.current_smearer, 2516 fid=self.data.id,2517 qmin=float(self.qmin_x),2518 qmax=float(self.qmax_x),2519 enable_smearer=not self.disable_smearer.GetValue(),2520 uid=self.uid)2484 fid=self.data.id, 2485 qmin=float(self.qmin_x), 2486 qmax=float(self.qmax_x), 2487 enable_smearer=enable_smearer, 2488 uid=self.uid) 2521 2489 return msg 2522 2490 … … 2552 2520 return 2553 2521 2554 if self.model == None:2555 self.disable_smearer.SetValue(True)2556 if event == None:2557 return2558 msg = "Please select a Model first..."2559 wx.MessageBox(msg, 'Info')2560 wx.PostEvent(self._manager.parent,2561 StatusEvent(status="Smear: %s" % msg))2562 return2563 2522 # Need update param values 2564 2523 self._update_paramv_on_fit() 2565 if self.model !=None:2524 if self.model is not None: 2566 2525 if self.data.is_data: 2567 2526 self._manager.page_finder[self.uid].add_data(data=self.data) … … 2573 2532 2574 2533 ## set smearing value whether or not the data contain the smearing info 2534 enable_smearer = not self.disable_smearer.GetValue() 2575 2535 wx.CallAfter(self._manager.set_smearer, uid=self.uid, 2576 2536 smearer=temp_smearer, … … 2578 2538 qmin=float(self.qmin_x), 2579 2539 qmax=float(self.qmax_x), 2580 enable_smearer= not self.disable_smearer.GetValue(),2540 enable_smearer=enable_smearer, 2581 2541 draw=True) 2582 2542 … … 2594 2554 self._get_smear_info() 2595 2555 #renew smear sizer 2596 if self.smear_type !=None:2556 if self.smear_type is not None: 2597 2557 self.smear_description_smear_type.SetValue(str(self.smear_type)) 2598 2558 self.smear_data_left.SetValue(str(self.dq_l)) … … 2607 2567 self.current_smearer = temp_smearer 2608 2568 if self.enable_smearer.GetValue(): 2609 if self.current_smearer ==None:2569 if self.current_smearer is None: 2610 2570 wx.PostEvent(self._manager.parent, 2611 2571 StatusEvent(status="Data contains no smearing information")) … … 2953 2913 wx.EVT_COMBOBOX(fun_box, -1, self._on_fun_box) 2954 2914 else: 2955 fun_box = self.ModelTextCtrl(self, -1,2956 2915 fun_box = ModelTextCtrl(self, -1, 2916 size=(_BOX_WIDTH, 20), 2957 2917 style=wx.TE_PROCESS_ENTER, name='%s' % item) 2958 2918 fun_box.SetToolTipString(\ … … 2977 2937 ix += 1 2978 2938 value = self.model.getParam(item) 2979 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),2980 style=wx.TE_PROCESS_ENTER)2939 ctl1 = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 2940 style=wx.TE_PROCESS_ENTER) 2981 2941 ctl1.SetToolTipString(\ 2982 2942 "Hit 'Enter' after typing to update the plot.") … … 2999 2959 3000 2960 ix += 1 3001 ctl3 = self.ModelTextCtrl(self, -1,3002 3003 2961 ctl3 = ModelTextCtrl(self, -1, 2962 size=(_BOX_WIDTH / 1.9, 20), 2963 style=wx.TE_PROCESS_ENTER, 3004 2964 text_enter_callback=self._onparamRangeEnter) 3005 2965 min_bound = self.model.details[item][1] … … 3011 2971 3012 2972 ix += 1 3013 ctl4 = self.ModelTextCtrl(self, -1,3014 3015 2973 ctl4 = ModelTextCtrl(self, -1, 2974 size=(_BOX_WIDTH / 1.9, 20), 2975 style=wx.TE_PROCESS_ENTER, 3016 2976 text_enter_callback=self._onparamRangeEnter) 3017 2977 max_bound = self.model.details[item][2] … … 3115 3075 ix += 1 3116 3076 value = self.model.getParam(item) 3117 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),3118 style=wx.TE_PROCESS_ENTER)3077 ctl1 = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 3078 style=wx.TE_PROCESS_ENTER) 3119 3079 ctl1.SetToolTipString(\ 3120 3080 "Hit 'Enter' after typing to update the plot.") … … 3142 3102 3143 3103 ix += 1 3144 ctl3 = self.ModelTextCtrl(self, -1,3145 3146 3104 ctl3 = ModelTextCtrl(self, -1, 3105 size=(_BOX_WIDTH / 1.8, 20), 3106 style=wx.TE_PROCESS_ENTER, 3147 3107 text_enter_callback=self._onparamRangeEnter) 3148 3108 … … 3152 3112 3153 3113 ix += 1 3154 ctl4 = self.ModelTextCtrl(self, -1,3155 3156 3114 ctl4 = ModelTextCtrl(self, -1, 3115 size=(_BOX_WIDTH / 1.8, 20), 3116 style=wx.TE_PROCESS_ENTER, 3157 3117 text_enter_callback=self._onparamRangeEnter) 3158 3118 sizer.Add(ctl4, (iy, ix), (1, 1),
Note: See TracChangeset
for help on using the changeset viewer.