source: sasview/invariantview/perspectives/invariant/invariant_widgets.py @ 1dcb8a5

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 1dcb8a5 was 6546e4b, checked in by Gervaise Alina <gervyh@…>, 15 years ago

remove the name of the author

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