Changeset 6f2c919 in sasview for sansview/perspectives/fitting/basepage.py
- 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
- File:
-
- 1 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)
Note: See TracChangeset
for help on using the changeset viewer.