diff --git a/examples/demo/Standard_Editors/BooleanEditor_demo.py b/examples/demo/Standard_Editors/BooleanEditor_demo.py index ea1a76df3..8f2eebf6f 100644 --- a/examples/demo/Standard_Editors/BooleanEditor_demo.py +++ b/examples/demo/Standard_Editors/BooleanEditor_demo.py @@ -3,7 +3,7 @@ A Boolean (True/False) trait is displayed and edited as a checkbox, by default. -It can also be displayed as text 'True' / 'False', either editable or read-only. +It can also be displayed as text 'True'/'False', either editable or read-only. This example also shows how to listen for a change in a trait, and take action when its value changes. @@ -60,6 +60,7 @@ def _my_boolean_trait_changed(self): resizable=True ) + # Create the demo view (but do not yet display it): demo = BooleanEditorDemo() diff --git a/examples/demo/Standard_Editors/ButtonEditor_demo.py b/examples/demo/Standard_Editors/ButtonEditor_demo.py index 566c7165d..7455f92a3 100644 --- a/examples/demo/Standard_Editors/ButtonEditor_demo.py +++ b/examples/demo/Standard_Editors/ButtonEditor_demo.py @@ -8,7 +8,8 @@ """ from traits.api import HasTraits, Button, Int -from traitsui.api import View + +from traitsui.api import Item, View class ButtonEditorDemo(HasTraits): @@ -16,7 +17,7 @@ class ButtonEditorDemo(HasTraits): # Define a Button trait: my_button_trait = Button('Click Me') - click_counter = Int() + click_counter = Int(0) # When the button is clicked, do something. # The listener method is named '_TraitName_fired', where @@ -27,12 +28,13 @@ def _my_button_trait_fired(self): # Demo view: traits_view = View( 'my_button_trait', - 'click_counter', + Item('click_counter', style='readonly'), title='ButtonEditor', buttons=['OK'], resizable=True ) + # Create the demo: demo = ButtonEditorDemo() diff --git a/examples/demo/Standard_Editors/CSVListEditor_demo.py b/examples/demo/Standard_Editors/CSVListEditor_demo.py index 891b91a4a..c4f8cc037 100644 --- a/examples/demo/Standard_Editors/CSVListEditor_demo.py +++ b/examples/demo/Standard_Editors/CSVListEditor_demo.py @@ -1,18 +1,30 @@ """ -Demonstrate the CSVListEditor class.
-
+**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + +Demonstrate the CSVListEditor class. + This editor allows the user to enter a *single* line of input text, containing comma-separated values (or another separator may be specified). Your program specifies an element Trait type of Int, Float, Str, Enum, or Range. """ +# Issue related to the demo warning: enthought/traitsui#913 + -from traits.api import HasTraits, List, Int, Float, Enum, Range, Str, Button, \ - Property -from traitsui.api import View, Item, Label, Heading, VGroup, HGroup, UItem, \ - spring, TextEditor, CSVListEditor +from traits.api import ( + HasTraits, List, Int, Float, Enum, Range, Str, Button, Property +) +from traitsui.api import ( + View, Item, Label, Heading, VGroup, HGroup, UItem, spring, TextEditor, + CSVListEditor +) -class Demo(HasTraits): +class CSVListEditorDemo(HasTraits): list1 = List(Int) @@ -39,73 +51,96 @@ class Demo(HasTraits): # This will be str(self.list1). list1str = Property(Str, depends_on='list1') - traits_view = \ - View( - HGroup( - # This VGroup forms the column of CSVListEditor examples. - VGroup( - Item('list1', label="List(Int)", - editor=CSVListEditor(ignore_trailing_sep=False), - tooltip='options: ignore_trailing_sep=False'), - Item('list1', label="List(Int)", style='readonly', - editor=CSVListEditor()), - Item('list2', label="List(Float)", - editor=CSVListEditor(enter_set=True, auto_set=False), - tooltip='options: enter_set=True, auto_set=False'), - Item('list3', label="List(Str, maxlen=3)", - editor=CSVListEditor()), - Item('list4', - label="List(Enum('red', 'green', 'blue', 2, 3))", - editor=CSVListEditor(sep=None), - tooltip='options: sep=None'), - Item('list5', label="List(Range(low=0.0, high=10.0))", - editor=CSVListEditor()), - Item('list6', label="List(Range(low=-1.0, high='high'))", - editor=CSVListEditor()), - Item('list7', label="List(Range(low='low', high='high'))", - editor=CSVListEditor()), - springy=True, + traits_view = View( + HGroup( + # This VGroup forms the column of CSVListEditor examples. + VGroup( + Item( + 'list1', + label="List(Int)", + editor=CSVListEditor(ignore_trailing_sep=False), + tooltip='options: ignore_trailing_sep=False' + ), + Item( + 'list1', + label="List(Int)", + style='readonly', + editor=CSVListEditor() ), - # This VGroup forms the right column; it will display the - # Python str representation of the lists. - VGroup( - UItem('list1str', editor=TextEditor(), - enabled_when='False', width=240), - UItem('list1str', editor=TextEditor(), - enabled_when='False', width=240), - UItem('list2', editor=TextEditor(), - enabled_when='False', width=240), - UItem('list3', editor=TextEditor(), - enabled_when='False', width=240), - UItem('list4', editor=TextEditor(), - enabled_when='False', width=240), - UItem('list5', editor=TextEditor(), - enabled_when='False', width=240), - UItem('list6', editor=TextEditor(), - enabled_when='False', width=240), - UItem('list7', editor=TextEditor(), - enabled_when='False', width=240), + Item( + 'list2', + label="List(Float)", + editor=CSVListEditor(enter_set=True, auto_set=False), + tooltip='options: enter_set=True, auto_set=False' ), + Item( + 'list3', + label="List(Str, maxlen=3)", + editor=CSVListEditor() + ), + Item( + 'list4', + label="List(Enum('red', 'green', 'blue', 2, 3))", + editor=CSVListEditor(sep=None), + tooltip='options: sep=None' + ), + Item( + 'list5', + label="List(Range(low=0.0, high=10.0))", + editor=CSVListEditor() + ), + Item( + 'list6', + label="List(Range(low=-1.0, high='high'))", + editor=CSVListEditor() + ), + Item( + 'list7', + label="List(Range(low='low', high='high'))", + editor=CSVListEditor() + ), + springy=True, + ), + # This VGroup forms the right column; it will display the + # Python str representation of the lists. + VGroup( + UItem('list1str', editor=TextEditor(), + enabled_when='False', width=240), + UItem('list1str', editor=TextEditor(), + enabled_when='False', width=240), + UItem('list2', editor=TextEditor(), + enabled_when='False', width=240), + UItem('list3', editor=TextEditor(), + enabled_when='False', width=240), + UItem('list4', editor=TextEditor(), + enabled_when='False', width=240), + UItem('list5', editor=TextEditor(), + enabled_when='False', width=240), + UItem('list6', editor=TextEditor(), + enabled_when='False', width=240), + UItem('list7', editor=TextEditor(), + enabled_when='False', width=240), ), - '_', - HGroup('low', 'high', spring, UItem('pop1'), UItem('sort1')), - Heading("Notes"), - Label("Hover over a list to see which editor options are set, " - "if any."), - Label("The editor of the first list, List(Int), uses " - "ignore_trailing_sep=False, so a trailing comma is " - "an error."), - Label("The second list is a read-only view of the first list."), - Label("The editor of the List(Float) example has enter_set=True " - "and auto_set=False; press Enter to validate."), - Label("The List(Str) example will accept at most 3 elements."), - Label("The editor of the List(Enum(...)) example uses sep=None, " - "i.e. whitespace acts as a separator."), - Label("The last two List(Range(...)) examples take one or both " - "of their limits from the Low and High fields below."), - width=720, - title="CSVListEditor Demonstration", - ) + ), + '_', + HGroup('low', 'high', spring, UItem('pop1'), UItem('sort1')), + Heading("Notes"), + Label("Hover over a list to see which editor options are set, " + "if any."), + Label("The editor of the first list, List(Int), uses " + "ignore_trailing_sep=False, so a trailing comma is " + "an error."), + Label("The second list is a read-only view of the first list."), + Label("The editor of the List(Float) example has enter_set=True " + "and auto_set=False; press Enter to validate."), + Label("The List(Str) example will accept at most 3 elements."), + Label("The editor of the List(Enum(...)) example uses sep=None, " + "i.e. whitespace acts as a separator."), + Label("The last three List(Range(...)) examples take neither, one or " + "both of their limits from the Low and High fields below."), + width=720, + title="CSVListEditor Demonstration", + ) def _list1_default(self): return [1, 4, 0, 10] @@ -123,5 +158,5 @@ def _sort1_fired(self): if __name__ == "__main__": - demo = Demo() + demo = CSVListEditorDemo() demo.configure_traits() diff --git a/examples/demo/Standard_Editors/CheckListEditor_demo.py b/examples/demo/Standard_Editors/CheckListEditor_demo.py index e982238a2..6793bb68f 100644 --- a/examples/demo/Standard_Editors/CheckListEditor_demo.py +++ b/examples/demo/Standard_Editors/CheckListEditor_demo.py @@ -8,31 +8,36 @@ each of the four styles of the CheckListEditor. """ -# Imports: -from traits.api \ - import HasTraits, List +from traits.api import HasTraits, List -from traitsui.api \ - import Item, Group, View, CheckListEditor - -# Define the demo class: +from traitsui.api import Item, Group, View, CheckListEditor +# Define the demo class: class CheckListEditorDemo(HasTraits): """ Define the main CheckListEditor demo class. """ # Define a trait for each of three formations: - checklist_4col = List(editor=CheckListEditor( - values=['one', 'two', 'three', 'four'], - cols=4)) + checklist_4col = List( + editor=CheckListEditor( + values=['one', 'two', 'three', 'four'], + cols=4 + ) + ) - checklist_2col = List(editor=CheckListEditor( - values=['one', 'two', 'three', 'four'], - cols=2)) + checklist_2col = List( + editor=CheckListEditor( + values=['one', 'two', 'three', 'four'], + cols=2 + ) + ) - checklist_1col = List(editor=CheckListEditor( - values=['one', 'two', 'three', 'four'], - cols=1)) + checklist_1col = List( + editor=CheckListEditor( + values=['one', 'two', 'three', 'four'], + cols=1 + ) + ) # CheckListEditor display with four columns: cl_4_group = Group( @@ -70,9 +75,9 @@ class CheckListEditorDemo(HasTraits): label='1-column' ) - # The view includes one group per column formation. These will be displayed - # on separate tabbed panels. - view1 = View( + # The view includes one group per column formation. These will be + # displayed on separate tabbed panels. + traits_view = View( cl_4_group, cl_2_group, cl_1_group, @@ -81,6 +86,7 @@ class CheckListEditorDemo(HasTraits): resizable=True ) + # Create the demo: demo = CheckListEditorDemo() diff --git a/examples/demo/Standard_Editors/CheckListEditor_simple_demo.py b/examples/demo/Standard_Editors/CheckListEditor_simple_demo.py index 4149d1f9c..81c4528bd 100644 --- a/examples/demo/Standard_Editors/CheckListEditor_simple_demo.py +++ b/examples/demo/Standard_Editors/CheckListEditor_simple_demo.py @@ -1,8 +1,8 @@ """ Checklist editor for a List of strings -The checklist editor provides a simple way for the user to select multiple items -from a list of known strings. +The checklist editor provides a simple way for the user to select multiple +items from a list of known strings. This example demonstrates the checklist editor's two most useful styles: @@ -26,17 +26,19 @@ class CheckListEditorDemo(HasTraits): """ Define the main CheckListEditor simple demo class. """ # Specify the strings to be displayed in the checklist: - checklist = List(editor=CheckListEditor( - values=['one', 'two', 'three', 'four', - 'five', 'six'], - cols=2)) + checklist = List( + editor=CheckListEditor( + values=['one', 'two', 'three', 'four', 'five', 'six'], + cols=2 + ) + ) # CheckListEditor display with two columns: checklist_group = Group( - '10', # insert vertical space + '10', # insert vertical space (10 empty pixels) Label('The custom style lets you select items from a checklist:'), UItem('checklist', style='custom'), - '10', '_', '10', # a horizontal line with 10 empty pixels above and below + '10', '_', '10', # horizontal line with vertical space above and below Label('The readonly style shows you which items are selected, ' 'as a Python list:'), UItem('checklist', style='readonly'), @@ -49,6 +51,7 @@ class CheckListEditorDemo(HasTraits): resizable=True ) + # Create the demo: demo = CheckListEditorDemo() diff --git a/examples/demo/Standard_Editors/CodeEditor_demo.py b/examples/demo/Standard_Editors/CodeEditor_demo.py index cc602e325..89aada89f 100644 --- a/examples/demo/Standard_Editors/CodeEditor_demo.py +++ b/examples/demo/Standard_Editors/CodeEditor_demo.py @@ -7,16 +7,12 @@ This demo shows each of the four styles of the CodeEditor """ -# Imports: -from traits.api \ - import HasTraits, Code +from traits.api import HasTraits, Code -from traitsui.api \ - import Item, Group, View - -# The main demo class: +from traitsui.api import Item, Group, View +# The main demo class: class CodeEditorDemo(HasTraits): """ Defines the CodeEditor demo class. """ @@ -36,10 +32,13 @@ class CodeEditorDemo(HasTraits): ) # Demo view: - view = View( + traits_view = View( code_group, title='CodeEditor', - buttons=['OK']) + width=600, + height=600, + buttons=['OK'] + ) # Create the demo: diff --git a/examples/demo/Standard_Editors/ColorEditor_demo.py b/examples/demo/Standard_Editors/ColorEditor_demo.py index 4b7d2cb2d..68ecda954 100644 --- a/examples/demo/Standard_Editors/ColorEditor_demo.py +++ b/examples/demo/Standard_Editors/ColorEditor_demo.py @@ -2,26 +2,32 @@ # License: BSD Style. """ +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + Implementation of a ColorEditor demo plugin for Traits UI demo program. This demo shows each of the four styles of the ColorEditor """ +# Issues related to the demo warning: enthought/traitsui#913, +# enthought/traitsui#946 -# Imports: -from traits.api \ - import HasTraits -from traitsui.api \ - import Item, Group, View, Color +from traits.api import HasTraits -# Demo class definition: +from traitsui.api import Item, Group, View, Color +# Demo class definition: class ColorEditorDemo(HasTraits): """ Defines the main ColorEditor demo. """ # Define a Color trait to view: - color_trait = Color + color_trait = Color() # Items are used to define the demo display, one item per editor style: color_group = Group( @@ -35,13 +41,14 @@ class ColorEditorDemo(HasTraits): ) # Demo view - view1 = View( + traits_view = View( color_group, title='ColorEditor', buttons=['OK'], resizable=True ) + # Create the demo: demo = ColorEditorDemo() diff --git a/examples/demo/Standard_Editors/CompoundEditor_demo.py b/examples/demo/Standard_Editors/CompoundEditor_demo.py index d59ec1cd6..fb7dc0504 100644 --- a/examples/demo/Standard_Editors/CompoundEditor_demo.py +++ b/examples/demo/Standard_Editors/CompoundEditor_demo.py @@ -2,27 +2,39 @@ # License: BSD Style. """ +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + Implementation of a CompoundEditor demo plugin for Traits UI demo program. This demo shows each of the four styles of the CompoundEditor """ +# Issue related to the demo warning: enthought/traitsui#945 -# Imports: -from traits.api \ - import HasTraits, Trait, Range -from traitsui.api \ - import Item, Group, View +from traits.api import Either, Enum, HasTraits, Range -# Define the demo class: +from traitsui.api import Item, Group, View +# Define the demo class: class CompoundEditorDemo(HasTraits): """ Defines the main CompoundEditor demo class. """ # Define a compund trait to view: - compound_trait = Trait(1, Range(1, 6), 'a', 'b', 'c', 'd', 'e', 'f') + # Note: In Traits 6.1 a new Trait type `Union` has been added, which is + # recommended over `Either`: + # compound_trait = Union( + # Range(1, 6), Enum('a', 'b', 'c', 'd', 'e', 'f'), default_value=1 + # ) + compound_trait = Either( + Range(1, 6), Enum('a', 'b', 'c', 'd', 'e', 'f'), default=1 + ) # Display specification (one Item per editor style): comp_group = Group( @@ -36,13 +48,14 @@ class CompoundEditorDemo(HasTraits): ) # Demo view: - view = View( + traits_view = View( comp_group, title='CompoundEditor', buttons=['OK'], resizable=True ) + # Create the demo: demo = CompoundEditorDemo() diff --git a/examples/demo/Standard_Editors/DataFrameEditor_demo.py b/examples/demo/Standard_Editors/DataFrameEditor_demo.py index a2979b2d5..bc44bda60 100644 --- a/examples/demo/Standard_Editors/DataFrameEditor_demo.py +++ b/examples/demo/Standard_Editors/DataFrameEditor_demo.py @@ -4,92 +4,90 @@ # DataFrameEditor_demo.py -- Example of using dataframe editors # Dataset from https://www.kaggle.com/mokosan/lord-of-the-rings-character-data +""" +**WARNING** -#--[Imports]-------------------------------------------------------------- + This demo might not work as expected and some documented features might be + missing. -from pandas import DataFrame -from traits.api import HasTraits, Instance -from traitsui.api import View, Item -from traitsui.menu import NoButtons -from traitsui.ui_editors.data_frame_editor import DataFrameEditor -import numpy as np +------------------------------------------------------------------------------- +""" +# Issue related to the demo warning: enthought/traitsui#944 +import numpy as np +from pandas import DataFrame +from traits.api import HasTraits, Instance -#------ DataFrameEditorDemo Class Definition--------------------------------- +from traitsui.api import View, Item +from traitsui.ui_editors.data_frame_editor import DataFrameEditor class DataFrameEditorDemo(HasTraits): df = Instance(DataFrame) - view = View( - - Item('df', - show_label=False, - editor=DataFrameEditor(formats={ - - 'RuntimeInMinutes':'%.4d', - 'BudgetInMillions':'%d', - 'BoxOfficeRevenueInMillions':'%d', - 'AcademyAwardNominations':'%d', - 'AcademyAwardWins':'%d', - 'RottenTomatoesScore':'%.2f' - - }) - - ), - - title="DataFrameEditor", - resizable=True, - id='traitsui.demo.Applications.data_frame_editor_demo' - - ) - + traits_view = View( + Item( + 'df', + show_label=False, + editor=DataFrameEditor( + formats={ + 'RuntimeInMinutes': '%.4d', + 'BudgetInMillions': '%d', + 'BoxOfficeRevenueInMillions': '%d', + 'AcademyAwardNominations': '%d', + 'AcademyAwardWins': '%d', + 'RottenTomatoesScore': '%.2f' + } + ) + ), + title="DataFrameEditor", + resizable=True, + id='traitsui.demo.Applications.data_frame_editor_demo' + ) # Sample Data -lotrMovieData = np.array([ - [558, 281, 2917.0, 30, 17, 94.0], - [178, 93, 871.5, 13, 4, 91.0], - [179, 94, 926.0, 6, 2, 96.0], - [201, 94, 1120, 11, 11, 95.0], - [462.0, 675, 2932.0, 7, 1, 66.33333333], - [169, 200, 1021.0, 3, 1, 64.0], - [161, 217, 958.4, 3, 0, 75.0], - [144, 250, 956.0, 1, 0, 60.0] - ]) +lotrMovieData = np.array( + [ + [558, 281, 2917.0, 30, 17, 94.0], + [178, 93, 871.5, 13, 4, 91.0], + [179, 94, 926.0, 6, 2, 96.0], + [201, 94, 1120, 11, 11, 95.0], + [462.0, 675, 2932.0, 7, 1, 66.33333333], + [169, 200, 1021.0, 3, 1, 64.0], + [161, 217, 958.4, 3, 0, 75.0], + [144, 250, 956.0, 1, 0, 60.0] + ] +) col_names = [ - 'RuntimeInMinutes', - 'BudgetInMillions', - 'BoxOfficeRevenueInMillions', - 'AcademyAwardNominations', - 'AcademyAwardWins', - 'RottenTomatoesScore' + 'RuntimeInMinutes', + 'BudgetInMillions', + 'BoxOfficeRevenueInMillions', + 'AcademyAwardNominations', + 'AcademyAwardWins', + 'RottenTomatoesScore' ] -index_names = [ - 'The Lord of the Rings Series', - 'The Fellowship of the Ring', - 'The Two Towers ', - 'The Return of the King', - 'The Hobbit Series', - 'The Unexpected Journey', - 'The Desolation of Smaug', - 'The Battle of the Five Armies' - ] +index_names = [ + 'The Lord of the Rings Series', + 'The Fellowship of the Ring', + 'The Two Towers ', + 'The Return of the King', + 'The Hobbit Series', + 'The Unexpected Journey', + 'The Desolation of Smaug', + 'The Battle of the Five Armies' +] # Create & run the demo df = DataFrame(data=lotrMovieData, columns=col_names, index=index_names) demo = DataFrameEditorDemo(df=df) - # Run the demo (if invoked from the command line): if __name__ == '__main__': demo.configure_traits() - - - diff --git a/examples/demo/Standard_Editors/DatetimeEditor_demo.py b/examples/demo/Standard_Editors/DatetimeEditor_demo.py index 306b95e8c..f76fdd88a 100644 --- a/examples/demo/Standard_Editors/DatetimeEditor_demo.py +++ b/examples/demo/Standard_Editors/DatetimeEditor_demo.py @@ -2,8 +2,18 @@ # License: BSD Style. """ +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + A Traits UI editor that edits a datetime panel. """ +# Issue related to the demo warning: enthought/traitsui#943 + + import datetime from traits.api import HasTraits, Datetime, Str @@ -15,7 +25,7 @@ class DateEditorDemo(HasTraits): datetime = Datetime() info_string = Str('The editors for Traits Datetime objects.') - view = View( + traits_view = View( Item( 'info_string', show_label=False, @@ -41,7 +51,7 @@ def _datetime_changed(self): print(self.datetime) -#-- Set Up The Demo ------------------------------------------------------ +# -- Set Up The Demo ------------------------------------------------------ demo = DateEditorDemo( datetime=datetime.datetime.now() diff --git a/examples/demo/Standard_Editors/DirectoryEditor_demo.py b/examples/demo/Standard_Editors/DirectoryEditor_demo.py index 19ea043db..cb5efbc4e 100644 --- a/examples/demo/Standard_Editors/DirectoryEditor_demo.py +++ b/examples/demo/Standard_Editors/DirectoryEditor_demo.py @@ -2,21 +2,26 @@ # License: BSD Style. """ +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + Implementation of a DirectoryEditor demo plugin for Traits UI demo program. This demo shows each of the four styles of the DirectoryEditor """ +# Issue related to the demo warning: enthought/traitsui#889 -# Imports: -from traits.api \ - import HasTraits, Directory -from traitsui.api \ - import Item, Group, View +from traits.api import HasTraits, Directory -# Define the demo class: +from traitsui.api import Item, Group, View +# Define the demo class: class DirectoryEditorDemo(HasTraits): """ Define the main DirectoryEditor demo class. """ @@ -35,13 +40,16 @@ class DirectoryEditorDemo(HasTraits): ) # Demo view: - view = View( + traits_view = View( dir_group, title='DirectoryEditor', + width=400, + height=600, buttons=['OK'], resizable=True ) + # Create the demo: demo = DirectoryEditorDemo() diff --git a/examples/demo/Standard_Editors/FileEditor_demo.py b/examples/demo/Standard_Editors/FileEditor_demo.py index 0ae1b69b0..86f63b491 100644 --- a/examples/demo/Standard_Editors/FileEditor_demo.py +++ b/examples/demo/Standard_Editors/FileEditor_demo.py @@ -2,21 +2,26 @@ # License: BSD Style. """ +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + Implementation of a FileEditor demo plugin for Traits UI demo program. This demo shows each of the four styles of the FileEditor """ +# Issue related to the demo warning: enthought/traitsui#889 -# Imports: -from traits.api \ - import HasTraits, File -from traitsui.api \ - import Item, Group, View +from traits.api import HasTraits, File -# Define the demo class: +from traitsui.api import Item, Group, View +# Define the demo class: class FileEditorDemo(HasTraits): """ Defines the main FileEditor demo class. """ @@ -35,13 +40,16 @@ class FileEditorDemo(HasTraits): ) # Demo view: - view = View( + traits_view = View( file_group, title='FileEditor', + width=400, + height=600, buttons=['OK'], resizable=True ) + # Create the demo: demo = FileEditorDemo() diff --git a/examples/demo/Standard_Editors/FontEditor_demo.py b/examples/demo/Standard_Editors/FontEditor_demo.py index 9c05b2db8..b18002e8e 100644 --- a/examples/demo/Standard_Editors/FontEditor_demo.py +++ b/examples/demo/Standard_Editors/FontEditor_demo.py @@ -1,13 +1,13 @@ """ Font editor -A Font editor in a Traits UI allows the user to select a font from the operating -system. +A Font editor in a Traits UI allows the user to select a font from the +operating system. Typically, you then pass the Font trait to another UI editor, which uses it to display text. You can also read the Font trait as a string, or access its -individual attributes (note that these attributes are specific to the UI toolkit --- QT or WX.) +individual attributes (note that these attributes are specific to the UI +toolkit -- QT or WX.) The default 'simple' Font editor style is usually the most useful and powerful style - it pops up a font selection dialog which is specific to the OS and @@ -16,7 +16,6 @@ This example also displays some other less common style choices. """ -# Imports: from traits.api import HasTraits from traitsui.api import Item, Group, View, Font @@ -26,7 +25,7 @@ class FontEditorDemo(HasTraits): """ Defines the main FontEditor demo class. """ # Define a Font trait to view: - my_font_trait = Font + my_font_trait = Font() # Display specification (one Item per editor style): font_group = Group( @@ -40,13 +39,14 @@ class FontEditorDemo(HasTraits): ) # Demo view: - view = View( + traits_view = View( font_group, title='FontEditor', buttons=['OK'], resizable=True ) + # Create the demo: demo = FontEditorDemo() diff --git a/examples/demo/Standard_Editors/HTMLEditor_demo.py b/examples/demo/Standard_Editors/HTMLEditor_demo.py index e8b0bf4cf..c7e5b8088 100644 --- a/examples/demo/Standard_Editors/HTMLEditor_demo.py +++ b/examples/demo/Standard_Editors/HTMLEditor_demo.py @@ -52,14 +52,18 @@ class HTMLEditorDemo(HasTraits): # Demo view traits_view = View( - UItem('my_html_trait', - # we specify the editor explicitly in order to set format_text: - editor=HTMLEditor(format_text=True)), + UItem( + 'my_html_trait', + # we specify the editor explicitly in order to set format_text: + editor=HTMLEditor(format_text=True) + ), title='HTMLEditor', buttons=['OK'], width=800, height=600, - resizable=True) + resizable=True + ) + # Create the demo: demo = HTMLEditorDemo() diff --git a/examples/demo/Standard_Editors/ImageEnumEditor_demo.py b/examples/demo/Standard_Editors/ImageEnumEditor_demo.py index defdf8a76..743303d70 100644 --- a/examples/demo/Standard_Editors/ImageEnumEditor_demo.py +++ b/examples/demo/Standard_Editors/ImageEnumEditor_demo.py @@ -2,17 +2,25 @@ # License: BSD Style. """ -Implementation of an ImageEnumEditor demo plugin for the Traits UI demo program. +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + +Implementation of an ImageEnumEditor demo plugin for the Traits UI demo +program. This demo shows each of the four styles of the ImageEnumEditor. """ +# Issues related to the demo warning: enthought/traitsui#913, +# enthought/traitsui#947 + -# Imports: -from traits.api \ - import HasTraits, Str, Trait +from traits.api import Enum, HasTraits, Str -from traitsui.api \ - import Item, Group, View, ImageEnumEditor +from traitsui.api import Item, Group, View, ImageEnumEditor # This list of image names (with the standard suffix "_origin") is used to # construct an image enumeration trait to demonstrate the ImageEnumEditor: @@ -24,7 +32,7 @@ class Dummy(HasTraits): """ x = Str() - view = View() + traits_view = View() class ImageEnumEditorDemo(HasTraits): @@ -32,32 +40,37 @@ class ImageEnumEditorDemo(HasTraits): """ # Define a trait to view: - image_from_list = Trait(editor=ImageEnumEditor(values=image_list, - prefix='@icons:', - suffix='_origin', - cols=4, - klass=Dummy), - *image_list) + image_from_list = Enum( + *image_list, + editor=ImageEnumEditor( + values=image_list, + prefix='@icons:', + suffix='_origin', + cols=4, + klass=Dummy + ) + ) # Items are used to define the demo display, one Item per editor style: img_group = Group( Item('image_from_list', style='simple', label='Simple'), Item('_'), - Item('image_from_list', style='custom', label='Custom'), - Item('_'), Item('image_from_list', style='text', label='Text'), Item('_'), - Item('image_from_list', style='readonly', label='ReadOnly') + Item('image_from_list', style='readonly', label='ReadOnly'), + Item('_'), + Item('image_from_list', style='custom', label='Custom') ) # Demo view: - view = View( + traits_view = View( img_group, title='ImageEnumEditor', buttons=['OK'], resizable=True ) + # Create the demo: demo = ImageEnumEditorDemo() diff --git a/examples/demo/Standard_Editors/InstanceEditor_demo.py b/examples/demo/Standard_Editors/InstanceEditor_demo.py index 6feac3d01..5892e0a47 100644 --- a/examples/demo/Standard_Editors/InstanceEditor_demo.py +++ b/examples/demo/Standard_Editors/InstanceEditor_demo.py @@ -2,6 +2,13 @@ # License: BSD Style. """ +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + Implementation of an InstanceEditor demo plugin for the Traits UI demo program. This demo shows each of the four styles of the InstanceEditor @@ -9,19 +16,18 @@ Fixme: This version of the demo only shows the old-style InstanceEditor capabilities. """ +# Issue related to the demo warning: enthought/traitsui#939 -# Imports: -from traits.api \ - import HasTraits, Str, Range, Bool, Instance -from traitsui.api \ - import Item, Group, View +from traits.api import HasTraits, Str, Range, Bool, Instance -#------------------------------------------------------------------------- -# Classes: -#------------------------------------------------------------------------- +from traitsui.api import Item, Group, View +# ------------------------------------------------------------------------- +# Classes: +# ------------------------------------------------------------------------- + class SampleClass(HasTraits): """ This Sample class is used to demonstrate the InstanceEditor demo. """ @@ -36,7 +42,7 @@ class SampleClass(HasTraits): # The InstanceEditor uses whatever view is defined for the class. The # default view lists the fields alphabetically, so it's best to define one # explicitly: - view = View('name', 'occupation', 'age', 'registered_voter') + traits_view = View('name', 'occupation', 'age', 'registered_voter') class InstanceEditorDemo(HasTraits): @@ -58,13 +64,14 @@ class InstanceEditorDemo(HasTraits): ) # Demo View: - view = View( + traits_view = View( inst_group, title='InstanceEditor', buttons=['OK'], resizable=True ) + # Create the demo: demo = InstanceEditorDemo() diff --git a/examples/demo/Standard_Editors/ListEditor_demo.py b/examples/demo/Standard_Editors/ListEditor_demo.py index e03e76d2a..23e224d59 100644 --- a/examples/demo/Standard_Editors/ListEditor_demo.py +++ b/examples/demo/Standard_Editors/ListEditor_demo.py @@ -7,16 +7,12 @@ This demo shows each of the four styles of ListEditor """ -# Imports: -from traits.api \ - import HasTraits, List, Str +from traits.api import HasTraits, List, Str -from traitsui.api \ - import Item, Group, View - -# Define the demo class: +from traitsui.api import Item, Group, View +# Define the demo class: class ListEditorDemo(HasTraits): """ Defines the main ListEditor demo class. """ @@ -35,13 +31,16 @@ class ListEditorDemo(HasTraits): ) # Demo view: - view = View( + traits_view = View( list_group, title='ListEditor', buttons=['OK'], + height=600, + width=400, resizable=True ) + # Create the demo: demo = ListEditorDemo() diff --git a/examples/demo/Standard_Editors/Popup_versions/BooleanEditor_demo.py b/examples/demo/Standard_Editors/Popup_versions/BooleanEditor_demo.py index c962e560a..f8a75ee89 100644 --- a/examples/demo/Standard_Editors/Popup_versions/BooleanEditor_demo.py +++ b/examples/demo/Standard_Editors/Popup_versions/BooleanEditor_demo.py @@ -4,15 +4,14 @@ This demo shows each of the four styles of the BooleanEditor """ - -#------------------------------------------------------------------------- -# Demo Class -#------------------------------------------------------------------------- - from traits.api import HasTraits, Bool from traitsui.api import Item, Group, View +# ------------------------------------------------------------------------- +# Demo Class +# ------------------------------------------------------------------------- + class BooleanEditorDemo(HasTraits): """ This class specifies the details of the BooleanEditor demo. """ @@ -20,25 +19,29 @@ class BooleanEditorDemo(HasTraits): # To demonstrate any given Trait editor, an appropriate Trait is required. boolean_trait = Bool() - # Items are used to define the demo display - one Item per - # editor style + # Items are used to define the demo display - one Item per editor style bool_group = Group( - Item( - 'boolean_trait', style='simple', label='Simple'), Item('_'), Item( - 'boolean_trait', style='custom', label='Custom'), Item('_'), Item( - 'boolean_trait', style='text', label='Text'), Item('_'), Item( - 'boolean_trait', style='readonly', label='ReadOnly')) + Item('boolean_trait', style='simple', label='Simple'), + Item('_'), + Item('boolean_trait', style='custom', label='Custom'), + Item('_'), + Item('boolean_trait', style='text', label='Text'), + Item('_'), + Item('boolean_trait', style='readonly', label='ReadOnly') + ) # Demo view - view1 = View(bool_group, - title='BooleanEditor', - buttons=['OK'], - width=300) + traits_view = View( + bool_group, + title='BooleanEditor', + buttons=['OK'], + width=300 + ) # Hook for 'demo.py' -popup = BooleanEditorDemo() +demo = BooleanEditorDemo() # Run the demo (if invoked from the command line): if __name__ == '__main__': - popup.configure_traits() + demo.configure_traits() diff --git a/examples/demo/Standard_Editors/Popup_versions/ButtonEditor_demo.py b/examples/demo/Standard_Editors/Popup_versions/ButtonEditor_demo.py index 3c7727ecd..b2ca40a60 100644 --- a/examples/demo/Standard_Editors/Popup_versions/ButtonEditor_demo.py +++ b/examples/demo/Standard_Editors/Popup_versions/ButtonEditor_demo.py @@ -6,13 +6,12 @@ """ from traits.api import HasTraits, Button -from traitsui.api import Item, View, Group -from traitsui.message import message +from traitsui.api import Item, View, Group, message -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Demo Class -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- class ButtonEditorDemo(HasTraits): """ This class specifies the details of the ButtonEditor demo. @@ -26,24 +25,28 @@ def _fire_event_fired(): # ButtonEditor display # (Note that Text and ReadOnly versions are not applicable) - event_group = Group(Item('fire_event', style='simple', label='Simple'), - Item('_'), - Item('fire_event', style='custom', label='Custom'), - Item('_'), - Item(label='[text style unavailable]'), - Item('_'), - Item(label='[read only style unavailable]')) + event_group = Group( + Item('fire_event', style='simple', label='Simple'), + Item('_'), + Item('fire_event', style='custom', label='Custom'), + Item('_'), + Item(label='[text style unavailable]'), + Item('_'), + Item(label='[readonly style unavailable]') + ) # Demo view - view1 = View(event_group, - title='ButtonEditor', - buttons=['OK'], - width=250) + traits_view = View( + event_group, + title='ButtonEditor', + buttons=['OK'], + width=250 + ) # Create the demo: -popup = ButtonEditorDemo() +demo = ButtonEditorDemo() # Run the demo (if invoked from the command line): if __name__ == '__main__': - popup.configure_traits() + demo.configure_traits() diff --git a/examples/demo/Standard_Editors/RGBColorEditor_demo.py b/examples/demo/Standard_Editors/RGBColorEditor_demo.py index 172536933..afd77d0ed 100644 --- a/examples/demo/Standard_Editors/RGBColorEditor_demo.py +++ b/examples/demo/Standard_Editors/RGBColorEditor_demo.py @@ -2,26 +2,31 @@ # License: BSD Style. """ -Implementation of a ColorEditor demo plugin for Traits UI demo program. +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + +Implementation of a RGBColorEditor demo plugin for Traits UI demo program. This demo shows each of the four styles of the ColorEditor """ +# Issue related to the demo warning: enthought/traitsui#939 -# Imports: -from traits.api \ - import HasTraits -from traitsui.api \ - import Item, Group, View, RGBColor +from traits.api import HasTraits -# Demo class definition: +from traitsui.api import Item, Group, View, RGBColor -class ColorEditorDemo(HasTraits): - """ Defines the main ColorEditor demo. """ +# Demo class definition: +class RGBColorEditorDemo(HasTraits): + """ Defines the main RGBColorEditor demo. """ # Define a Color trait to view: - color_trait = RGBColor + color_trait = RGBColor() # Items are used to define the demo display, one item per editor style: color_group = Group( @@ -35,15 +40,16 @@ class ColorEditorDemo(HasTraits): ) # Demo view - view1 = View( + traits_view = View( color_group, - title='ColorEditor', + title='RGBColorEditor', buttons=['OK'], resizable=True ) + # Create the demo: -demo = ColorEditorDemo() +demo = RGBColorEditorDemo() # Run the demo (if invoked from the command line): if __name__ == '__main__': diff --git a/examples/demo/Standard_Editors/SetEditor_demo.py b/examples/demo/Standard_Editors/SetEditor_demo.py index b47a6e999..cc004ce8e 100644 --- a/examples/demo/Standard_Editors/SetEditor_demo.py +++ b/examples/demo/Standard_Editors/SetEditor_demo.py @@ -2,6 +2,13 @@ # License: BSD Style. """ +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + Implementation of a SetEditor demo plugin for the Traits UI demo program. The four tabs of this demo show variations on the interface as follows: @@ -11,45 +18,55 @@ Ord I: Creates a set whose order is specified by the user, no "move all" Ord II: Creates a set whose order is specifed by the user, has "move all" """ +# Issue related to the demo warning: enthought/traitsui#913 -# Imports: -from traits.api \ - import HasTraits, List -from traitsui.api \ - import Item, Group, View, SetEditor +from traits.api import HasTraits, List -# Define the main demo class: +from traitsui.api import Item, Group, View, SetEditor +# Define the main demo class: class SetEditorDemo(HasTraits): """ Defines the SetEditor demo class. """ # Define a trait each for four SetEditor variants: - unord_nma_set = List(editor=SetEditor( - values=['kumquats', 'pomegranates', 'kiwi'], - can_move_all=False, - left_column_title='Available Fruit', - right_column_title='Exotic Fruit Bowl')) - - unord_ma_set = List(editor=SetEditor( - values=['kumquats', 'pomegranates', 'kiwi'], - left_column_title='Available Fruit', - right_column_title='Exotic Fruit Bowl')) - - ord_nma_set = List(editor=SetEditor( - values=['apples', 'berries', 'cantaloupe'], - ordered=True, - can_move_all=False, - left_column_title='Available Fruit', - right_column_title='Fruit Bowl')) - - ord_ma_set = List(editor=SetEditor( - values=['apples', 'berries', 'cantaloupe'], - ordered=True, - left_column_title='Available Fruit', - right_column_title='Fruit Bowl')) + unord_nma_set = List( + editor=SetEditor( + values=['kumquats', 'pomegranates', 'kiwi'], + left_column_title='Available Fruit', + right_column_title='Exotic Fruit Bowl', + can_move_all=False + ) + ) + + unord_ma_set = List( + editor=SetEditor( + values=['kumquats', 'pomegranates', 'kiwi'], + left_column_title='Available Fruit', + right_column_title='Exotic Fruit Bowl' + ) + ) + + ord_nma_set = List( + editor=SetEditor( + values=['apples', 'berries', 'cantaloupe'], + left_column_title='Available Fruit', + right_column_title='Fruit Bowl', + ordered=True, + can_move_all=False + ) + ) + + ord_ma_set = List( + editor=SetEditor( + values=['apples', 'berries', 'cantaloupe'], + left_column_title='Available Fruit', + right_column_title='Fruit Bowl', + ordered=True + ) + ) # SetEditor display, unordered, no move-all buttons: no_nma_group = Group( @@ -81,7 +98,7 @@ class SetEditorDemo(HasTraits): # The view includes one group per data type. These will be displayed # on separate tabbed panels: - view = View( + traits_view = View( no_nma_group, no_ma_group, o_nma_group, @@ -90,6 +107,7 @@ class SetEditorDemo(HasTraits): buttons=['OK'] ) + # Create the demo: demo = SetEditorDemo() diff --git a/examples/demo/Standard_Editors/TableEditor_demo.py b/examples/demo/Standard_Editors/TableEditor_demo.py index 2243a2dda..03b779a25 100644 --- a/examples/demo/Standard_Editors/TableEditor_demo.py +++ b/examples/demo/Standard_Editors/TableEditor_demo.py @@ -14,6 +14,8 @@ This demo shows the full behavior of a straightforward TableEditor. Only one style of TableEditor is implemented, so that is the one shown. """ +# Issue related to the demo warning: enthought/traitsui#948 + from traits.api import HasTraits, HasStrictTraits, Str, Int, Regex, List diff --git a/examples/demo/Standard_Editors/TitleEditor_demo.py b/examples/demo/Standard_Editors/TitleEditor_demo.py index 24f2c968e..e8a4d91b3 100644 --- a/examples/demo/Standard_Editors/TitleEditor_demo.py +++ b/examples/demo/Standard_Editors/TitleEditor_demo.py @@ -20,12 +20,9 @@ into the value field to cause the title to changed. """ -# Imports: -from traits.api \ - import HasTraits, Enum, Str, Float, Property, cached_property +from traits.api import HasTraits, Enum, Str, Float, Property, cached_property -from traitsui.api \ - import View, VGroup, HGroup, Item, TitleEditor +from traitsui.api import View, VGroup, HGroup, Item, TitleEditor class TitleEditorDemo(HasTraits): @@ -48,7 +45,7 @@ class TitleEditorDemo(HasTraits): value = Float() # Define the test view: - view = View( + traits_view = View( VGroup( VGroup( HGroup( @@ -87,16 +84,23 @@ class TitleEditorDemo(HasTraits): width=0.4 ) - #-- Property Implementations --------------------------------------------- + # -- Property Implementations --------------------------------------------- @cached_property def _get_title_3(self): - try: - return ('The square root of %s is %s' % - (self.value, self.value ** 0.5)) - except: - return ('The square root of %s is %si' % - (self.value, (-self.value) ** 0.5)) + if self.value >= 0: + return ( + 'The square root of {} is {}'.format( + self.value, self.value ** 0.5 + ) + ) + else: + return ( + 'The square root of {} is {}i'.format( + self.value, (-self.value) ** 0.5 + ) + ) + # Create the demo: demo = TitleEditorDemo() diff --git a/examples/demo/Standard_Editors/TreeEditor_demo.py b/examples/demo/Standard_Editors/TreeEditor_demo.py index 07bf23a02..27055e751 100644 --- a/examples/demo/Standard_Editors/TreeEditor_demo.py +++ b/examples/demo/Standard_Editors/TreeEditor_demo.py @@ -14,8 +14,8 @@ - Employee -The TreeEditor generates a hierarchical tree control, consisting of nodes. It is -useful for cases where objects contain lists of other objects. +The TreeEditor generates a hierarchical tree control, consisting of nodes. It +is useful for cases where objects contain lists of other objects. The tree control is displayed in one pane of the editor, and a user interface for the selected object is displayed in the other pane. The layout orientation @@ -29,15 +29,14 @@ You must specify the classes whose instances the node type applies to. Use the **node_for** attribute of TreeNode to specify a list of classes; often, this list contains only one class. You can have more than one node type that applies -to a particular class; in this case, each object of that class is represented by -multiple nodes, one for each applicable node type. +to a particular class; in this case, each object of that class is represented +by multiple nodes, one for each applicable node type. See the Traits User Manual for more details. """ -# FIXME: provide accessible copy or equivalent of factories_advanced_extra.rst - from traits.api import HasTraits, Str, Regex, List, Instance + from traitsui.api import Item, View, TreeEditor, TreeNode @@ -66,6 +65,7 @@ class Company(HasTraits): departments = List(Department) employees = List(Employee) + # Create an empty view for objects that have no data to display: no_view = View() @@ -73,39 +73,44 @@ class Company(HasTraits): tree_editor = TreeEditor( nodes=[ # The first node specified is the top level one - TreeNode(node_for=[Company], - auto_open=True, - # child nodes are - children='', - label='name', # label with Company name - view=View(['name']) - ), - TreeNode(node_for=[Company], - auto_open=True, - children='departments', - label='=Departments', # constant label - view=no_view, - add=[Department], - ), - TreeNode(node_for=[Company], - auto_open=True, - children='employees', - label='=Employees', # constant label - view=no_view, - add=[Employee] - ), - TreeNode(node_for=[Department], - auto_open=True, - children='employees', - label='name', # label with Department name - view=View(['name']), - add=[Employee] - ), - TreeNode(node_for=[Employee], - auto_open=True, - label='name', # label with Employee name - view=View(['name', 'title', 'phone']) - ) + TreeNode( + node_for=[Company], + auto_open=True, + # child nodes are + children='', + label='name', # label with Company name + view=View(['name']) + ), + TreeNode( + node_for=[Company], + auto_open=True, + children='departments', + label='=Departments', # constant label + view=no_view, + add=[Department], + ), + TreeNode( + node_for=[Company], + auto_open=True, + children='employees', + label='=Employees', # constant label + view=no_view, + add=[Employee] + ), + TreeNode( + node_for=[Department], + auto_open=True, + children='employees', + label='name', # label with Department name + view=View(['name']), + add=[Employee] + ), + TreeNode( + node_for=[Employee], + auto_open=True, + label='name', # label with Employee name + view=View(['name', 'title', 'phone']) + ) ] ) @@ -116,11 +121,8 @@ class Partner(HasTraits): name = Str('') company = Instance(Company) - view = View( - Item(name='company', - editor=tree_editor, - show_label=False - ), + traits_view = View( + Item(name='company', editor=tree_editor, show_label=False), title='Company Structure', buttons=['OK'], resizable=True, @@ -129,22 +131,13 @@ class Partner(HasTraits): height=500 ) + # Create an example data structure: -jason = Employee(name='Jason', - title='Senior Engineer', - phone='536-1057') -mike = Employee(name='Mike', - title='Senior Engineer', - phone='536-1057') -dave = Employee(name='Dave', - title='Senior Software Developer', - phone='536-1057') -martin = Employee(name='Martin', - title='Senior Engineer', - phone='536-1057') -duncan = Employee(name='Duncan', - title='Consultant', - phone='526-1057') +jason = Employee(name='Jason', title='Senior Engineer', phone='536-1057') +mike = Employee(name='Mike', title='Senior Engineer', phone='536-1057') +dave = Employee(name='Dave', title='Senior Developer', phone='536-1057') +martin = Employee(name='Martin', title='Senior Engineer', phone='536-1057') +duncan = Employee(name='Duncan', title='Consultant', phone='526-1057') # Create the demo: demo = Partner( diff --git a/examples/demo/Standard_Editors/TupleEditor_demo.py b/examples/demo/Standard_Editors/TupleEditor_demo.py index 38d68896f..2ee467d3b 100644 --- a/examples/demo/Standard_Editors/TupleEditor_demo.py +++ b/examples/demo/Standard_Editors/TupleEditor_demo.py @@ -2,21 +2,26 @@ # License: BSD Style. """ +**WARNING** + + This demo might not work as expected and some documented features might be + missing. + +------------------------------------------------------------------------------- + Implementation of a TupleEditor demo plugin for Traits UI demo program. This demo shows each of the four styles of the TupleEditor """ +# Issue related to the demo warning: enthought/traitsui#939 -# Imports: -from traits.api \ - import HasTraits, Tuple, Range, Str -from traitsui.api \ - import Item, Group, View, Color +from traits.api import HasTraits, Tuple, Range, Str -# The main demo class: +from traitsui.api import Item, Group, View, Color +# The main demo class: class TupleEditorDemo(HasTraits): """ Defines the TupleEditor demo class. """ @@ -36,7 +41,7 @@ class TupleEditorDemo(HasTraits): ) # Demo view - view = View( + traits_view = View( tuple_group, title='TupleEditor', buttons=['OK'],