Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrite _create_component instead of _create_window to avoid Error in examples #508

Merged
merged 2 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions enable/examples/demo/enable/shapes/run.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
"""
**WARNING**

This demo might not work as expected and some documented features might be
missing.

-------------------------------------------------------------------------------

An example showing moveable shapes.
"""
# Issue related to the demo warning: enthought/enable#500

# Enthought library imports.
from enable.api import Container, Window
from enable.api import Container
from enable.example_support import DemoFrame, demo_main

# Local imports
Expand All @@ -25,14 +17,13 @@ class MyFrame(DemoFrame):
# 'DemoFrame' interface.
#--------------------------------------------------------------------------

def _create_window(self):
""" Create an enable window. """
def _create_component(self):

container = Container(
auto_size=False, bgcolor='black', *self._create_shapes()
)

return Window(self, component=container)
return container

# Private interface.
#--------------------------------------------------------------------------
Expand Down
15 changes: 3 additions & 12 deletions enable/examples/demo/enable/tools/button_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@
# LICENSE.txt
#
"""
**WARNING**

This demo might not work as expected and some documented features might be
missing.

-------------------------------------------------------------------------------

Button Tool
===========
"""
# Issue related to the demo warning: enthought/enable#500

from traits.api import Bool
from kiva.constants import FILL, STROKE

from enable.api import Container, Window, transparent_color
from enable.api import Container, transparent_color
from enable.colors import ColorTrait
from enable.example_support import DemoFrame, demo_main
from enable.primitives.api import Box
Expand Down Expand Up @@ -81,7 +73,7 @@ def button_clicked(self):
# DemoApplication interface
#-------------------------------------------------------------------------

def _create_window(self):
def _create_component(self):
# create a box that changes color when clicked
push_button_box = SelectableBox(bounds=[100,50], position=[50, 50], color='red')

Expand All @@ -108,8 +100,7 @@ def _create_window(self):
container.add(push_button_box)
container.add(toggle_box)

window = Window(self, -1, component=container)
return window
return container


if __name__ == "__main__":
Expand Down
16 changes: 5 additions & 11 deletions enable/examples/demo/enable/tools/drop_tool.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
"""
**WARNING**

This demo might not work as expected and some documented features might be
missing.

-------------------------------------------------------------------------------

This demonstrates the use of the drop tool.
"""
# Issue related to the demo warning: enthought/enable#500

from enable.example_support import DemoFrame, demo_main
from enable.api import Component, Container, Label, Window
from enable.api import Component, Container, Label
from enable.tools.base_drop_tool import BaseDropTool

class Box(Component):
Expand Down Expand Up @@ -45,13 +37,15 @@ def handle_drop(self, location, objs):

class MyFrame(DemoFrame):

def _create_window(self):
def _create_component(self):
box = Box(bounds=[100.0, 100.0], position=[50.0, 50.0])
container = Container(bounds=[500,500])
container.add(box)
drop_tool = TextDropTool(component=container)
container.tools.append(drop_tool)
return Window(self, -1, component=container)

return container


if __name__ == "__main__":
demo_main(MyFrame)