Changes in src/sas/perspectives/fitting/basepage.py [acf8e4a5:373d4ee] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/basepage.py
racf8e4a5 r373d4ee 398 398 batch_menu.Enable(self.batch_on and flag) 399 399 400 class ModelTextCtrl(wx.TextCtrl):401 """402 Text control for model and fit parameters.403 Binds the appropriate events for user interactions.404 Default callback methods can be overwritten on initialization405 406 :param kill_focus_callback: callback method for EVT_KILL_FOCUS event407 :param set_focus_callback: callback method for EVT_SET_FOCUS event408 :param mouse_up_callback: callback method for EVT_LEFT_UP event409 :param text_enter_callback: callback method for EVT_TEXT_ENTER event410 411 """412 ## Set to True when the mouse is clicked while whole string is selected413 full_selection = False414 ## Call back for EVT_SET_FOCUS events415 _on_set_focus_callback = None416 417 def __init__(self, parent, id=-1,418 value=wx.EmptyString,419 pos=wx.DefaultPosition,420 size=wx.DefaultSize,421 style=0,422 validator=wx.DefaultValidator,423 name=wx.TextCtrlNameStr,424 kill_focus_callback=None,425 set_focus_callback=None,426 mouse_up_callback=None,427 text_enter_callback=None):428 429 wx.TextCtrl.__init__(self, parent, id, value, pos,430 size, style, validator, name)431 432 # Bind appropriate events433 self._on_set_focus_callback = parent.onSetFocus \434 if set_focus_callback is None else set_focus_callback435 self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus)436 self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus \437 if kill_focus_callback is None else kill_focus_callback)438 self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter \439 if text_enter_callback is None else text_enter_callback)440 if not ON_MAC:441 self.Bind(wx.EVT_LEFT_UP, self._highlight_text \442 if mouse_up_callback is None else mouse_up_callback)443 444 def _on_set_focus(self, event):445 """446 Catch when the text control is set in focus to highlight the whole447 text if necessary448 449 :param event: mouse event450 451 """452 event.Skip()453 self.full_selection = True454 return self._on_set_focus_callback(event)455 456 def _highlight_text(self, event):457 """458 Highlight text of a TextCtrl only of no text has be selected459 460 :param event: mouse event461 462 """463 # Make sure the mouse event is available to other listeners464 event.Skip()465 control = event.GetEventObject()466 if self.full_selection:467 self.full_selection = False468 # Check that we have a TextCtrl469 if issubclass(control.__class__, wx.TextCtrl):470 # Check whether text has been selected,471 # if not, select the whole string472 (start, end) = control.GetSelection()473 if start == end:474 control.SetSelection(-1, -1)475 476 def _silent_kill_focus(self, event):477 """478 Save the state of the page479 """480 481 event.Skip()482 #pass483 484 400 def set_page_info(self, page_info): 485 401 """ … … 1680 1596 draw=False) 1681 1597 elif not self._is_2D(): 1598 enable_smearer = not self.disable_smearer.GetValue() 1682 1599 self._manager.set_smearer(smearer=temp_smearer, 1683 1600 qmin=float(self.qmin_x), … … 1685 1602 fid=self.data.id, 1686 1603 qmax=float(self.qmax_x), 1687 enable_smearer=not self.disable_smearer.GetValue(),1688 1604 enable_smearer=enable_smearer, 1605 draw=False) 1689 1606 if self.data != None: 1690 1607 index_data = ((self.qmin_x <= self.data.x) & \ … … 3774 3691 toggle view of model from 1D to 2D or 2D from 1D if implemented 3775 3692 """ 3693 3694 class ModelTextCtrl(wx.TextCtrl): 3695 """ 3696 Text control for model and fit parameters. 3697 Binds the appropriate events for user interactions. 3698 Default callback methods can be overwritten on initialization 3699 3700 :param kill_focus_callback: callback method for EVT_KILL_FOCUS event 3701 :param set_focus_callback: callback method for EVT_SET_FOCUS event 3702 :param mouse_up_callback: callback method for EVT_LEFT_UP event 3703 :param text_enter_callback: callback method for EVT_TEXT_ENTER event 3704 3705 """ 3706 ## Set to True when the mouse is clicked while whole string is selected 3707 full_selection = False 3708 ## Call back for EVT_SET_FOCUS events 3709 _on_set_focus_callback = None 3710 3711 def __init__(self, parent, id=-1, 3712 value=wx.EmptyString, 3713 pos=wx.DefaultPosition, 3714 size=wx.DefaultSize, 3715 style=0, 3716 validator=wx.DefaultValidator, 3717 name=wx.TextCtrlNameStr, 3718 kill_focus_callback=None, 3719 set_focus_callback=None, 3720 mouse_up_callback=None, 3721 text_enter_callback=None): 3722 3723 wx.TextCtrl.__init__(self, parent, id, value, pos, 3724 size, style, validator, name) 3725 3726 # Bind appropriate events 3727 self._on_set_focus_callback = parent.onSetFocus \ 3728 if set_focus_callback is None else set_focus_callback 3729 self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus) 3730 self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus \ 3731 if kill_focus_callback is None else kill_focus_callback) 3732 self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter \ 3733 if text_enter_callback is None else text_enter_callback) 3734 if not ON_MAC: 3735 self.Bind(wx.EVT_LEFT_UP, self._highlight_text \ 3736 if mouse_up_callback is None else mouse_up_callback) 3737 3738 def _on_set_focus(self, event): 3739 """ 3740 Catch when the text control is set in focus to highlight the whole 3741 text if necessary 3742 3743 :param event: mouse event 3744 3745 """ 3746 event.Skip() 3747 self.full_selection = True 3748 return self._on_set_focus_callback(event) 3749 3750 def _highlight_text(self, event): 3751 """ 3752 Highlight text of a TextCtrl only of no text has be selected 3753 3754 :param event: mouse event 3755 3756 """ 3757 # Make sure the mouse event is available to other listeners 3758 event.Skip() 3759 control = event.GetEventObject() 3760 if self.full_selection: 3761 self.full_selection = False 3762 # Check that we have a TextCtrl 3763 if issubclass(control.__class__, wx.TextCtrl): 3764 # Check whether text has been selected, 3765 # if not, select the whole string 3766 (start, end) = control.GetSelection() 3767 if start == end: 3768 control.SetSelection(-1, -1) 3769 3770 def _silent_kill_focus(self, event): 3771 """ 3772 Save the state of the page 3773 """ 3774 3775 event.Skip() 3776 #pass 3777
Note: See TracChangeset
for help on using the changeset viewer.