Changeset 6f2c919 in sasview for sansview/perspectives
- Timestamp:
- Jul 25, 2009 6:58:31 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:
- 812b901
- Parents:
- e2da832
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r646c97a r6f2c919 116 116 self.set_layout() 117 117 118 class ModelTextCtrl(wx.TextCtrl): 119 """ 120 Text control for model and fit parameters. 121 Binds the appropriate events for user interactions. 122 Default callback methods can be overwritten on initialization 123 124 @param kill_focus_callback: callback method for EVT_KILL_FOCUS event 125 @param set_focus_callback: callback method for EVT_SET_FOCUS event 126 @param mouse_up_callback: callback method for EVT_LEFT_UP event 127 @param text_enter_callback: callback method for EVT_TEXT_ENTER event 128 """ 129 def __init__(self, parent, id=-1, value=wx.EmptyString, pos=wx.DefaultPosition, 130 size=wx.DefaultSize, style=0, validator=wx.DefaultValidator, name=wx.TextCtrlNameStr, 131 kill_focus_callback = None, set_focus_callback = None, 132 mouse_up_callback = None, text_enter_callback = None): 133 134 wx.TextCtrl.__init__(self, parent, id, value, pos, size, style, validator, name) 135 136 # Bind appropriate events 137 self.Bind(wx.EVT_SET_FOCUS, parent.onSetFocus \ 138 if set_focus_callback is None else set_focus_callback) 139 self.Bind(wx.EVT_KILL_FOCUS, parent._onparamEnter \ 140 if kill_focus_callback is None else kill_focus_callback) 141 self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter \ 142 if text_enter_callback is None else text_enter_callback) 143 self.Bind(wx.EVT_LEFT_UP, parent._highlight_text \ 144 if mouse_up_callback is None else mouse_up_callback) 118 145 119 146 def onContextMenu(self, event): … … 455 482 item[4].Hide() 456 483 self.Layout() 457 # Get a handle to the TextCtrl458 widget = evt.GetEventObject()459 # Select the whole control, after this event resolves460 wx.CallAfter(widget.SetSelection, -1,-1)461 484 return 462 485 486 def _highlight_text(self, event): 487 """ 488 Highlight text of a TextCtrl only of no text has be selected 489 @param event: mouse event 490 """ 491 control = event.GetEventObject() 492 # Check that we have a TextCtrl 493 if issubclass(control.__class__, wx.TextCtrl): 494 # Check whether text has been selected, 495 # if not, select the whole string 496 497 (start, end) = control.GetSelection() 498 if start==end: 499 control.SetSelection(-1,-1) 500 501 # Make sure the mouse event is available to other listeners 502 event.Skip() 463 503 464 504 def read_file(self, path): … … 1491 1531 def _set_range_sizer(self, title, object1=None,object=None): 1492 1532 """ 1493 Fill the 1533 TODO: object1 and object are NOT proper parameter names. 1534 Please clean up your code. 1494 1535 """ 1495 1536 self.sizer5.Clear(True) … … 1497 1538 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 1498 1539 #-------------------------------------------------------------- 1499 self.qmin = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20))1540 self.qmin = BasicPage.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20)) 1500 1541 self.qmin.SetValue(str(self.qmin_x)) 1501 1542 self.qmin.SetToolTipString("Minimun value of Q in linear scale.") 1502 self.qmin.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)1503 self.qmin.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)1504 self.qmin.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)1505 1543 1506 self.qmax = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20))1544 self.qmax = BasicPage.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20)) 1507 1545 self.qmax.SetValue(str(self.qmax_x)) 1508 1546 self.qmax.SetToolTipString("Maximum value of Q in linear scale.") 1509 self.qmax.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)1510 self.qmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)1511 self.qmax.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)1512 1547 1513 1548 sizer_horizontal=wx.BoxSizer(wx.HORIZONTAL) -
sansview/perspectives/fitting/fitpage.py
rba95543 r6f2c919 303 303 ix = 1 304 304 value= self.model.getParam(name1) 305 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20),305 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 306 306 style=wx.TE_PROCESS_ENTER) 307 307 ctl1.SetValue(str (format_number(value))) 308 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)309 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)310 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)311 308 self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) 312 309 ## text to show error sign … … 326 323 ix = 4 327 324 value= self.model.getParam(name2) 328 Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20),325 Tctl = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 329 326 style=wx.TE_PROCESS_ENTER) 330 327 331 328 Tctl.SetValue(str (format_number(value))) 332 Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)333 Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)334 Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)335 329 self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 336 330 wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 340 334 ix = 5 341 335 value= self.model.getParam(name3) 342 Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20),336 Tctl = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 343 337 style=wx.TE_PROCESS_ENTER) 344 338 Tctl.SetValue(str (format_number(value))) 345 Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)346 Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)347 Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)348 339 self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 349 340 wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 378 369 ix = 1 379 370 value= self.model.getParam(name1) 380 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20),371 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 381 372 style=wx.TE_PROCESS_ENTER) 382 373 ctl1.SetValue(str (format_number(value))) … … 385 376 else: 386 377 ctl1.Disable() 387 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)388 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)389 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)390 378 self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) 391 379 ## text to show error sign … … 411 399 ix = 4 412 400 value= self.model.getParam(name2) 413 Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20),401 Tctl = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 414 402 style=wx.TE_PROCESS_ENTER) 415 403 … … 419 407 else: 420 408 Tctl.Disable() 421 Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)422 Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)423 Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)424 409 self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 425 410 wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 431 416 ix = 5 432 417 value= self.model.getParam(name3) 433 Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20),418 Tctl = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 434 419 style=wx.TE_PROCESS_ENTER) 435 420 Tctl.SetValue(str (format_number(value))) … … 438 423 else: 439 424 Tctl.Disable() 440 Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)441 Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)442 Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)443 425 self.sizer4_4.Add(Tctl, (iy,ix),(1,1), 444 426 wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 1082 1064 ix += 1 1083 1065 value= self.model.getParam(item) 1084 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20),1066 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 1085 1067 style=wx.TE_PROCESS_ENTER) 1086 1068 1087 1069 ctl1.SetValue(format_number(value)) 1088 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)1089 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)1090 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)1091 1070 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 1092 1071 ## text to show error sign … … 1104 1083 param_min, param_max= self.model.details[item][1:] 1105 1084 ix += 1 1106 ctl3 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) 1085 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1086 kill_focus_callback = self._onparamRangeEnter, 1087 set_focus_callback = self._onparamRangeEnter) 1107 1088 if param_min ==None: 1108 1089 ctl3.SetValue("") 1109 1090 else: 1110 1091 ctl3.SetValue(str(param_min)) 1111 ctl3.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)1112 ctl3.Bind(wx.EVT_KILL_FOCUS, self._onparamRangeEnter)1113 ctl3.Bind(wx.EVT_TEXT_ENTER,self._onparamRangeEnter)1114 1092 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1115 1093 ctl3.Hide() 1116 1094 1117 1095 ix += 1 1118 ctl4 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) 1119 ctl4.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 1120 ctl4.Bind(wx.EVT_KILL_FOCUS, self._onparamRangeEnter) 1121 ctl4.Bind(wx.EVT_TEXT_ENTER,self._onparamRangeEnter) 1096 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1097 kill_focus_callback = self._onparamRangeEnter, 1098 set_focus_callback = self._onparamRangeEnter) 1122 1099 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1123 1100 if param_max==None: … … 1162 1139 ix += 1 1163 1140 value= self.model.getParam(item) 1164 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20),1141 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 1165 1142 style=wx.TE_PROCESS_ENTER) 1166 1143 … … 1170 1147 else: 1171 1148 ctl1.Disable() 1172 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)1173 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)1174 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)1175 1149 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 1176 1150 ## text to show error sign … … 1191 1165 param_min, param_max= self.model.details[item][1:] 1192 1166 ix += 1 1193 ctl3 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) 1167 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1168 kill_focus_callback = self._onparamRangeEnter, 1169 set_focus_callback = self._onparamRangeEnter) 1194 1170 if param_min ==None: 1195 1171 ctl3.SetValue("") 1196 1172 else: 1197 1173 ctl3.SetValue(str(param_min)) 1198 ctl3.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)1199 ctl3.Bind(wx.EVT_KILL_FOCUS, self._onparamRangeEnter)1200 ctl3.Bind(wx.EVT_TEXT_ENTER,self._onparamRangeEnter)1201 1174 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1202 1175 ctl3.Hide() … … 1206 1179 ctl3.Disable() 1207 1180 ix += 1 1208 ctl4 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) 1209 ctl4.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 1210 ctl4.Bind(wx.EVT_KILL_FOCUS, self._onparamRangeEnter) 1211 ctl4.Bind(wx.EVT_TEXT_ENTER,self._onparamRangeEnter) 1181 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1182 kill_focus_callback = self._onparamRangeEnter, 1183 set_focus_callback = self._onparamRangeEnter) 1212 1184 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1213 1185 if param_max ==None: -
sansview/perspectives/fitting/fitpanel.py
r5612152 r6f2c919 180 180 """ 181 181 selected_page = self.GetPage(self.GetSelection()) 182 ## removing about page183 if selected_page==self.about_page:184 self.about_page=None185 return186 182 ## removing sim_page 187 183 if selected_page == self.sim_page: -
sansview/perspectives/fitting/modelpage.py
re7b1ccf r6f2c919 84 84 sizer_npts= wx.GridSizer(1, 1,5, 5) 85 85 86 self.npts = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20))86 self.npts = BasicPage.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20)) 87 87 self.npts.SetValue(format_number(self.num_points)) 88 88 self.npts.SetToolTipString("Number of point to plot.") 89 self.npts.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)90 self.npts.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)91 self.npts.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)92 89 93 90 sizer_npts.Add(wx.StaticText(self, -1, 'Npts'),1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) … … 173 170 ix = 1 174 171 value= self.model.getParam(name1) 175 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20),172 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 176 173 style=wx.TE_PROCESS_ENTER) 177 174 ctl1.SetValue(str (format_number(value))) 178 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)179 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)180 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)181 175 self.sizer4_4.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 182 176 self.fittable_param.append([None,name1,ctl1,None, … … 185 179 ix =2 186 180 value= self.model.getParam(name2) 187 Tctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20),181 Tctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 188 182 style=wx.TE_PROCESS_ENTER) 189 183 Tctl1.SetValue(str (format_number(value))) 190 Tctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)191 Tctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)192 Tctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)193 184 self.sizer4_4.Add(Tctl1, (iy,ix),(1,1), 194 185 wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 198 189 ix =3 199 190 value= self.model.getParam(name3) 200 Tctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20),191 Tctl2 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 201 192 style=wx.TE_PROCESS_ENTER) 202 193 Tctl2.SetValue(str (format_number(value))) 203 Tctl2.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)204 Tctl2.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)205 Tctl2.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)206 194 self.sizer4_4.Add(Tctl2, (iy,ix),(1,1), 207 195 wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 226 214 ix = 1 227 215 value= self.model.getParam(name1) 228 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20),216 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 229 217 style=wx.TE_PROCESS_ENTER) 230 218 ctl1.SetValue(str (format_number(value))) 231 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)232 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)233 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)234 219 if not self.enable2D: 235 220 ctl1.Disable() … … 244 229 ix =2 245 230 value= self.model.getParam(name2) 246 Tctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20),231 Tctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 247 232 style=wx.TE_PROCESS_ENTER) 248 233 Tctl1.SetValue(str (format_number(value))) 249 Tctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)250 Tctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)251 Tctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)252 234 if not self.enable2D: 253 235 Tctl1.Disable() … … 263 245 ix =3 264 246 value= self.model.getParam(name3) 265 Tctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20),247 Tctl2 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 266 248 style=wx.TE_PROCESS_ENTER) 267 249 Tctl2.SetValue(str (format_number(value))) 268 Tctl2.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)269 Tctl2.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)270 Tctl2.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)271 250 if not self.enable2D: 272 251 Tctl2.Disable() … … 506 485 ix += 1 507 486 value= self.model.getParam(item) 508 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20),487 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 509 488 style=wx.TE_PROCESS_ENTER) 510 489 511 490 ctl1.SetValue(str (format_number(value))) 512 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)513 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)514 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)515 491 516 492 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) … … 537 513 ix += 1 538 514 value= self.model.getParam(item) 539 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20),515 ctl1 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 540 516 style=wx.TE_PROCESS_ENTER) 541 517 … … 545 521 else: 546 522 ctl1.Enable() 547 ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)548 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)549 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)550 523 551 524 sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
Note: See TracChangeset
for help on using the changeset viewer.