source: sasview/invariantview/perspectives/invariant/invariant_widgets.py @ c91c29e

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since c91c29e was 4a2b054, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on pylint

  • Property mode set to 100644
File size: 2.9 KB
Line 
1
2
3
4################################################################################
5#This software was developed by the University of Tennessee as part of the
6#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
7#project funded by the US National Science Foundation.
8#
9#See the license text in license.txt
10#
11#copyright 2009, University of Tennessee
12################################################################################
13
14
15import wx
16#import os
17#from invariant_state import InvariantState as IState
18#import copy
19
20class InvTextCtrl(wx.TextCtrl):
21    """
22    Text control for model and fit parameters.
23    Binds the appropriate events for user interactions.
24    """
25    def __init__(self, *args, **kwds):
26        wx.TextCtrl.__init__(self, *args, **kwds)
27        ## Set to True when the mouse is clicked while
28        #the whole string is selected
29        self.full_selection = False
30        ## Call back for EVT_SET_FOCUS events
31        _on_set_focus_callback = None
32
33        # Bind appropriate events
34        self.Bind(wx.EVT_LEFT_UP, self._highlight_text)
35        self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus)
36       
37    def _on_set_focus(self, event):
38        """
39        Catch when the text control is set in focus to highlight the whole
40        text if necessary
41       
42        :param event: mouse event
43        """
44        event.Skip()
45        self.full_selection = True
46       
47    def _highlight_text(self, event):
48        """
49        Highlight text of a TextCtrl only of no text has be selected
50       
51        :param event: mouse event
52        """
53        # Make sure the mouse event is available to other listeners
54        event.Skip()
55        control  = event.GetEventObject()
56        if self.full_selection:
57            self.full_selection = False
58            # Check that we have a TextCtrl
59            if issubclass(control.__class__, wx.TextCtrl):
60                # Check whether text has been selected,
61                # if not, select the whole string
62                (start, end) = control.GetSelection()
63                if start == end:
64                    control.SetSelection(-1, -1)
65           
66
67class OutputTextCtrl(wx.TextCtrl):
68    """
69    Text control used to display outputs.
70    No editing allowed. The background is
71    grayed out. User can't select text.
72    """
73    def __init__(self, *args, **kwds):
74        wx.TextCtrl.__init__(self, *args, **kwds)
75        self.SetEditable(False)
76        self.SetBackgroundColour(self.GetParent().GetBackgroundColour())
77       
78        # Bind to mouse event to avoid text highlighting
79        # The event will be skipped once the call-back
80        # is called.
81       
82        self.Bind(wx.EVT_MOUSE_EVENTS, self._click)
83
84       
85    def _click(self, event):
86        """
87        Prevent further handling of the mouse event
88        by not calling Skip().
89        """ 
90        pass
91   
92   
93
94 
Note: See TracBrowser for help on using the repository browser.