source: sasview/invariantview/perspectives/invariant/invariant_widgets.py @ 97dea6c

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 97dea6c was d7a39e5, checked in by Gervaise Alina <gervyh@…>, 15 years ago

working on documentation

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[518d35d]1
2
[d7a39e5]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
[518d35d]15import wx
16import os
17
18class InvTextCtrl(wx.TextCtrl):
19    """
[d7a39e5]20    Text control for model and fit parameters.
21    Binds the appropriate events for user interactions.
[518d35d]22    """
23    def __init__(self, *args, **kwds):
24       
25        wx.TextCtrl.__init__(self, *args, **kwds)
26       
27        ## Set to True when the mouse is clicked while the whole string is selected
28        full_selection = False
29        ## Call back for EVT_SET_FOCUS events
30        _on_set_focus_callback = None
31        # Bind appropriate events
32        self.Bind(wx.EVT_LEFT_UP, self._highlight_text)
33        self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus)
34
35    def _on_set_focus(self, event):
36        """
[d7a39e5]37        Catch when the text control is set in focus to highlight the whole
38        text if necessary
39       
40        :param event: mouse event
41       
[518d35d]42        """
43        event.Skip()
44        self.full_selection = True
45       
46    def _highlight_text(self, event):
47        """
[d7a39e5]48        Highlight text of a TextCtrl only of no text has be selected
49       
50        :param event: mouse event
51       
[518d35d]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
66class OutputTextCtrl(wx.TextCtrl):
67    """
[d7a39e5]68    Text control used to display outputs.
69    No editing allowed. The background is
70    grayed out. User can't select text.
[518d35d]71    """
72    def __init__(self, *args, **kwds):
73        wx.TextCtrl.__init__(self, *args, **kwds)
74        self.SetEditable(False)
75        self.SetBackgroundColour(self.GetParent().GetBackgroundColour())
76       
77        # Bind to mouse event to avoid text highlighting
78        # The event will be skipped once the call-back
79        # is called.
80        self.Bind(wx.EVT_MOUSE_EVENTS, self._click)
81       
82    def _click(self, event):
83        """
[d7a39e5]84        Prevent further handling of the mouse event
85        by not calling Skip().
[518d35d]86        """ 
87        pass
88 
Note: See TracBrowser for help on using the repository browser.