File: wx_window.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 (55 lines) | stat: -rw-r--r-- 1,722 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
#------------------------------------------------------------------------------
# Copyright (c) 2008, Riverbank Computing Limited
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in enthought/LICENSE.txt and may be redistributed only
# under the conditions described in the aforementioned license.  The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
# Thanks for using Enthought open source!
#
# Author: Riverbank Computing Limited
# Description: <Enthought permissions package component>
#------------------------------------------------------------------------------


# Major library imports.
import wx

# Enthought library imports.
from apptools.permissions.adapter_base import AdapterBase


class wxWindowAdapter(AdapterBase):
    """This is the adapter for wx Window instances."""

    def adapt(self):
        """Reimplemented to adapt the proxied object."""

        # Replace the real methods.
        self.proxied.Enable = self.update_enabled
        self.proxied.Show = self.update_visible

        return self.proxied

    def get_enabled(self):
        """Get the enabled state of the proxied object."""

        return self.proxied.IsEnabled()

    def set_enabled(self, value):
        """Set the enabled state of the proxied object."""

        wx.Window.Enable(self.proxied, value)

    def get_visible(self):
        """Get the visible state of the proxied object."""

        return self.proxied.IsShown()

    def set_visible(self, value):
        """Set the visible state of the proxied object."""

        wx.Window.Show(self.proxied, value)

AdapterBase.register_adapter(wxWindowAdapter, wx.Window)