Changeset 2296316 in sasview for sansview/perspectives/fitting/fitpage.py
- Timestamp:
- Mar 29, 2011 12:40:33 PM (14 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:
- e0e2c44f
- Parents:
- 29ef718
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpage.py
r9466f2d6 r2296316 41 41 ## draw sizer 42 42 self._fill_datainfo_sizer() 43 self.is_2D = None 43 44 # get smear info from data 44 45 self._get_smear_info() … … 48 49 self._set_smear(self.data) 49 50 self.Bind(EVT_CHI2_UPDATE, self.on_complete_chisqr) 51 # bind key event 52 self.Bind(wx.EVT_RIGHT_DOWN, self.on_right_down) 50 53 self._set_bookmark_flag(False) 51 54 self._set_save_flag(False) … … 82 85 self.Layout() 83 86 return 84 for item in self.parameters:85 if self.engine_type =="scipy" :86 item[5].SetValue("")87 item[5].Hide()88 item[6].SetValue("")89 item[6].Hide()90 self.text2_min.Hide()91 self.text2_max.Hide()92 93 else:94 item[5].Show(True)95 item[6].Show(True)96 self.text2_min.Show(True)97 self.text2_max.Show(True)98 for item in self.fittable_param:99 if item[5]!=None and item[6]!=None and not \100 item in self.orientation_params_disp:101 if self.engine_type =="scipy" and \102 not item in self.orientation_params:103 item[5].SetValue("")104 item[5].Hide()105 item[6].SetValue("")106 item[6].Hide()107 self.text2_min.Hide()108 self.text2_max.Hide()109 self.text_disp_min.Hide()110 self.text_disp_max.Hide()111 else:112 item[5].Show(True)113 item[6].Show(True)114 self.text2_min.Show(True)115 self.text2_max.Show(True)116 self.text_disp_min.Show(True)117 self.text_disp_max.Show(True)118 119 for item in self.orientation_params:120 if item[5]!=None and item[6]!=None:121 if self.engine_type =="scipy" or \122 self.data.__class__.__name__ !="Data2D":123 item[5].SetValue("")124 item[5].Hide()125 item[6].SetValue("")126 item[6].Hide()127 else:128 item[5].Show(True)129 item[6].Show(True)130 131 for item in self.orientation_params_disp:132 if item[5]!=None and item[6]!=None:133 if self.engine_type =="scipy" or \134 self.data.__class__.__name__ !="Data2D":135 item[5].SetValue("")136 item[5].Hide()137 item[6].SetValue("")138 item[6].Hide()139 else:140 item[5].Show(True)141 item[6].Show(True)142 87 self.Layout() 143 88 self.Refresh() … … 163 108 smear_message_new_ssmear = "Please enter only the value of interest to customize smearing..." 164 109 smear_message_new_psmear = "Please enter both; the dQ will be generated by interpolation..." 165 smear_message_2d_x_title = "<dQ x>[1/A]:"166 smear_message_2d_y_title = "<dQ y>[1/A]:"110 smear_message_2d_x_title = "<dQp>[1/A]:" 111 smear_message_2d_y_title = "<dQs>[1/A]:" 167 112 smear_message_pinhole_min_title = "dQ_low[1/A]:" 168 113 smear_message_pinhole_max_title = "dQ_high[1/A]:" … … 253 198 self.Npts_total = BGTextCtrl(self, -1, "-", size=(75,20), style=0) 254 199 self.Npts_total.SetToolTipString(" Total Npts : total number of data points") 200 # Update and Draw button 201 self.draw_button = wx.Button(self,wx.NewId(),'Compute', size=(88,24)) 202 self.draw_button.Bind(wx.EVT_BUTTON, self._onDraw,id= self.draw_button.GetId()) 203 self.draw_button.SetToolTipString("Compute and Draw.") 204 255 205 box_description_1= wx.StaticText(self, -1,' Chi2/Npts') 256 206 box_description_2= wx.StaticText(self, -1,'Fitted Npts') 257 207 box_description_3= wx.StaticText(self, -1,'Data Npts') 258 box_description_4= wx.StaticText(self, -1,' ')208 #box_description_4= wx.StaticText(self, -1,' ') 259 209 260 210 … … 262 212 sizer_fit.Add(box_description_2,0,0) 263 213 sizer_fit.Add(box_description_3,0,0) 264 sizer_fit.Add( box_description_4,0,0)214 sizer_fit.Add(self.draw_button,0,0) 265 215 sizer_fit.Add(self.tcChi,0,0) 266 216 sizer_fit.Add(self.Npts_fit ,0,0) … … 281 231 self.smear_message_new_p = wx.StaticText(self, -1, smear_message_new_psmear , style=wx.ALIGN_LEFT) 282 232 self.smear_description_2d_x = wx.StaticText(self, -1, smear_message_2d_x_title , style=wx.ALIGN_LEFT) 233 self.smear_description_2d_x.SetToolTipString(" dQp(parallel) in q_r direction.") 283 234 self.smear_description_2d_y = wx.StaticText(self, -1, smear_message_2d_y_title , style=wx.ALIGN_LEFT) 235 self.smear_description_2d_y.SetToolTipString(" dQs(perpendicular) in q_phi direction.") 284 236 self.smear_description_pin_min = wx.StaticText(self, -1, smear_message_pinhole_min_title , style=wx.ALIGN_LEFT) 285 237 self.smear_description_pin_max = wx.StaticText(self, -1, smear_message_pinhole_max_title , style=wx.ALIGN_LEFT) … … 570 522 sizer.Layout() 571 523 572 def _set_sizer_dispersion(self , dispersity):524 def _set_sizer_dispersion(self): 573 525 """ 574 526 draw sizer with gaussian dispersity parameters … … 588 540 self._reset_dispersity() 589 541 590 # Create the dispersion objects 591 for item in self.model.dispersion.keys(): 592 #disp_model = GaussianDispersion() 593 disp_model = dispersity() 594 self._disp_obj_dict[item] = disp_model 595 self.model.set_dispersion(item, disp_model) 596 self.state._disp_obj_dict[item]= disp_model 597 598 599 ix=0 600 iy=1 542 ## fill a sizer with the combobox to select dispersion type 543 #sizer_select_dispers = wx.BoxSizer(wx.HORIZONTAL) 544 model_disp = wx.StaticText(self, -1, 'Function') 545 546 import sans.models.dispersion_models 547 self.polydisp= sans.models.dispersion_models.models 548 549 ix = 0 550 iy = 0 601 551 disp = wx.StaticText(self, -1, ' ') 602 552 self.sizer4_4.Add(disp,( iy, ix),(1,1), 603 553 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 604 554 ix += 1 605 values = wx.StaticText(self, -1, 'PD[ratio] 555 values = wx.StaticText(self, -1, 'PD[ratio]') 606 556 polytext = "Polydispersity (= STD/mean); " 607 557 polytext += "the standard deviation over the mean value." … … 614 564 self.sizer4_4.Add( self.text_disp_1,(iy, ix),(1,1),\ 615 565 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 616 self.text_disp_1.Hide()617 566 618 567 … … 621 570 self.sizer4_4.Add(self.text_disp_min,(iy, ix),(1,1),\ 622 571 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 623 self.text_disp_min.Hide() 572 624 573 ix +=1 625 574 self.text_disp_max = wx.StaticText(self, -1, 'Max') … … 635 584 self.sizer4_4.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 636 585 ix += 1 637 nsigmas = wx.StaticText(self, -1, 'Nsig mas')586 nsigmas = wx.StaticText(self, -1, 'Nsigs') 638 587 nsigmas.SetToolTipString(" Number of sigmas between which the range\n\ 639 588 of the distribution function will be used for weighting. \n\ … … 642 591 self.sizer4_4.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 643 592 0) 593 ix +=1 594 self.sizer4_4.Add(model_disp,(iy, ix),(1,1),\ 595 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 644 596 645 597 if self.engine_type=="park": … … 664 616 ix = 0 665 617 cb = wx.CheckBox(self, -1, name0, (10, 10)) 666 cb.SetToolTipString("Check for fitting")618 cb.SetToolTipString("Check mark to fit") 667 619 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 668 620 self.sizer4_4.Add( cb,( iy, ix),(1,1), 669 621 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 670 15)622 5) 671 623 ix = 1 672 624 value= self.model.getParam(name1) 673 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH ,20)625 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/1.3,20) 674 626 ,style=wx.TE_PROCESS_ENTER) 675 627 ctl1.SetLabel('PD[ratio]') … … 678 630 poly_text += " from the mean value." 679 631 ctl1.SetToolTipString(poly_text) 680 ctl1.SetValue(str (format_number(value )))632 ctl1.SetValue(str (format_number(value, True))) 681 633 self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) 682 634 ## text to show error sign … … 688 640 689 641 ix = 3 690 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH ,20),642 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/1.3,20), 691 643 style=0) 692 644 … … 703 655 self.sizer4_4.Add(ctl3, (iy,ix),(1,1), 704 656 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 705 ctl3.Hide()657 706 658 707 659 ix = 5 … … 713 665 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 714 666 715 ctl4.Hide()716 667 717 668 if self.engine_type=="park": 718 669 ctl3.Show(True) 719 670 ctl4.Show(True) 720 721 self.fittable_param.append([cb,name1,ctl1,text2, 722 ctl2, ctl3, ctl4,None]) 723 671 724 672 elif p=="npts": 725 673 ix = 6 726 674 value= self.model.getParam(name2) 727 675 Tctl = self.ModelTextCtrl(self, -1, 728 size=(_BOX_WIDTH/2,20),676 size=(_BOX_WIDTH/2.2,20), 729 677 style=wx.TE_PROCESS_ENTER) 730 678 … … 738 686 value= self.model.getParam(name3) 739 687 Tct2 = self.ModelTextCtrl(self, -1, 740 size=(_BOX_WIDTH/2 ,20),688 size=(_BOX_WIDTH/2.2,20), 741 689 style=wx.TE_PROCESS_ENTER) 742 690 … … 744 692 self.sizer4_4.Add(Tct2, (iy,ix),(1,1), 745 693 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 746 ix +=1747 self.sizer4_4.Add((20,20), (iy,ix),(1,1),748 wx.EXPAND|wx.ADJUST_MINSIZE, 0)694 #ix +=1 695 #self.sizer4_4.Add((20,20), (iy,ix),(1,1), 696 # wx.EXPAND|wx.ADJUST_MINSIZE, 0) 749 697 750 self.fixed_param.append([None,name3, Tct2 751 ,None,None,None, 752 None,None]) 753 698 self.fixed_param.append([None, name3, Tct2, 699 None, None, None, 700 None, None]) 701 702 703 ix = 8 704 disp_box = wx.ComboBox(self, -1,size=(65,-1), 705 style=wx.CB_READONLY, name = '%s'% name1) 706 for key, value in self.polydisp.iteritems(): 707 name_disp = str(key) 708 disp_box.Append(name_disp,value) 709 disp_box.SetStringSelection("gaussian") 710 wx.EVT_COMBOBOX(disp_box,-1, self._on_disp_func) 711 self.sizer4_4.Add(disp_box,(iy,ix),(1,1), wx.EXPAND) 712 self.fittable_param.append([cb,name1,ctl1,text2, 713 ctl2, ctl3, ctl4, disp_box]) 714 754 715 ix =0 755 716 iy +=1 … … 776 737 ix = 0 777 738 cb = wx.CheckBox(self, -1, name0, (10, 10)) 778 cb.SetToolTipString("Check for fitting")739 cb.SetToolTipString("Check mark to fit") 779 740 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 780 741 self.sizer4_4.Add( cb,( iy, ix),(1,1), 781 742 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 782 15)743 5) 783 744 if self.data.__class__.__name__ =="Data2D": 784 745 cb.Show(True) … … 787 748 ix = 1 788 749 value= self.model.getParam(name1) 789 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH ,750 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/1.3, 790 751 20),style=wx.TE_PROCESS_ENTER) 791 752 poly_tip = "Absolute Sigma for %s." % item 792 753 ctl1.SetToolTipString(poly_tip) 793 ctl1.SetValue(str (format_number(value )))754 ctl1.SetValue(str (format_number(value, True))) 794 755 if self.data.__class__.__name__ =="Data2D": 795 756 if first_orient: … … 817 778 818 779 ix = 3 819 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH ,20),780 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/1.3,20), 820 781 style=0) 821 782 … … 842 803 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 843 804 ctl4.Hide() 844 #if self.data.__class__.__name__ =="Data2D":845 #ctl4.Enable(True)846 #elif ctl4.Shown():847 #ctl4.Hide()848 805 849 if self.engine_type=="park" and \ 850 self.data.__class__.__name__ =="Data2D": 806 if self.data.__class__.__name__ =="Data2D": 851 807 ctl3.Show(True) 852 808 ctl4.Show(True) 853 854 855 856 857 self.fittable_param.append([cb,name1,ctl1,text2, 858 ctl2, ctl3, ctl4,None]) 859 self.orientation_params_disp.append([cb,name1,ctl1, 860 text2, ctl2, ctl3, ctl4,None]) 809 861 810 elif p=="npts": 862 811 ix = 6 863 812 value= self.model.getParam(name2) 864 813 Tctl = self.ModelTextCtrl(self, -1, 865 size=(_BOX_WIDTH/2,20),814 size=(_BOX_WIDTH/2.2, 20), 866 815 style=wx.TE_PROCESS_ENTER) 867 816 … … 882 831 value= self.model.getParam(name3) 883 832 Tct2 = self.ModelTextCtrl(self, -1, 884 size=(_BOX_WIDTH/2 ,20),833 size=(_BOX_WIDTH/2.2,20), 885 834 style=wx.TE_PROCESS_ENTER) 886 835 … … 892 841 self.sizer4_4.Add(Tct2, (iy,ix),(1,1), 893 842 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 894 ix +=1 843 895 844 896 845 self.fixed_param.append([None,name3, Tct2 … … 900 849 Tct2 ,None,None, None, None,None]) 901 850 851 852 ix = 8 853 disp_box = wx.ComboBox(self, -1,size=(65,-1), 854 style=wx.CB_READONLY, name = '%s'% name1) 855 for key, value in self.polydisp.iteritems(): 856 name_disp = str(key) 857 disp_box.Append(name_disp,value) 858 disp_box.SetStringSelection("gaussian") 859 wx.EVT_COMBOBOX(disp_box,-1, self._on_disp_func) 860 self.sizer4_4.Add(disp_box,(iy,ix),(1,1), wx.EXPAND) 861 self.fittable_param.append([cb,name1,ctl1,text2, 862 ctl2, ctl3, ctl4, disp_box]) 863 self.orientation_params_disp.append([cb,name1,ctl1, 864 text2, ctl2, ctl3, ctl4, disp_box]) 865 866 if self.data.__class__.__name__ =="Data2D": 867 disp_box.Show(True) 868 else: 869 disp_box.Hide() 870 871 902 872 self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict) 903 873 … … 920 890 self.Layout() 921 891 892 893 def _onDraw(self, event): 894 """ 895 Update and Draw the model 896 """ 897 if self.model ==None: 898 msg="Please select a Model first..." 899 wx.MessageBox(msg, 'Info') 900 wx.PostEvent(self.manager.parent, StatusEvent(status=\ 901 "Draw model: %s"%msg)) 902 return 903 flag = self._update_paramv_on_fit() 904 self._onparamEnter_helper() 905 if not flag: 906 msg= "The parameters are invalid" 907 wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) 908 return 909 910 922 911 def _onFit(self, event): 923 912 """ … … 934 923 wx.MessageBox(msg, 'Info') 935 924 wx.PostEvent(self._manager.parent, StatusEvent(status=\ 936 "Fit: %s" % msg))925 "Fit: %s"%msg, type="stop")) 937 926 return 938 927 … … 941 930 if not flag: 942 931 msg= "Fitting range or parameters are invalid" 943 wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) 932 wx.PostEvent(self.parent.parent, StatusEvent(status= msg, 933 type="stop")) 944 934 return 945 935 946 936 if len(self.param_toFit) <= 0: 947 937 msg= "Select at least one parameter to fit" 948 wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) 938 wx.PostEvent(self.parent.parent, StatusEvent(status= msg, 939 type="stop" )) 949 940 return 950 941 … … 1227 1218 self.set_npts2fit() 1228 1219 else: 1229 if self.data is not None: 1230 1231 index_data = ((self.qmin_x <= self.data.x)& \ 1232 (self.data.x <= self.qmax_x)) 1233 self.Npts_fit.SetValue(str(len(self.data.x[index_data]))) 1234 1220 index_data = ((self.qmin_x <= self.data.x)& \ 1221 (self.data.x <= self.qmax_x)) 1222 self.Npts_fit.SetValue(str(len(self.data.x[index_data]))) 1235 1223 1236 1224 else: … … 1698 1686 raise ValueError,"missing parameter to fit" 1699 1687 1700 def onsetValues(self, chisqr,p_name, out,cov):1688 def onsetValues(self, chisqr, p_name, out, cov): 1701 1689 """ 1702 1690 Build the panel from the fit result … … 1718 1706 1719 1707 #Check if chi2 is finite 1720 if chisqr != None ornumpy.isfinite(chisqr):1708 if chisqr != None and numpy.isfinite(chisqr): 1721 1709 #format chi2 1722 1710 if self.engine_type == "park": … … 1724 1712 if npt_fit > 0: 1725 1713 chisqr =chisqr/npt_fit 1726 chi2 = format_number(chisqr )1714 chi2 = format_number(chisqr, True) 1727 1715 self.tcChi.SetValue(chi2) 1728 1716 self.tcChi.Refresh() … … 1735 1723 1736 1724 try: 1737 n = self.disp_box.GetCurrentSelection() 1738 dispersity= self.disp_box.GetClientData(n) 1739 if dispersity !=None and self.enable_disp.GetValue(): 1740 name= dispersity.__name__ 1741 if name == "GaussianDispersion": 1742 if hasattr(self,"text_disp_1" ): 1743 if self.text_disp_1 !=None: 1744 self.text_disp_1.Hide() 1725 if self.enable_disp.GetValue(): 1726 if hasattr(self,"text_disp_1" ): 1727 if self.text_disp_1 != None: 1728 self.text_disp_1.Hide() 1745 1729 except: 1746 1730 dispersty = None … … 1748 1732 #set the panel when fit result are float not list 1749 1733 if out.__class__== numpy.float64: 1750 self.param_toFit[0][2].SetValue(format_number(out ))1734 self.param_toFit[0][2].SetValue(format_number(out, True)) 1751 1735 1752 1736 if self.param_toFit[0][4].IsShown: … … 1755 1739 self.text2_3.Show(True) 1756 1740 try: 1757 if dispersity !=None: 1758 name= dispersity.__name__ 1759 if name == "GaussianDispersion" and \ 1760 self.enable_disp.GetValue(): 1761 if hasattr(self,"text_disp_1" ): 1762 if self.text_disp_1 !=None: 1763 self.text_disp_1.Show(True) 1741 if self.enable_disp.GetValue(): 1742 if hasattr(self,"text_disp_1" ): 1743 if self.text_disp_1 !=None: 1744 self.text_disp_1.Show(True) 1764 1745 except: 1765 1746 pass … … 1771 1752 self.param_toFit[0][3].Show(True) 1772 1753 self.param_toFit[0][4].Show(True) 1773 self.param_toFit[0][4].SetValue(format_number(cov[0] ))1754 self.param_toFit[0][4].SetValue(format_number(cov[0], True)) 1774 1755 has_error = True 1775 1756 else: … … 1788 1769 break 1789 1770 if len(out)<=len(self.param_toFit) and out[ind] !=None: 1790 val_out = format_number(out[ind] )1771 val_out = format_number(out[ind], True) 1791 1772 item[2].SetValue(val_out) 1792 1773 … … 1795 1776 try: 1796 1777 if dispersity !=None: 1797 name= dispersity.__name__ 1798 if name == "GaussianDispersion" and \ 1799 self.enable_disp.GetValue(): 1778 if self.enable_disp.GetValue(): 1800 1779 if hasattr(self,"text_disp_1" ): 1801 1780 if self.text_disp_1!=None: … … 1807 1786 if cov[ind]!=None : 1808 1787 if numpy.isfinite(float(cov[ind])): 1809 val_err = format_number(cov[ind] )1788 val_err = format_number(cov[ind], True) 1810 1789 item[3].Show(True) 1811 1790 item[4].Show(True) … … 1821 1800 ## save current state 1822 1801 self.save_current_state() 1823 #plot model 1824 self._draw_model() 1825 self._lay_out() 1802 #plot model ( when drawing, do not update chisqr value again) 1803 self._draw_model(update_chisqr=False) 1804 self._lay_out() 1805 self.Refresh() 1826 1806 #PostStatusEvent 1827 1807 msg = "Fit completed! " … … 2267 2247 else: 2268 2248 output = event.output 2269 self.tcChi.SetValue(str(format_number(output )))2249 self.tcChi.SetValue(str(format_number(output, True))) 2270 2250 2271 2251 self.state.tcChi = self.tcChi.GetValue() … … 2296 2276 item[0].SetValue(True) 2297 2277 self.param_toFit.append(item ) 2278 try: 2279 if len(self.values[item[1]]) > 0: 2280 item[0].SetValue(False) 2281 except: 2282 pass 2283 2298 2284 else: 2299 2285 ## for 1D all parameters except orientation … … 2301 2287 item[0].SetValue(True) 2302 2288 self.param_toFit.append(item ) 2289 try: 2290 if len(self.values[item[1]]) > 0: 2291 item[0].SetValue(False) 2292 except: 2293 pass 2294 2303 2295 else: 2304 2296 for item in self.parameters: … … 2476 2468 sizer.Add(self.text2_min,(iy, ix),(1,1),\ 2477 2469 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2478 self.text2_min.Hide()2470 #self.text2_min.Hide() 2479 2471 ix +=1 2480 2472 self.text2_max = wx.StaticText(self, -1, 'Max') 2481 2473 sizer.Add(self.text2_max,(iy, ix),(1,1),\ 2482 2474 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2483 self.text2_max.Hide()2475 #self.text2_max.Hide() 2484 2476 ix += 1 2485 2477 self.text2_4 = wx.StaticText(self, -1, '[Units]') … … 2487 2479 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2488 2480 self.text2_4.Hide() 2489 if self.engine_type=="park":2490 self.text2_max.Show(True)2491 self.text2_min.Show(True)2492 2481 2493 2482 for item in keys: … … 2524 2513 style=wx.TE_PROCESS_ENTER, name ='%s'% item) 2525 2514 fun_box.SetToolTipString("Hit 'Enter' after typing.") 2526 fun_box.SetValue(format_number(value ))2515 fun_box.SetValue(format_number(value, True)) 2527 2516 sizer.Add(fun_box, (iy,ix),(1,1), wx.EXPAND) 2528 2517 self.str_parameters.append([None,item, fun_box, 2529 None,None,None,None,None]) 2518 None, None, None, 2519 None, None]) 2530 2520 2531 2521 … … 2533 2523 ## add parameters name with checkbox for selecting to fit 2534 2524 cb = wx.CheckBox(self, -1, item ) 2535 cb.SetToolTipString(" Check for fitting.")2525 cb.SetToolTipString(" Check mark to fit.") 2536 2526 #cb.SetValue(True) 2537 2527 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) … … 2546 2536 style=wx.TE_PROCESS_ENTER) 2547 2537 ctl1.SetToolTipString("Hit 'Enter' after typing.") 2548 ctl1.SetValue(format_number(value ))2538 ctl1.SetValue(format_number(value, True)) 2549 2539 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 2550 2540 ## text to show error sign … … 2555 2545 text2.Hide() 2556 2546 ix += 1 2557 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH ,20), style=0)2547 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/1.2,20), style=0) 2558 2548 sizer.Add(ctl2, (iy,ix),(1,1), 2559 2549 wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 2561 2551 2562 2552 ix += 1 2563 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/ 2,20),2553 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/1.9,20), 2564 2554 style=wx.TE_PROCESS_ENTER, 2565 2555 text_enter_callback = self._onparamRangeEnter) … … 2567 2557 sizer.Add(ctl3, (iy,ix),(1,1), 2568 2558 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2569 ctl3.Hide()2570 2559 2571 2560 ix += 1 2572 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/ 2,20),2561 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/1.9,20), 2573 2562 style=wx.TE_PROCESS_ENTER, 2574 2563 text_enter_callback = self._onparamRangeEnter) 2575 2564 sizer.Add(ctl4, (iy,ix),(1,1), 2576 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2577 2578 ctl4.Hide() 2565 wx.EXPAND|wx.FIXED_MINSIZE, 0) 2579 2566 2580 if self.engine_type=="park":2581 ctl3.Show(True)2582 ctl4.Show(True)2583 2567 ix +=1 2584 2568 # Units … … 2632 2616 cb = wx.CheckBox(self, -1, item ) 2633 2617 cb.SetValue(False) 2634 cb.SetToolTipString("Check for fitting")2618 cb.SetToolTipString("Check mark to fit") 2635 2619 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 2636 2620 if self.data.__class__.__name__ =="Data2D": … … 2647 2631 style=wx.TE_PROCESS_ENTER) 2648 2632 ctl1.SetToolTipString("Hit 'Enter' after typing.") 2649 ctl1.SetValue(format_number(value ))2633 ctl1.SetValue(format_number(value, True)) 2650 2634 if self.data.__class__.__name__ =="Data2D": 2651 2635 ctl1.Show(True) … … 2660 2644 text2.Hide() 2661 2645 ix += 1 2662 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH ,20), style=0)2646 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/1.2,20), style=0) 2663 2647 sizer.Add(ctl2, (iy,ix),(1,1), 2664 2648 wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 2667 2651 2668 2652 ix += 1 2669 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/ 2,20),2653 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/1.8,20), 2670 2654 style=wx.TE_PROCESS_ENTER, 2671 2655 text_enter_callback = self._onparamRangeEnter) … … 2676 2660 2677 2661 ix += 1 2678 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/ 2,20),2662 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/1.8,20), 2679 2663 style=wx.TE_PROCESS_ENTER, 2680 2664 text_enter_callback = self._onparamRangeEnter) … … 2684 2668 ctl4.Hide() 2685 2669 2686 if self.engine_type =="park" and \ 2687 self.data.__class__.__name__ =="Data2D": 2670 if self.data.__class__.__name__ =="Data2D": 2688 2671 ctl3.Show(True) 2689 2672 ctl4.Show(True) … … 2727 2710 self.Layout() 2728 2711 self.Refresh() 2729 2712 2713 def on_right_down(self, event): 2714 """ 2715 Get key stroke event 2716 """ 2717 if self.data == None: 2718 return 2719 # Figuring out key combo: Cmd for copy, Alt for paste 2720 if event.AltDown() and event.ShiftDown(): 2721 self._show_ftol_dialog() 2722 flag = True 2723 else: 2724 flag = False 2725 # make event free 2726 event.Skip() 2727 # messages depending on the flag 2728 if not flag: 2729 msg = " Could not open ftol dialog;" 2730 msg += " Check if the Scipy fit engine is selected in the menubar." 2731 infor = 'warning' 2732 # inform msg to wx 2733 wx.PostEvent( self.parent.parent, 2734 StatusEvent(status= msg, info=infor)) 2735 2736 2737 def _show_ftol_dialog(self): 2738 """ 2739 Dialog to select ftol for Scipy 2740 """ 2741 from ftol_dialog import ChangeFtol 2742 panel = ChangeFtol(self) 2743 panel.ShowModal() 2744 2730 2745 def _onModel2D(self, event): 2731 2746 """
Note: See TracChangeset
for help on using the changeset viewer.