File: enable_editor.py

package info (click to toggle)
python-apptools 4.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,652 kB
  • sloc: python: 16,657; makefile: 77
file content (78 lines) | stat: -rw-r--r-- 2,599 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#-------------------------------------------------------------------------------
#
#  Traits UI editor for displaying Enable Components.
#
#  Written by: David Morrill
#
#  Date: 07/30/2007
#
#  (c) Copyright 2007 by Enthought, Inc.
#
#-------------------------------------------------------------------------------

""" Traits UI editor for displaying Enable Components.
"""

#-------------------------------------------------------------------------------
#  Imports:
#-------------------------------------------------------------------------------

import wx

from traitsui.wx.editor \
    import Editor

from traitsui.wx.basic_editor_factory \
    import BasicEditorFactory

from enable.wx_backend.api \
    import Window

#-------------------------------------------------------------------------------
#  '_EnableEditor' class:
#-------------------------------------------------------------------------------

class _EnableEditor ( Editor ):
    """ Traits UI editor for displaying Enable Components.
    """

    # Override the default value to allow the control to be resizable:
    scrollable = True

    #---------------------------------------------------------------------------
    #  Finishes initializing the editor by creating the underlying toolkit
    #  widget:
    #---------------------------------------------------------------------------

    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self._window = Window( parent, -1,
                               component = self.value,
                               bg_color  = ( 0.698, 0.698, 0.698, 1.0 ) )
        self.control = self._window.control
        self.control.SetSize( wx.Size( 300, 300 ) )

        self.set_tooltip()

    #---------------------------------------------------------------------------
    #  Updates the editor when the object trait changes external to the editor:
    #---------------------------------------------------------------------------

    def update_editor ( self ):
        """ Updates the editor when the object trait changes externally to the
            editor.
        """
        self._window.component = self.value

#-------------------------------------------------------------------------------
#  Create the editor factory object:
#-------------------------------------------------------------------------------

# wxPython editor factory for Enable component editors:
class EnableEditor ( BasicEditorFactory ):

    # The editor class to be created:
    klass = _EnableEditor