From 0ef2a3a6739769cfaa781c515d1ed9bfdf4a6eaa Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Fri, 16 Apr 2021 09:05:30 +0530 Subject: [PATCH] DEV : Replace depends_on in Property traits with observe modified: envisage/examples/demo/plugins/tasks/attractors/model/henon.py modified: envisage/examples/demo/plugins/tasks/attractors/model/i_model_3d.py modified: envisage/examples/demo/plugins/tasks/attractors/model/lorenz.py modified: envisage/examples/demo/plugins/tasks/attractors/model/rossler.py modified: envisage/examples/demo/plugins/tasks/attractors/model_help_pane.py modified: envisage/examples/demo/plugins/tasks/attractors/plot_2d_pane.py modified: envisage/plugins/python_shell/view/namespace_view.py modified: envisage/ui/tasks/action/task_window_toggle_group.py modified: envisage/ui/tasks/task_window.py modified: examples/legacy/plugins/tasks/ipython_kernel/example_task.py modified: examples/legacy/plugins/tasks/ipython_kernel/python_editor.py --- .../demo/plugins/tasks/attractors/model/henon.py | 6 +++--- .../plugins/tasks/attractors/model/i_model_3d.py | 4 ++-- .../demo/plugins/tasks/attractors/model/lorenz.py | 5 ++--- .../demo/plugins/tasks/attractors/model/rossler.py | 4 ++-- .../demo/plugins/tasks/attractors/model_help_pane.py | 2 +- .../demo/plugins/tasks/attractors/plot_2d_pane.py | 12 ++++++------ envisage/plugins/python_shell/view/namespace_view.py | 2 +- envisage/ui/tasks/action/task_window_toggle_group.py | 2 +- envisage/ui/tasks/task_window.py | 2 +- .../plugins/tasks/ipython_kernel/example_task.py | 2 +- .../plugins/tasks/ipython_kernel/python_editor.py | 4 ++-- 11 files changed, 22 insertions(+), 23 deletions(-) diff --git a/envisage/examples/demo/plugins/tasks/attractors/model/henon.py b/envisage/examples/demo/plugins/tasks/attractors/model/henon.py index 393fe3fc7..a7b9f4016 100644 --- a/envisage/examples/demo/plugins/tasks/attractors/model/henon.py +++ b/envisage/examples/demo/plugins/tasks/attractors/model/henon.py @@ -34,7 +34,7 @@ class Henon(HasTraits): steps = Int(10000) # Iteration results. - points = Property(Array, depends_on="a, b, initial_point, steps") + points = Property(Array, observe="a, b, initial_point, steps") # Configuration view. view = View( @@ -49,8 +49,8 @@ class Henon(HasTraits): name = Str("Henon Map") plot_type = Str("scatter") - x_data = Property(Array, depends_on="points") - y_data = Property(Array, depends_on="points") + x_data = Property(Array, observe="points") + y_data = Property(Array, observe="points") x_label = Str("x") y_label = Str("y") diff --git a/envisage/examples/demo/plugins/tasks/attractors/model/i_model_3d.py b/envisage/examples/demo/plugins/tasks/attractors/model/i_model_3d.py index a04bc72f0..58346da34 100644 --- a/envisage/examples/demo/plugins/tasks/attractors/model/i_model_3d.py +++ b/envisage/examples/demo/plugins/tasks/attractors/model/i_model_3d.py @@ -36,8 +36,8 @@ class IModel3dIPlottable2dMixin(HasTraits): name = DelegatesTo("adaptee") - x_data = Property(Array, depends_on="adaptee.points, x_label") - y_data = Property(Array, depends_on="adaptee.points, y_label") + x_data = Property(Array, observe="adaptee.points, x_label") + y_data = Property(Array, observe="adaptee.points, y_label") x_label = Trait("x", {"x": 0, "y": 1, "z": 2}) y_label = Trait("y", {"x": 0, "y": 1, "z": 2}) diff --git a/envisage/examples/demo/plugins/tasks/attractors/model/lorenz.py b/envisage/examples/demo/plugins/tasks/attractors/model/lorenz.py index 0be19249b..3be70bdc9 100644 --- a/envisage/examples/demo/plugins/tasks/attractors/model/lorenz.py +++ b/envisage/examples/demo/plugins/tasks/attractors/model/lorenz.py @@ -31,8 +31,7 @@ class Lorenz(HasTraits): name = Str("Lorenz Attractor") points = Property( - Array, - depends_on=["prandtl", "rayleigh", "beta", "initial_point", "times"], + Array, observe="prandtl, rayleigh, beta, initial_point, times" ) #### 'Lorenz' interface ################################################### @@ -47,7 +46,7 @@ class Lorenz(HasTraits): time_start = Float(0.0) time_stop = Float(100.0) time_step = Float(0.01) - times = Property(Array, depends_on="time_start, time_stop, time_step") + times = Property(Array, observe="time_start, time_stop, time_step") # Configuration view. view = View( diff --git a/envisage/examples/demo/plugins/tasks/attractors/model/rossler.py b/envisage/examples/demo/plugins/tasks/attractors/model/rossler.py index 988d9bd1c..b282b34ad 100644 --- a/envisage/examples/demo/plugins/tasks/attractors/model/rossler.py +++ b/envisage/examples/demo/plugins/tasks/attractors/model/rossler.py @@ -30,7 +30,7 @@ class Rossler(HasTraits): #### 'IModel3d' interface ################################################# name = Str("Rossler Attractor") - points = Property(Array, depends_on=["a, b, c, initial_point, times"]) + points = Property(Array, observe="a, b, c, initial_point, times") #### 'Rossler' interface ################################################## @@ -44,7 +44,7 @@ class Rossler(HasTraits): time_start = Float(0.0) time_stop = Float(100.0) time_step = Float(0.01) - times = Property(Array, depends_on="time_start, time_stop, time_step") + times = Property(Array, observe="time_start, time_stop, time_step") # Configuration view. view = View( diff --git a/envisage/examples/demo/plugins/tasks/attractors/model_help_pane.py b/envisage/examples/demo/plugins/tasks/attractors/model_help_pane.py index 9f520c208..d8726bf4b 100644 --- a/envisage/examples/demo/plugins/tasks/attractors/model_help_pane.py +++ b/envisage/examples/demo/plugins/tasks/attractors/model_help_pane.py @@ -24,7 +24,7 @@ class ModelHelpPane(TraitsDockPane): model = Instance(HasTraits) - html = Property(Str, depends_on="model") + html = Property(Str, observe="model") view = View( Item( diff --git a/envisage/examples/demo/plugins/tasks/attractors/plot_2d_pane.py b/envisage/examples/demo/plugins/tasks/attractors/plot_2d_pane.py index d7b073692..102010d8a 100644 --- a/envisage/examples/demo/plugins/tasks/attractors/plot_2d_pane.py +++ b/envisage/examples/demo/plugins/tasks/attractors/plot_2d_pane.py @@ -28,12 +28,12 @@ class Plot2dPane(TraitsTaskPane): active_model = Instance(IPlottable2d) models = List(IPlottable2d) - plot_type = Property(Str, depends_on="active_model.plot_type") - title = Property(Str, depends_on="active_model.name") - x_data = Property(depends_on="active_model.x_data") - y_data = Property(depends_on="active_model.y_data") - x_label = Property(Str, depends_on="active_model.x_label") - y_label = Property(Str, depends_on="active_model.y_label") + plot_type = Property(Str, observe="active_model.plot_type") + title = Property(Str, observe="active_model.name") + x_data = Property(observe="active_model.x_data") + y_data = Property(observe="active_model.y_data") + x_label = Property(Str, observe="active_model.x_label") + y_label = Property(Str, observe="active_model.y_label") view = View( HGroup( diff --git a/envisage/plugins/python_shell/view/namespace_view.py b/envisage/plugins/python_shell/view/namespace_view.py index 44005b209..9f5bae804 100644 --- a/envisage/plugins/python_shell/view/namespace_view.py +++ b/envisage/plugins/python_shell/view/namespace_view.py @@ -100,7 +100,7 @@ class NamespaceView(View): # The bindings in the namespace. This is a list of HasTraits objects with # 'name', 'type' and 'module' string attributes. - bindings = Property(List, depends_on=["namespace"]) + bindings = Property(List, observe="namespace") shell_view = Instance(PythonShellView) diff --git a/envisage/ui/tasks/action/task_window_toggle_group.py b/envisage/ui/tasks/action/task_window_toggle_group.py index 09caf3e9a..f03550f97 100644 --- a/envisage/ui/tasks/action/task_window_toggle_group.py +++ b/envisage/ui/tasks/action/task_window_toggle_group.py @@ -18,7 +18,7 @@ class TaskWindowToggleAction(Action): #### 'Action' interface ################################################### - name = Property(Str, depends_on="window.active_task.name") + name = Property(Str, observe="window.active_task.name") style = "toggle" #### 'TaskWindowToggleAction' interface ################################### diff --git a/envisage/ui/tasks/task_window.py b/envisage/ui/tasks/task_window.py index 7206321d6..52922421f 100644 --- a/envisage/ui/tasks/task_window.py +++ b/envisage/ui/tasks/task_window.py @@ -23,7 +23,7 @@ class TaskWindow(PyfaceTaskWindow): #: The window's icon. We override it so it can delegate to the application #: icon if the window's icon is not set. - icon = Property(Instance(ImageResource), depends_on="_icon") + icon = Property(Instance(ImageResource), observe="_icon") #### Protected interface ################################################## diff --git a/examples/legacy/plugins/tasks/ipython_kernel/example_task.py b/examples/legacy/plugins/tasks/ipython_kernel/example_task.py index 6efec4b5b..7982c67f8 100644 --- a/examples/legacy/plugins/tasks/ipython_kernel/example_task.py +++ b/examples/legacy/plugins/tasks/ipython_kernel/example_task.py @@ -39,7 +39,7 @@ class ExampleTask(Task): name = "Multi-Tab Editor" active_editor = Property( - Instance(IEditor), depends_on="editor_area.active_editor" + Instance(IEditor), observe="editor_area.active_editor" ) editor_area = Instance(IEditorAreaPane) diff --git a/examples/legacy/plugins/tasks/ipython_kernel/python_editor.py b/examples/legacy/plugins/tasks/ipython_kernel/python_editor.py index ca060cea4..5282c0159 100644 --- a/examples/legacy/plugins/tasks/ipython_kernel/python_editor.py +++ b/examples/legacy/plugins/tasks/ipython_kernel/python_editor.py @@ -27,9 +27,9 @@ class PythonEditor(Editor): dirty = Bool(False) - name = Property(Str, depends_on="path") + name = Property(Str, observe="path") - tooltip = Property(Str, depends_on="path") + tooltip = Property(Str, observe="path") show_line_numbers = Bool(True)