-
Notifications
You must be signed in to change notification settings - Fork 1
/
enable_canvas.enaml
35 lines (26 loc) · 1.02 KB
/
enable_canvas.enaml
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
from atom.api import Typed, observe, set_default
from enable.api import Window, Component
from enaml.widgets.api import RawWidget
from enaml.core.declarative import d_
class EnableCanvas(RawWidget):
""" A widget that displays an enable component
"""
#: The enable component to be displayed
component = d_(Typed(Component))
#: Internal storage for the enable window
_window = Typed(Window)
#: Enable canvas' expand freely in width and height by default
hug_width = set_default('ignore')
hug_height = set_default('ignore')
def create_widget(self, parent):
if self.component is not None:
self._window = Window(parent, component=self.component,
bgcolor=self.component.bgcolor)
enable_widget = self._window.control
else:
self._window = None
enable_widget = None
return enable_widget
@observe('component')
def component_changed(self, new):
self._window.component = new['value']