Changeset 7975f2b in sasview for sansview/perspectives/fitting
- Timestamp:
- Dec 13, 2009 4:48:11 PM (15 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:
- fe9c19b4
- Parents:
- 7ab35154
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
redd166b r7975f2b 7 7 import math 8 8 import string 9 from sans.guiframe.utils import format_number,check_float 10 from sans.guicomm.events import StatusEvent 9 from sans.guiframe.utils import format_number,check_float,check_value 10 from sans.guicomm.events import StatusEvent 11 11 import pagestate 12 12 from pagestate import PageState … … 163 163 kill_focus_callback = None, set_focus_callback = None, 164 164 mouse_up_callback = None, text_enter_callback = None): 165 165 166 166 wx.TextCtrl.__init__(self, parent, id, value, pos, size, style, validator, name) 167 167 … … 208 208 if start==end: 209 209 control.SetSelection(-1,-1) 210 210 211 211 212 212 def onContextMenu(self, event): … … 455 455 #TODO: total hack - fix this 456 456 self.state.model= self.model.clone() 457 #if not hasattr(self.model, "_persistency_dict"): 457 458 458 self.model._persistency_dict = {} 459 459 self.model._persistency_dict[p] = [self.values, self.weights] … … 499 499 500 500 self.state.model.name= self.model.name 501 #if not hasattr(self.model, "_persistency_dict"):502 #self.model._persistency_dict = {}503 #self.state.model._persistency_dict= copy.deepcopy(self.model._persistency_dict)504 501 505 502 #Remember fit engine_type for fit panel … … 508 505 if self.manager !=None: 509 506 self.manager._on_change_engine(engine=self.engine_type) 510 #self.engine_type = self.manager._return_engine_type()511 507 512 508 self.state.engine_type = self.engine_type … … 820 816 self.model.set_dispersion(item, disp_model) 821 817 822 #self.model._persistency_dict = {}823 818 self.model._persistency_dict[item] = [state.values, state.weights] 824 819 … … 925 920 use : _check_value_enter 926 921 """ 922 # Flag to register when a parameter has changed. 923 is_modified = False 927 924 #self._undo.Enable(True) 928 925 if self.model !=None: 929 # Flag to register when a parameter has changed.930 is_modified = False931 926 try: 932 927 is_modified =self._check_value_enter( self.fittable_param ,is_modified) … … 940 935 # If qmin and qmax have been modified, update qmin and qmax and 941 936 # set the is_modified flag to True 942 from sans.guiframe.utils import check_value943 937 if check_value( self.qmin, self.qmax): 944 if float(self.qmin.GetValue()) != self.qmin_x: 945 self.qmin_x = float(self.qmin.GetValue()) 938 tempmin = float(self.qmin.GetValue()) 939 if tempmin != self.qmin_x: 940 self.qmin_x = tempmin 946 941 is_modified = True 947 if float(self.qmax.GetValue()) != self.qmax_x: 948 self.qmax_x = float(self.qmax.GetValue()) 942 tempmax = float(self.qmax.GetValue()) 943 if tempmax != self.qmax_x: 944 self.qmax_x = tempmax 949 945 is_modified = True 950 946 self.fitrange = True … … 953 949 if self.npts != None: 954 950 if check_float(self.npts): 955 if float(self.npts.GetValue()) != self.num_points: 956 self.num_points = float(self.npts.GetValue()) 951 temp_npts = float(self.npts.GetValue()) 952 if temp_npts != self.num_points: 953 self.num_points = temp_npts 957 954 is_modified = True 958 955 else: … … 965 962 self.state_change= True 966 963 self._draw_model() 967 self.Layout() 968 self.Refresh() 969 964 self._sleep4sec() 965 self.Layout() 966 self.Refresh() 967 return is_modified 968 970 969 def _update_paramv_on_fit(self): 971 970 """ 972 971 make sure that update param values just before the fitting 973 972 """ 974 from sans.guiframe.utils import check_value975 973 #flag for qmin qmax check values 976 974 flag =False … … 985 983 986 984 # If qmin and qmax have been modified, update qmin and qmax and 985 # Here we should check whether the boundaries have been modified. 986 # If qmin and qmax have been modified, update qmin and qmax and 987 # set the is_modified flag to True 987 988 if check_value( self.qmin, self.qmax): 988 if float(self.qmin.GetValue()) != self.qmin_x: 989 self.qmin_x = float(self.qmin.GetValue()) 990 991 if float(self.qmax.GetValue()) != self.qmax_x: 992 self.qmax_x = float(self.qmax.GetValue()) 989 tempmin = float(self.qmin.GetValue()) 990 if tempmin != self.qmin_x: 991 self.qmin_x = tempmin 992 tempmax = float(self.qmax.GetValue()) 993 if tempmax != self.qmax_x: 994 self.qmax_x = tempmax 993 995 flag = True 994 995 if self.npts != None: 996 if check_float(self.npts): 997 if float(self.npts.GetValue()) != self.num_points: 998 self.num_points = float(self.npts.GetValue()) 996 else: 997 flag = False 999 998 else: 999 flag = False 1000 1000 msg= "Cannot Fit :Must select a model!!! " 1001 1001 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) … … 1231 1231 if self.enable_smearer.GetValue(): 1232 1232 temp_smear= self.smearer 1233 1234 1233 self.manager.draw_model(self.model, data=self.data, 1235 1234 smearer= temp_smear, … … 1400 1399 1401 1400 return 0 1401 1402 def _onparamEnter(self,event): 1403 """ 1404 when enter value on panel redraw model according to changed 1405 """ 1406 tcrtl= event.GetEventObject() 1407 1408 #Clear msg if previously shown. 1409 msg= "" 1410 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1411 1412 ## save current state 1413 self.save_current_state() 1414 if event !=None: 1415 #self._undo.Enable(True) 1416 event = PageInfoEvent(page = self) 1417 wx.PostEvent(self.parent, event) 1418 1419 if check_float(tcrtl): 1420 1421 self._onparamEnter_helper() 1422 event.Skip() 1423 else: 1424 msg= "Cannot Plot :Must enter a number!!! " 1425 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1426 event.Skip() 1427 return 1402 1428 1403 1429 … … 1447 1473 self.disp_list =self.model.getDispParamList() 1448 1474 self.state.disp_list = self.disp_list 1449 #self.sizer4_4.Layout() 1450 self.Layout() 1451 #self.SetScrollbars(20,20,25,65) 1452 #self.Refresh() 1453 1454 1455 1456 def _onparamEnter(self,event): 1457 """ 1458 when enter value on panel redraw model according to changed 1459 """ 1460 1461 tcrtl= event.GetEventObject() 1462 1463 #Clear msg if previously shown. 1464 msg= "" 1465 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1466 1467 ## save current state 1468 self.save_current_state() 1469 if event !=None: 1470 #self._undo.Enable(True) 1471 event = PageInfoEvent(page = self) 1472 wx.PostEvent(self.parent, event) 1475 self.Layout() 1476 1473 1477 1474 if check_float(tcrtl):1475 1476 self._onparamEnter_helper()1477 1478 else:1479 msg= "Cannot Plot :Must enter a number!!! "1480 wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))1481 return1482 1483 1484 1478 def _check_value_enter(self, list, modified): 1485 1479 """ … … 1491 1485 if len(list)==0: 1492 1486 return is_modified 1493 1494 1487 for item in list: 1495 1488 #skip angle parameters for 1D … … 1504 1497 param_min= None 1505 1498 param_max= None 1506 1499 1507 1500 ## check minimun value 1508 1501 if item[5]!= None and item[5]!= "": 1509 1502 if item[5].GetValue().lstrip().rstrip()!="": 1510 1503 try: 1504 1511 1505 param_min = float(item[5].GetValue()) 1506 if check_value(item[2],item[5]): 1507 if numpy.isfinite(param_min): 1508 item[2].SetValue(format_number(param_min)) 1509 item[2].SetBackgroundColour(wx.WHITE) 1512 1510 except: 1513 1511 msg = "Wrong Fit parameter range entered " … … 1516 1514 is_modified = True 1517 1515 ## check maximum value 1518 if item[6]!= None and item[ 5]!= "":1516 if item[6]!= None and item[6]!= "": 1519 1517 if item[6].GetValue().lstrip().rstrip()!="": 1520 try: 1518 try: 1521 1519 param_max = float(item[6].GetValue()) 1520 if check_value(item[6],item[2]): 1521 if numpy.isfinite(param_max): 1522 item[2].SetValue(format_number(param_max)) 1523 item[2].SetBackgroundColour(wx.WHITE) 1522 1524 except: 1523 1525 msg = "Wrong Fit parameter range entered " … … 1525 1527 raise ValueError, msg 1526 1528 is_modified = True 1527 from sans.guiframe.utils import check_value1529 1528 1530 1529 1531 if param_min != None and param_max !=None: … … 1532 1534 msg+= "name %s of model %s "%(name, self.model.name) 1533 1535 wx.PostEvent(self.parent.parent, StatusEvent(status = msg)) 1534 1536 1535 1537 if name in self.model.details.keys(): 1536 if param_min != self.model.details[name][1] or param_max != self.model.details[name][2]:1537 1538 self.model.details[name][1:3]= param_min,param_max 1538 1539 is_modified = True 1539 1540 1540 1541 else: 1541 self.model.details [name] = ["",param_min,param_max]1542 is_modified = True1543 1542 self.model.details [name] = ["",param_min,param_max] 1543 is_modified = True 1544 1544 1545 value= float(item[2].GetValue()) 1545 1546 1546 1547 # If the value of the parameter has changed, 1547 1548 # +update the model and set the is_modified flag 1548 if value != self.model.getParam(name) :1549 if value != self.model.getParam(name) and numpy.isfinite(value): 1549 1550 self.model.setParam(name,value) 1550 1551 is_modified = True … … 1645 1646 self.save_current_state() 1646 1647 self.sizer4_4.Clear(True) 1647 #self.sizer4_4.Layout()1648 #self.sizer4.Layout()1649 1648 self.Layout() 1650 #self.Refresh() 1651 #self.SetScrollbars(20,20,25,65) 1649 1652 1650 return 1653 1651 if (len(self.disp_cb_dict)>0) : … … 1663 1661 1664 1662 pass 1665 # Redraw the model 1666 #self._draw_model() 1663 1667 1664 ## save state into 1668 1665 self.save_current_state() 1669 #self.sizer4_4.Layout() 1670 #self.sizer4.Layout() 1671 self.Layout() 1672 #self.SetScrollbars(20,20,25,65) 1666 self.Layout() 1673 1667 self.Refresh() 1674 1675 1668 1676 1669 1677 1670 def _on_select_Disp(self,event): … … 1683 1676 name = self.disp_box.GetValue() 1684 1677 dispersity= self.disp_box.GetClientData(n) 1685 1686 1678 self.disp_name = name 1687 1679 … … 1698 1690 wx.PostEvent(self.parent, event) 1699 1691 1700 #self.sizer4_4.Layout() 1701 #self.sizer4.Layout() 1702 #self.Layout() 1692 self.sizer4_4.Layout() 1693 self.sizer4.Layout() 1703 1694 self.SetScrollbars(20,20,25,65) 1704 #self.Refresh()1705 1695 1706 1696 def _set_sizer_arraydispersion(self): … … 1747 1737 self.state.disp_cb_dict[p]= self.disp_cb_dict[p].GetValue() 1748 1738 self.Bind(wx.EVT_RADIOBUTTON, self.select_disp_angle, id=self.disp_cb_dict[p].GetId()) 1749 #wx.EVT_RADIOBUTTON(self, self.disp_cb_dict[p].GetId(), self.select_disp_angle)1750 1739 self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1751 1740 … … 1757 1746 if not (self.enable2D or self.data.__class__.__name__ =="Data2D"): 1758 1747 self.disp_cb_dict[p].Hide() 1759 #self.disp_cb_dict[p].Disable()1760 1748 else: 1761 1749 self.disp_cb_dict[p].Show(True) 1762 #self.disp_cb_dict[p].Enable()1763 1750 self.Bind(wx.EVT_RADIOBUTTON, self.select_disp_angle, id=self.disp_cb_dict[p].GetId()) 1764 #wx.EVT_RADIOBUTTON(self, self.disp_cb_dict[p].GetId(), self.select_disp_angle)1765 1751 self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1766 1752 … … 1769 1755 iy +=1 1770 1756 self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 1771 #self.sizer4_4.Layout()1772 #self.sizer4.Layout()1773 1757 self.Layout() 1774 #self.SetScrollbars(20,20,25,65)1775 ## save state into1776 1758 1777 1759 self.state.orientation_params =[] … … 1815 1797 boxsizer1 = box_sizer 1816 1798 1817 self.qmin = BasicPage.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20),style=wx.TE_PROCESS_ENTER)1799 self.qmin = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20),style=wx.TE_PROCESS_ENTER) 1818 1800 self.qmin.SetValue(str(self.qmin_x)) 1819 1801 self.qmin.SetToolTipString("Minimun value of Q in linear scale.") 1820 #self.qmin.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)1821 #self.qmin.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)1822 #self.qmin.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)1823 1802 1824 self.qmax = BasicPage.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20),style=wx.TE_PROCESS_ENTER)1803 self.qmax = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20),style=wx.TE_PROCESS_ENTER) 1825 1804 self.qmax.SetValue(str(self.qmax_x)) 1826 1805 self.qmax.SetToolTipString("Maximum value of Q in linear scale.") 1827 #self.qmax.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)1828 #self.qmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)1829 #self.qmax.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)1830 1806 1831 1807 id = wx.NewId() 1832 1808 self.reset_qrange =wx.Button(self,id,'Reset',size=(70,23)) 1809 1833 1810 self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked,id=id) 1834 1811 self.reset_qrange.SetToolTipString("Reset Q range to the default values") … … 1857 1834 self.sizer5.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 1858 1835 self.sizer5.Layout() 1859 #self.Layout() 1860 #self.SetScrollbars(20,20,25,65) 1861 1836 1862 1837 1863 1838 def _fill_save_sizer(self): … … 1887 1862 self.sizer6.Layout() 1888 1863 self.SetScrollbars(20,20,25,65) 1889 1864 1865 def _lay_out(self): 1866 """ 1867 returns self.Layout 1868 Note: Mac seems to like this better when self.Layout is called after fitting. 1869 """ 1870 self._sleep4sec() 1871 self.Layout() 1872 self._sleep4sec() 1873 return 1874 1875 def _sleep4sec(self): 1876 """ 1877 sleep for 0.5 sec only on Mac 1878 """ 1879 if ON_MAC == True: 1880 time.sleep(0.5) 1881 1890 1882 def on_reset_clicked(self,event): 1891 1883 """ … … 1907 1899 self.num_points = _NPTS_DEFAULT 1908 1900 self.state.npts = self.num_points 1909 1901 1902 1910 1903 self.state.qmin = self.qmin_x 1911 1904 self.state.qmax = self.qmax_x -
sansview/perspectives/fitting/fitpage.py
redd166b r7975f2b 7 7 import copy 8 8 import math 9 import time 9 10 from sans.models.dispersion_models import ArrayDispersion, GaussianDispersion 10 11 11 12 from sans.guicomm.events import StatusEvent 12 from sans.guiframe.utils import format_number,check_float 13 13 from sans.guiframe.utils import format_number,check_float,check_value 14 14 15 ## event to post model to fit to fitting plugins 15 16 (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() … … 33 34 34 35 """ 36 35 37 def __init__(self,parent, page_info): 36 38 BasicPage.__init__(self, parent, page_info) 39 37 40 """ 38 41 Initialization of the Panel … … 92 95 self.text2_min.Hide() 93 96 self.text2_max.Hide() 97 94 98 else: 95 99 item[5].Show(True) … … 138 142 item[6].Show(True) 139 143 self.Layout() 140 141 144 self.Refresh() 145 142 146 def _fill_range_sizer(self): 143 147 """ … … 188 192 #Set sizer for Fitting section 189 193 self._set_range_sizer( title=title,box_sizer=boxsizer_range, object1=sizer_smearer, object= sizer_fit) 190 191 194 192 195 def _fill_datainfo_sizer(self): 193 196 """ … … 267 270 268 271 269 #def _set_sizer_gaussian(self):270 272 def _set_sizer_dispersion(self, dispersity): 271 273 """ … … 354 356 ix = 1 355 357 value= self.model.getParam(name1) 356 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),358 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 357 359 style=wx.TE_PROCESS_ENTER) 358 360 ctl1.SetValue(str (format_number(value))) … … 373 375 374 376 ix = 4 375 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,377 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 376 378 kill_focus_callback = self._onparamRangeEnter, 377 text_enter_callback = self._onparamRangeEnter, 378 set_focus_callback = self._onparamRangeEnter) 379 text_enter_callback = self._onparamRangeEnter) 379 380 380 381 self.sizer4_4.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 382 383 383 384 ix = 5 384 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,385 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 385 386 kill_focus_callback = self._onparamRangeEnter, 386 text_enter_callback = self._onparamRangeEnter, 387 set_focus_callback = self._onparamRangeEnter) 387 text_enter_callback = self._onparamRangeEnter) 388 388 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 389 389 … … 400 400 ix = 6 401 401 value= self.model.getParam(name2) 402 Tctl = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),402 Tctl = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 403 403 style=wx.TE_PROCESS_ENTER) 404 404 … … 411 411 ix = 7 412 412 value= self.model.getParam(name3) 413 Tct2 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),413 Tct2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 414 414 style=wx.TE_PROCESS_ENTER) 415 415 Tct2.SetValue(str (format_number(value))) … … 452 452 ix = 1 453 453 value= self.model.getParam(name1) 454 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),454 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 455 455 style=wx.TE_PROCESS_ENTER) 456 456 ctl1.SetValue(str (format_number(value))) … … 474 474 475 475 ix = 4 476 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,476 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 477 477 kill_focus_callback = self._onparamRangeEnter, 478 text_enter_callback = self._onparamRangeEnter, 479 set_focus_callback = self._onparamRangeEnter) 478 text_enter_callback = self._onparamRangeEnter) 480 479 481 480 self.sizer4_4.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 484 483 485 484 ix = 5 486 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,485 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 487 486 kill_focus_callback = self._onparamRangeEnter, 488 text_enter_callback = self._onparamRangeEnter, 489 set_focus_callback = self._onparamRangeEnter) 487 text_enter_callback = self._onparamRangeEnter) 490 488 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 491 489 ctl4.Hide() … … 509 507 ix = 6 510 508 value= self.model.getParam(name2) 511 Tctl = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),509 Tctl = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 512 510 style=wx.TE_PROCESS_ENTER) 513 511 … … 526 524 ix = 7 527 525 value= self.model.getParam(name3) 528 Tct2 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),526 Tct2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 529 527 style=wx.TE_PROCESS_ENTER) 530 528 Tct2.SetValue(str (format_number(value))) … … 536 534 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 537 535 ix +=1 538 #self.sizer4_4.Add((20,20), (iy,ix),(1,1), 539 #wx.EXPAND|wx.ADJUST_MINSIZE, 0) 536 540 537 self.fixed_param.append([None,name3, Tct2 541 538 ,None,None, None, None,None]) … … 564 561 ix =0 565 562 iy +=1 566 #self.sizer4_4.Layout() 567 #self.sizer4.Layout() 563 568 564 self.Layout() 569 #self.SetScrollbars(20,20,25,65) 570 #self.Refresh() 571 572 565 566 573 567 def _onFit(self, event): 574 568 """ 575 569 Allow to fit 576 570 """ 577 from sans.guiframe.utils import check_value578 self.select_param(event =None)579 571 #make sure all parameter values are updated. 572 580 573 flag = self._update_paramv_on_fit() #check_value( self.qmin, self.qmax) 581 574 … … 589 582 wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) 590 583 return 584 585 586 self.select_param(event =None) 591 587 592 588 #Clear errors if exist from previous fitting … … 610 606 # self.btFit.SetLabel("Fit") 611 607 # self.btFit.Bind(event= wx.EVT_BUTTON, handler=self._onFit, id=self.btFit.GetId()) 612 self.btFit.SetFocus()608 613 609 614 610 … … 622 618 self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId()) 623 619 self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit,id=self.btFit.GetId()) 624 625 626 #self.btFit.SetFocus() 627 #self.sizer5.Layout() 628 #self.SetScrollbars(20,20,55,40) 620 629 621 630 622 def _on_select_model(self, event): … … 675 667 when enter value on panel redraw model according to changed 676 668 """ 669 flag = False 677 670 tcrtl= event.GetEventObject() 671 678 672 #Clear msg if previously shown. 679 673 msg= "" 680 674 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 681 675 682 676 if check_float(tcrtl): 683 self._onparamEnter_helper()684 temp_smearer = None685 if self.enable_smearer.GetValue():686 temp_smearer= self.smearer687 self.compute_chisqr(smearer= temp_smearer)688 689 ## new state posted690 if self.state_change:691 #self._undo.Enable(True)692 self.save_current_state()693 event = PageInfoEvent(page = self)694 wx.PostEvent(self.parent, event)677 flag = self._onparamEnter_helper() 678 if flag: 679 temp_smearer = None 680 if self.enable_smearer.GetValue(): 681 temp_smearer= self.smearer 682 self.compute_chisqr(smearer= temp_smearer) 683 684 ## new state posted 685 if self.state_change: 686 #self._undo.Enable(True) 687 event = PageInfoEvent(page = self) 688 wx.PostEvent(self.parent, event) 695 689 self.state_change= False 696 690 self.save_current_state() 697 691 else: 692 self.save_current_state() 698 693 msg= "Cannot Plot :Must enter a number!!! " 699 694 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) … … 718 713 self._check_value_enter(self.fittable_param ,is_modified) 719 714 self._check_value_enter(self.parameters ,is_modified) 720 721 715 except: 722 716 tcrtl.SetBackgroundColour("pink") … … 732 726 wx.PostEvent(self.parent, event) 733 727 self.state_change= False 728 self._sleep4sec() 734 729 self.Layout() 735 self.Refresh()730 #self.Refresh() 736 731 737 732 … … 759 754 if item[4]!=None and item[4].IsShown(): 760 755 item[4].Hide() 761 756 762 757 if len(self.fittable_param)>0: 763 758 for item in self.fittable_param: … … 774 769 if item[4]!=None and item[4].IsShown(): 775 770 item[4].Hide() 776 777 771 return 778 772 … … 787 781 self.state.data= data 788 782 self._fill_datainfo_sizer() 789 790 #self.SetScrollbars(20,20,25,65)791 #self.Layout()792 783 793 784 def reset_page(self, state,first=False): … … 802 793 if self.engine_type != None: 803 794 self.manager._on_change_engine(engine=self.engine_type) 804 #self.tcChi.SetLabel(str(format_number(self.tcChi.GetLabel()))) 805 # reset param_toFit 795 806 796 self.select_param(event = None) 807 797 #Save state_fit 808 798 self.save_current_state_fit() 809 self. Layout()799 self._lay_out() 810 800 self.Refresh() 811 801 … … 815 805 """ 816 806 return float(self.qmin_x) , float(self.qmax_x) 807 808 def get_npts2fit(self): 809 """ 810 return numbers of data points within qrange 811 Note: This is for Park where chi2 is not normalized by Npts of fit 812 """ 813 npts2fit = 0 814 qmin,qmax = self.get_range() 815 if self.data.__class__.__name__ =="Data2D": 816 for qx in self.data.x_bins: 817 for qy in self.data.y_bins: 818 if math.sqrt((qx*qx)+(qy*qy)) >= qmin \ 819 and math.sqrt((qx*qx)+(qy*qy)) <= qmax: 820 npts2fit += 1 821 else: 822 for qx in self.data.x: 823 if qx >= qmin and qx <= qmax: 824 npts2fit += 1 825 return npts2fit 826 817 827 818 828 def get_chi2(self): … … 848 858 is_modified = False 849 859 has_error = False 860 861 #Hide textctrl boxes of errors. 850 862 self._clear_Err_on_Fit() 863 864 #Check if chi2 is finite 865 if chisqr != None or numpy.isfinite(chisqr): 851 866 #format chi2 852 chi2 = format_number(chisqr) 853 self.tcChi.SetLabel(chi2) 867 npt_fit = float(self.get_npts2fit()) 868 if self.engine_type == "park" and npt_fit > 0: 869 chisqr =chisqr/npt_fit 870 chi2 = format_number(chisqr) 871 self.tcChi.SetLabel(chi2) 872 self.tcChi.Refresh() 873 else: 874 self.tcChi.SetLabel("-") 854 875 855 876 #Hide error title … … 860 881 n = self.disp_box.GetCurrentSelection() 861 882 dispersity= self.disp_box.GetClientData(n) 862 name= dispersity.__name__ 863 if name == "GaussianDispersion": 864 if hasattr(self,"text_disp_1" ): 865 if self.text_disp_1 !=None: 866 self.text_disp_1.Hide() 883 if dispersity !=None and self.enable_disp.GetValue(): 884 name= dispersity.__name__ 885 if name == "GaussianDispersion": 886 if hasattr(self,"text_disp_1" ): 887 if self.text_disp_1 !=None: 888 self.text_disp_1.Hide() 867 889 except: 890 dispersty = None 868 891 pass 869 892 #set the panel when fit result are float not list 870 871 893 if out.__class__== numpy.float64: 872 894 self.param_toFit[0][2].SetValue(format_number(out)) … … 877 899 self.text2_3.Show(True) 878 900 try: 879 name= dispersity.__name__ 880 if name == "GaussianDispersion": 881 if hasattr(self,"text_disp_1" ): 882 if self.text_disp_1 !=None: 883 self.text_disp_1.Show(True) 901 if dispersity !=None: 902 name= dispersity.__name__ 903 if name == "GaussianDispersion" and self.enable_disp.GetValue(): 904 if hasattr(self,"text_disp_1" ): 905 if self.text_disp_1 !=None: 906 self.text_disp_1.Show(True) 884 907 except: 885 908 pass … … 888 911 if self.param_toFit[0][3].IsShown: 889 912 self.param_toFit[0][3].Hide() 890 else: 891 892 self.param_toFit[0][3].Show(True) 893 self.param_toFit[0][3].Refresh() 913 else: 914 self.param_toFit[0][3].Show(True) 894 915 self.param_toFit[0][4].Show(True) 895 916 self.param_toFit[0][4].SetValue(format_number(cov[0])) 896 self.param_toFit[0][4].Refresh()897 917 has_error = True 898 918 else: … … 900 920 i = 0 901 921 #Set the panel when fit result are list 902 for item in self.param_toFit: 922 for item in self.param_toFit: 903 923 if len(item)>5 and item != None: 904 924 ## reset error value to initial state 905 if item[3].IsShown(): 906 item[3].Hide() 907 if item[4].IsShown(): 908 item[4].Hide() 909 910 if len(out)<=len(self.param_toFit):# and i < len(out): 911 val_out = format_number(self.model.getParam(item[1])) 912 if item[2] != val_out: 913 item[2].SetValue(val_out) 914 925 item[3].Hide() 926 item[4].Hide() 927 915 928 for ind in range(len(out)): 916 929 917 930 if item[1] == p_name[ind]: 918 931 break 919 920 if(cov !=None) and len(cov)<=len(self.param_toFit): 932 if len(out)<=len(self.param_toFit) and out[ind] !=None: 933 val_out = format_number(out[ind]) 934 item[2].SetValue(val_out) 935 936 if(cov !=None): 921 937 922 938 try: 923 name= dispersity.__name__ 924 if name == "GaussianDispersion": 925 if hasattr(self,"text_disp_1" ): 926 if self.text_disp_1!=None: 927 self.text_disp_1.Show(True) 939 if dispersity !=None: 940 name= dispersity.__name__ 941 if name == "GaussianDispersion" and self.enable_disp.GetValue(): 942 if hasattr(self,"text_disp_1" ): 943 if self.text_disp_1!=None: 944 if not self.text_disp_1.IsShown(): 945 self.text_disp_1.Show(True) 928 946 except: 929 947 pass 930 948 931 if cov[ind]!=None and numpy.isfinite(cov[ind]): 932 val_err = format_number(cov[ind]) 933 item[3].Show(True) 934 item[4].Show(True) 935 if val_err != item[4].GetValue(): 936 item[4].SetValue(format_number(cov[ind])) 937 has_error = True 949 if cov[ind]!=None : 950 if numpy.isfinite(float(cov[ind])): 951 val_err = format_number(cov[ind]) 952 item[3].Show(True) 953 item[4].Show(True) 954 item[4].SetValue(val_err) 955 956 has_error = True 938 957 i += 1 939 958 #Show error title when any errors displayed … … 941 960 if not self.text2_3.IsShown(): 942 961 self.text2_3.Show(True) 943 try: 944 ## save current state 945 self.save_current_state() 946 self.Layout() 947 self.Refresh() 948 except: 949 raise 950 self.btFit.SetFocus() 951 962 963 ## save current state 964 self.save_current_state() 965 #plot model 966 self._draw_model() 967 self._lay_out() 968 #PostStatusEvent 969 msg="Fit completed! " 970 wx.PostEvent(self.manager.parent, StatusEvent(status=msg)) 971 952 972 953 973 def onSmear(self, event): … … 995 1015 996 1016 self.sizer5.Layout() 997 self.sizer5.Refresh()998 1017 self.state.tcChi =self.tcChi 999 1018 … … 1006 1025 Compute chisqr for 1D 1007 1026 """ 1008 from sans.guiframe.utils import check_value1009 flag = check_value( self.qmin, self.qmax)1010 1011 if not flag:1012 return1013 1014 1027 try: 1015 1028 self.qmin_x = float(self.qmin.GetValue()) … … 1043 1056 to the tcChi txtcrl 1044 1057 """ 1045 from sans.guiframe.utils import check_value1046 flag = check_value( self.qmin, self.qmax)1047 if not flag:1048 return1049 1050 1058 try: 1051 1059 self.qmin_x = float(self.qmin.GetValue()) … … 1076 1084 to the tcChi txtcrl 1077 1085 """ 1078 from sans.guiframe.utils import check_value1079 1086 flag = check_value( self.qmin, self.qmax) 1080 1087 if flag== True: … … 1281 1288 ix += 1 1282 1289 value= self.model.getParam(item) 1283 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),1290 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 1284 1291 style=wx.TE_PROCESS_ENTER) 1285 1292 … … 1298 1305 1299 1306 ix += 1 1300 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,1307 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1301 1308 kill_focus_callback = self._onparamRangeEnter, 1302 text_enter_callback = self._onparamRangeEnter, 1303 set_focus_callback = self._onparamRangeEnter) 1309 text_enter_callback = self._onparamRangeEnter) 1304 1310 1305 1311 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 1307 1313 1308 1314 ix += 1 1309 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,1315 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1310 1316 kill_focus_callback = self._onparamRangeEnter, 1311 text_enter_callback = self._onparamRangeEnter, 1312 set_focus_callback = self._onparamRangeEnter) 1317 text_enter_callback = self._onparamRangeEnter) 1313 1318 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1314 1319 … … 1320 1325 ix +=1 1321 1326 # Units 1322 try:1327 if self.model.details.has_key(item): 1323 1328 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 1324 e xcept:1329 else: 1325 1330 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 1326 1331 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 1376 1381 ix += 1 1377 1382 value= self.model.getParam(item) 1378 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),1383 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 1379 1384 style=wx.TE_PROCESS_ENTER) 1380 1385 … … 1399 1404 1400 1405 ix += 1 1401 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,1406 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1402 1407 kill_focus_callback = self._onparamRangeEnter, 1403 text_enter_callback = self._onparamRangeEnter, 1404 set_focus_callback = self._onparamRangeEnter) 1408 text_enter_callback = self._onparamRangeEnter) 1405 1409 1406 1410 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 1413 1417 1414 1418 ix += 1 1415 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,1419 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1416 1420 kill_focus_callback = self._onparamRangeEnter, 1417 text_enter_callback = self._onparamRangeEnter, 1418 set_focus_callback = self._onparamRangeEnter) 1421 text_enter_callback = self._onparamRangeEnter) 1419 1422 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1420 1423 … … 1427 1430 ix +=1 1428 1431 # Units 1429 try:1432 if self.model.details.has_key(item): 1430 1433 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 1431 e xcept:1434 else: 1432 1435 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 1433 1436 if self.data.__class__.__name__ =="Data2D": … … 1438 1441 1439 1442 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1440 1441 1443 1442 1444 ##[cb state, name, value, "+/-", error of fit, min, max , units] 1443 1445 self.parameters.append([cb,item, ctl1, … … 1447 1449 1448 1450 iy+=1 1449 #sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)1450 1451 1451 1452 #Display units text on panel 1452 1453 for item in keys: 1453 if self.model.details [item][0]!='':1454 if self.model.details.has_key(item): 1454 1455 self.text2_4.Show() 1455 break 1456 else: 1457 self.text2_4.Hide() 1456 1458 1457 #self.state.cb1 = self.cb1.GetValue() 1459 1458 #self._copy_parameters_state(self.orientation_params, -
sansview/perspectives/fitting/fitting.py
redd166b r7975f2b 477 477 ## If a thread is already started, stop it 478 478 if self.calc_fit!= None and self.calc_fit.isrunning(): 479 return 479 480 self.calc_fit.stop() 480 481 481 482 wx.PostEvent(self.parent, StatusEvent(status="Start the computation", 482 483 curr_thread=self.calc_fit,type="start")) 484 time.sleep(0.5) 483 485 wx.PostEvent(self.parent, StatusEvent(status="Computing...", 484 486 curr_thread=self.calc_fit,type="progress")) 487 time.sleep(0.5) 485 488 ## perform single fit 486 489 if self._fit_engine=="scipy": 487 qmin, qmax= self.current_pg.get_range()490 #qmin, qmax= self.current_pg.get_range() 488 491 self.calc_fit=FitThread(parent =self.parent, 489 492 fn= self.fitter, … … 745 748 @param qmax: the maximum value of x to replot model 746 749 747 """ 748 wx.PostEvent(self.parent, StatusEvent(status="Single fit \ 749 complete! " )) 750 750 """ 751 751 try: 752 752 if result ==None: … … 766 766 for name in pars: 767 767 param_name.append(name) 768 if result.pvec.__class__==numpy.float64: 769 model.setParam(name,result.pvec) 770 else: 771 if result.pvec[i] != None and numpy.isfinite(result.pvec[i]): 772 model.setParam(name,result.pvec[i]) 773 i += 1 774 ## Reset values of the current page to fit result 768 775 769 cpage.onsetValues(result.fitness,param_name, result.pvec,result.stderr) 770 """ 776 771 ## plot the current model with new param 777 772 metadata = self.page_finder[cpage].get_fit_data() … … 784 779 self.draw_model( model=model, data= metadata, smearer= smearer, 785 780 qmin= qmin, qmax= qmax) 786 wx.PostEvent(self.parent, StatusEvent(status=" " , type="stop"))781 """ 787 782 except: 788 783 msg= "Single Fit completed but Following error occurred:%s"% sys.exc_value … … 798 793 @param elapsed: computation time 799 794 """ 800 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous fit complete "))801 802 795 ## fit more than 1 model at the same time 803 796 try: … … 816 809 if format_number(result.fitness) == page.get_chi2(): 817 810 #ToDo: Compare parameter inputs with outputs too. 818 msg= "Simultaneous Fit completed"819 msg +=" but chi2 has not been improved..."820 811 wx.PostEvent(self.parent, StatusEvent(status="%s " % msg)) 821 812 break … … 833 824 if model.name == model_name: 834 825 p_name= model.name+"."+param_name 835 if p.name == p_name: 836 small_out.append(p.value ) 826 if p.name == p_name: 837 827 if p.value != None and numpy.isfinite(p.value): 838 model.setParam(param_name,p.value) 839 small_param_name.append(param_name) 840 small_cov.append(p.stderr) 841 else: 842 value= model.getParam(param_name) 843 small_out.append(value ) 844 small_param_name.append(param_name) 845 small_cov.append(None) 828 small_out.append(p.value ) 829 small_param_name.append(param_name) 830 small_cov.append(p.stderr) 831 846 832 # Display result on each page 847 833 page.onsetValues(result.fitness, small_param_name,small_out,small_cov) 848 #Replot models849 msg= "Simultaneous Fit completed. plotting... %s:"%model.name850 wx.PostEvent(self.parent, StatusEvent(status="%s " % msg))851 qmin, qmax= page.get_range()852 smearer =self.page_finder[page].get_smearer()853 self.draw_model( model=model, data= metadata, smearer=smearer,854 qmin= qmin, qmax= qmax)855 wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop"))856 834 except: 857 835 msg= "Simultaneous Fit completed" -
sansview/perspectives/fitting/modelpage.py
rc99a6c5 r7975f2b 90 90 91 91 sizer_npts= wx.GridSizer(1, 1,5, 5) 92 self.npts = BasicPage.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)92 self.npts = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 93 93 self.npts.SetValue(format_number(self.num_points)) 94 94 self.npts.SetToolTipString("Number of point to plot.") … … 186 186 ix = 1 187 187 value= self.model.getParam(name1) 188 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),188 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 189 189 style=wx.TE_PROCESS_ENTER) 190 190 ctl1.SetValue(str (format_number(value))) … … 195 195 ix =2 196 196 value= self.model.getParam(name2) 197 Tctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),197 Tctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 198 198 style=wx.TE_PROCESS_ENTER) 199 199 Tctl1.SetValue(str (format_number(value))) … … 205 205 ix =3 206 206 value= self.model.getParam(name3) 207 Tctl2 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),207 Tctl2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 208 208 style=wx.TE_PROCESS_ENTER) 209 209 Tctl2.SetValue(str (format_number(value))) … … 234 234 ix = 1 235 235 value= self.model.getParam(name1) 236 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),236 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 237 237 style=wx.TE_PROCESS_ENTER) 238 238 ctl1.SetValue(str (format_number(value))) … … 251 251 ix =2 252 252 value= self.model.getParam(name2) 253 Tctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),253 Tctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 254 254 style=wx.TE_PROCESS_ENTER) 255 255 Tctl1.SetValue(str (format_number(value))) … … 269 269 ix =3 270 270 value= self.model.getParam(name3) 271 Tctl2 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20),271 Tctl2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 272 272 style=wx.TE_PROCESS_ENTER) 273 273 Tctl2.SetValue(str (format_number(value))) … … 412 412 413 413 self.model_description = wx.Button(self,-1, label="Details", size=(80,23)) 414 414 415 self.model_description.Bind(wx.EVT_BUTTON,self.on_button_clicked) 415 416 self.model_description.SetToolTipString("Click Model Functions in HelpWindow...") 416 417 self.model_description.SetFocus() 417 418 sizer_selection.Add( self.description_show ) 418 419 sizer_selection.Add( (20,20)) … … 528 529 ix += 1 529 530 value= self.model.getParam(item) 530 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),531 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 531 532 style=wx.TE_PROCESS_ENTER) 532 533 … … 536 537 ix +=1 537 538 # Units 538 try:539 if self.model.details.has_key(item): 539 540 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 540 e xcept:541 else: 541 542 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 542 543 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 574 575 ix += 1 575 576 value= self.model.getParam(item) 576 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20),577 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 577 578 style=wx.TE_PROCESS_ENTER) 578 579 … … 588 589 ix +=1 589 590 # Units 590 try:591 if self.model.details.has_key(item): 591 592 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 592 e xcept:593 else: 593 594 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 594 595 if not self.enable2D: 595 596 units.Hide() 596 #units.Disable()597 597 else: 598 598 units.Show(True) 599 #units.Enable()600 599 601 600 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 611 610 612 611 iy+=1 613 #sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)614 612 615 613 #Display units text on panel 616 614 for item in keys: 617 if self.model.details[item][0]!='': 618 self.text2_4.Show() 619 break 620 else: 621 self.text2_4.Hide() 615 self.text2_4.Show() 616 622 617 623 618 boxsizer1.Add(sizer)
Note: See TracChangeset
for help on using the changeset viewer.