Changes in src/sas/perspectives/fitting/basepage.py [373d4ee:acf8e4a5] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/basepage.py
r373d4ee racf8e4a5 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 initialization 405 406 :param kill_focus_callback: callback method for EVT_KILL_FOCUS event 407 :param set_focus_callback: callback method for EVT_SET_FOCUS event 408 :param mouse_up_callback: callback method for EVT_LEFT_UP event 409 :param text_enter_callback: callback method for EVT_TEXT_ENTER event 410 411 """ 412 ## Set to True when the mouse is clicked while whole string is selected 413 full_selection = False 414 ## Call back for EVT_SET_FOCUS events 415 _on_set_focus_callback = None 416 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 events 433 self._on_set_focus_callback = parent.onSetFocus \ 434 if set_focus_callback is None else set_focus_callback 435 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 whole 447 text if necessary 448 449 :param event: mouse event 450 451 """ 452 event.Skip() 453 self.full_selection = True 454 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 selected 459 460 :param event: mouse event 461 462 """ 463 # Make sure the mouse event is available to other listeners 464 event.Skip() 465 control = event.GetEventObject() 466 if self.full_selection: 467 self.full_selection = False 468 # Check that we have a TextCtrl 469 if issubclass(control.__class__, wx.TextCtrl): 470 # Check whether text has been selected, 471 # if not, select the whole string 472 (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 page 479 """ 480 481 event.Skip() 482 #pass 483 400 484 def set_page_info(self, page_info): 401 485 """ … … 1596 1680 draw=False) 1597 1681 elif not self._is_2D(): 1598 enable_smearer = not self.disable_smearer.GetValue()1599 1682 self._manager.set_smearer(smearer=temp_smearer, 1600 1683 qmin=float(self.qmin_x), … … 1602 1685 fid=self.data.id, 1603 1686 qmax=float(self.qmax_x), 1604 enable_smearer=enable_smearer,1605 draw=False)1687 enable_smearer=not self.disable_smearer.GetValue(), 1688 draw=False) 1606 1689 if self.data != None: 1607 1690 index_data = ((self.qmin_x <= self.data.x) & \ … … 3691 3774 toggle view of model from 1D to 2D or 2D from 1D if implemented 3692 3775 """ 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 initialization3699 3700 :param kill_focus_callback: callback method for EVT_KILL_FOCUS event3701 :param set_focus_callback: callback method for EVT_SET_FOCUS event3702 :param mouse_up_callback: callback method for EVT_LEFT_UP event3703 :param text_enter_callback: callback method for EVT_TEXT_ENTER event3704 3705 """3706 ## Set to True when the mouse is clicked while whole string is selected3707 full_selection = False3708 ## Call back for EVT_SET_FOCUS events3709 _on_set_focus_callback = None3710 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 events3727 self._on_set_focus_callback = parent.onSetFocus \3728 if set_focus_callback is None else set_focus_callback3729 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 whole3741 text if necessary3742 3743 :param event: mouse event3744 3745 """3746 event.Skip()3747 self.full_selection = True3748 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 selected3753 3754 :param event: mouse event3755 3756 """3757 # Make sure the mouse event is available to other listeners3758 event.Skip()3759 control = event.GetEventObject()3760 if self.full_selection:3761 self.full_selection = False3762 # Check that we have a TextCtrl3763 if issubclass(control.__class__, wx.TextCtrl):3764 # Check whether text has been selected,3765 # if not, select the whole string3766 (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 page3773 """3774 3775 event.Skip()3776 #pass3777
Note: See TracChangeset
for help on using the changeset viewer.