diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 02bea5aef..b7114feff 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -16,9 +16,7 @@ jobs: matrix: os: [ubuntu-latest] toolkit: ['pyside2'] - # Dependencies include chaco/enable, whose installation fails - # on Python 3.8 and 3.9 - python-version: [3.6] + python-version: [3.6, 3.8, 3.9] runs-on: ${{ matrix.os }} steps: - name: Check out diff --git a/docs/releases/upcoming/1833.test.rst b/docs/releases/upcoming/1833.test.rst new file mode 100644 index 000000000..0c283d451 --- /dev/null +++ b/docs/releases/upcoming/1833.test.rst @@ -0,0 +1 @@ +Remove tests and examples that depend on Chaco and Enable. \ No newline at end of file diff --git a/ets-demo/etstool.py b/ets-demo/etstool.py index 9b906fe1f..55c0c93c0 100644 --- a/ets-demo/etstool.py +++ b/ets-demo/etstool.py @@ -144,7 +144,6 @@ 'traitsui', # dependencies needed for examples "apptools", - "chaco", "h5py", "numpy", "pandas", diff --git a/integrationtests/ui/table_editor_color_test.py b/integrationtests/ui/table_editor_color_test.py deleted file mode 100644 index 88e4881d2..000000000 --- a/integrationtests/ui/table_editor_color_test.py +++ /dev/null @@ -1,85 +0,0 @@ -# (C) Copyright 2004-2022 Enthought, Inc., Austin, TX -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in 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! - -# ------------------------------------------------------------------------- -# Imports: -# ------------------------------------------------------------------------- - -from traits.api import HasTraits, List - -from traitsui.api import View, Item, TableEditor - -from traitsui.color_column import ColorColumn - -from enable.api import ColorTrait - - -class Thingy(HasTraits): - color = ColorTrait('black') - - -# ------------------------------------------------------------------------- -# Sample data: -# ------------------------------------------------------------------------- - -colors = [ - Thingy(color='red'), - Thingy(color='orange'), - Thingy(color='yellow'), - Thingy(color='green'), - Thingy(color='blue'), - Thingy(color='indigo'), - Thingy(color='violet'), - Thingy(color='black'), - Thingy(color='white'), -] - - -class TableTest(HasTraits): - - # ------------------------------------------------------------------------- - # Trait definitions: - # ------------------------------------------------------------------------- - - colors = List(Thingy) - - table_editor = TableEditor( - columns=[ - ColorColumn(name='color'), - ], - editable=True, - deletable=True, - sortable=True, # - sort_model=True, - show_lines=True, # - orientation='vertical', - show_column_labels=True, # - row_factory=Thingy, - ) - - traits_view = View( - [Item('colors', id='colors', editor=table_editor), '|[]<>'], - title='Table Editor Test', - id='traitsui.tests.table_editor_color_test', - dock='horizontal', - width=0.4, - height=0.3, - resizable=True, - kind='live', - ) - - -# ------------------------------------------------------------------------- -# Run the tests: -# ------------------------------------------------------------------------- - -if __name__ == '__main__': - tt = TableTest(colors=colors) - tt.configure_traits() diff --git a/integrationtests/ui/test_ui2.py b/integrationtests/ui/test_ui2.py deleted file mode 100644 index f44ba978b..000000000 --- a/integrationtests/ui/test_ui2.py +++ /dev/null @@ -1,266 +0,0 @@ -# (C) Copyright 2004-2022 Enthought, Inc., Austin, TX -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in 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! - -# ------------------------------------------------------------------------- -# Imports: -# ------------------------------------------------------------------------- - -import wx - -from kiva.traits.kiva_font_trait import KivaFont - -from enable.traits.api import RGBAColor - -from traits.api import Trait, HasTraits, Str, Int, Range, List, Event, Bool - -from traitsui.api import ( - View, - Handler, - Item, - CheckListEditor, - ButtonEditor, - FileEditor, - DirectoryEditor, - ImageEnumEditor, -) - -# ------------------------------------------------------------------------- -# Constants: -# ------------------------------------------------------------------------- - -origin_values = ['top left', 'top right', 'bottom left', 'bottom right'] - -# ------------------------------------------------------------------------- -# 'PersonHandler' class: -# ------------------------------------------------------------------------- - - -class PersonHandler(Handler): - def object_zip_changed(self, info): - obj = info.object - enabled = obj.zip >= 10000 - info.street.enabled = enabled - info.city.enabled = enabled - info.state.enabled = enabled - if obj.zip == 78664: - obj.street = '901 Morning View Place' - obj.city = 'Round Rock' - obj.state = 'Texas' - - def object_call_changed(self, info): - print('You called?') - - -# ------------------------------------------------------------------------- -# 'WizardHandler' class: -# ------------------------------------------------------------------------- - - -class WizardHandler(Handler): - def object_sex_changed(self, info): - if info.object.sex == 'Female': - info.p1.next = 'p3' - else: - info.p1.next = 'p2' - info.p2.next = None - - def object_name_changed(self, info): - info.p2.enabled = info.p3.enabled = info.object.name != '' - if not info.p2.enabled: - info.p2.msg = info.p3.msg = 'You must enter a valid name.' - - -# ------------------------------------------------------------------------- -# 'Employer' class: -# ------------------------------------------------------------------------- - - -class Employer(HasTraits): - - # ------------------------------------------------------------------------- - # Trait definitions: - # ------------------------------------------------------------------------- - - company = Str() - boss = Str() - - view = View('company', 'boss') - - -# ------------------------------------------------------------------------- -# 'Person' class -# ------------------------------------------------------------------------- - - -class Person(HasTraits): - - # ------------------------------------------------------------------------- - # Trait definitions: - # ------------------------------------------------------------------------- - - name = Str('David Morrill') - age = Int(39) - sex = Trait('Male', 'Female') - coolness = Range(0.0, 10.0, 10.0) - number = Trait( - 1, Range(1, 6), 'one', 'two', 'three', 'four', 'five', 'six' - ) - human = Bool(True) - employer = Trait(Employer(company='Enthought, Inc.', boss='eric')) - eye_color = RGBAColor - set = List( - editor=CheckListEditor(values=['one', 'two', 'three', 'four'], cols=4) - ) - font = KivaFont - street = Str() - city = Str() - state = Str() - zip = Int(78663) - password = Str() - books = List( - Str, ['East of Eden', 'The Grapes of Wrath', 'Of Mice and Men'] - ) - call = Event(0, editor=ButtonEditor(label='Click to call')) - info = Str(editor=FileEditor()) - location = Str(editor=DirectoryEditor()) - origin = Trait( - editor=ImageEnumEditor( - values=origin_values, suffix='_origin', cols=4, klass=Employer - ), - *origin_values, - ) - - nm = Item('name', enabled_when='object.age >= 21') - pw = Item('password', defined_when='object.zip == 78664') - view = View( - ( - ( - nm, - 'age', - 'coolness', - '_', - 'eye_color', - 'eye_color@', - 'eye_color*', - 'eye_color~', - '_', - 'font', - 'font@', - 'font*', - 'font~', - '_', - 'set', - 'set@', - 'set*', - 'set~', - '_', - 'sex', - 'sex@', - 'sex*', - 'sex~', - '_', - 'human', - 'human@', - 'human*', - 'human~', - '_', - 'number', - 'number@', - 'number*', - 'number~', - '_', - 'books', - '_', - 'books@', - '_', - 'books*', - '_', - 'books~', - '_', - 'info', - 'location', - 'origin', - 'origin@', - 'call', - 'employer', - 'employer[]@', - 'employer*', - 'employer~', - pw, - '|<[Person:]', - ), - (' ', 'street', 'city', 'state', 'zip', '|<[Address:]'), - ( - nm, - nm, - nm, - nm, - nm, - nm, - nm, - nm, - nm, - nm, - nm, - nm, - nm, - nm, - '|<[Names:]', - ), - '|', - ), - title='Traits 2 User Interface Test', - handler=PersonHandler(), - buttons=['Apply', 'Revert', 'Undo', 'OK'], - height=0.5, - ) - - wizard = View( - ('|p1:', 'name', 'age', 'sex'), - ('|p2:', 'street', 'city', 'state', 'zip'), - ('|p3:', 'eye_color', 'origin', 'human'), - handler=WizardHandler(), - ) - - -# ------------------------------------------------------------------------- -# 'TraitSheetApp' class: -# ------------------------------------------------------------------------- - - -class TraitSheetApp(wx.App): - - # ------------------------------------------------------------------------- - # Initialize the object: - # ------------------------------------------------------------------------- - - def __init__(self, object): - self.object = object - wx.InitAllImageHandlers() - wx.App.__init__(self, 1, 'debug.log') - self.MainLoop() - object.print_traits() - - # ------------------------------------------------------------------------- - # Handle application initialization: - # ------------------------------------------------------------------------- - - def OnInit(self): - # ui = self.object.edit_traits( 'view', kind = 'live' ) - ui = self.object.edit_traits('wizard', kind='wizard') - self.SetTopWindow(ui.control) - return True - - -# ------------------------------------------------------------------------- -# Main program: -# ------------------------------------------------------------------------- - -TraitSheetApp(Person()) diff --git a/traitsui/__init__.py b/traitsui/__init__.py index 6cd6bdd31..199450a58 100644 --- a/traitsui/__init__.py +++ b/traitsui/__init__.py @@ -30,7 +30,6 @@ "examples": [ # Dependencies for examples "apptools", - "chaco", # for a very simple example, see enthought/traitsui#1139 "h5py", "numpy", "pandas", diff --git a/traitsui/examples/demo/Misc/demo_group_size.py b/traitsui/examples/demo/Misc/demo_group_size.py index e7987190b..038ce238f 100644 --- a/traitsui/examples/demo/Misc/demo_group_size.py +++ b/traitsui/examples/demo/Misc/demo_group_size.py @@ -20,11 +20,9 @@ We separate the left and right groups by a splitter (HSplit), and also make the window itself resizable. -This demo includes a simple Chaco plot for variety, but it is not a Chaco demo. - """ from numpy import linspace, pi, sin -from traits.api import HasTraits, Instance, Str, Int +from traits.api import Code, HasTraits, Instance, Str, Int # UItem is Unlabeled Item from traitsui.api import ( @@ -36,8 +34,6 @@ VGroup, HGroup, ) -from chaco.api import Plot, AbstractPlotData, ArrayPlotData -from enable.component_editor import ComponentEditor class InstanceUItem(UItem): @@ -47,28 +43,19 @@ class InstanceUItem(UItem): editor = Instance(InstanceEditor, ()) -class PlotView(HasTraits): +class CodeView(HasTraits): """Defines a sub-view whose size we wish to explicitly control.""" n = Int(123) - data = Instance(AbstractPlotData) - plot1 = Instance(Plot) + code = Code() view = View( # This HGroup keeps 'n' from over-widening, by implicitly placing # a spring to the right of the item. HGroup(Item('n')), - UItem('plot1', editor=ComponentEditor()), + UItem('code'), resizable=True, ) - def create_plot(self, data, name, color): - p = Plot(self.data) - p.plot(data, name=name, color=color) - return p - - def _data_changed(self): - self.plot1 = self.create_plot(("x", "y1"), "sin plot", "red") - class VerticalBar(HasTraits): """Defines a sub-view whose size we wish to explicitly control.""" @@ -86,15 +73,15 @@ class VerticalBar(HasTraits): class BigView(HasTraits): """Defines the top-level view. It contains two side-by-side panels (a - vertical bar and a plot under an integer) whose relative sizes we wish - to control explicitly. If these were simply defined as Groups, we could - not control their sizes. But by extracting them as separate classes with - their own views, the resizing becomes possible, because they are loaded - as Items now. + vertical bar and a code editor under an integer) whose relative sizes we + wish to control explicitly. If these were simply defined as Groups, we + could not control their sizes. But by extracting them as separate classes + with their own views, the resizing becomes possible, because they are + loaded as Items now. """ bar = Instance(VerticalBar, ()) - plot = Instance(PlotView) + code = Instance(CodeView) view = View( HSplit( # Specify pixel width of each sub-view. (Or, to specify @@ -102,7 +89,7 @@ class BigView(HasTraits): # We specify the height here for sake of demonstration; # it could also be specified for the top-level view. InstanceUItem('bar', width=150), - InstanceUItem('plot', width=500, height=500), + InstanceUItem('code', width=500, height=500), show_border=True, ), resizable=True, @@ -110,6 +97,6 @@ class BigView(HasTraits): x = linspace(-2 * pi, 2 * pi, 100) -pv = PlotView(data=ArrayPlotData(x=x, y1=sin(x))) -bv = BigView(plot=pv) +pv = CodeView(code=open(__file__).read()) +bv = BigView(code=pv) bv.configure_traits()