From 223d3aa2e4445cb5c951991ca0c9d58e7868cea9 Mon Sep 17 00:00:00 2001 From: Midhun PM Date: Fri, 27 Dec 2019 10:45:30 -0600 Subject: [PATCH 1/2] Do not expose 'auto' for infinite series --- examples/demo/functionplotter.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/demo/functionplotter.py b/examples/demo/functionplotter.py index 603dd1b0b..348213ba9 100644 --- a/examples/demo/functionplotter.py +++ b/examples/demo/functionplotter.py @@ -9,8 +9,8 @@ # Enthought library imports from enable.api import Component, ComponentEditor -from traits.api import HasTraits, Instance, Int -from traitsui.api import Item, Group, HGroup, View +from traits.api import HasTraits, Instance, Int, Enum +from traitsui.api import Item, Group, HGroup, View, TextEditor # Chaco imports from chaco.api import ScatterPlot, DataView, LinePlot @@ -22,18 +22,25 @@ class PlotExample(HasTraits): plot = Instance(Component) numpoints = Int(500) + low_mode = Enum("value", "track") + high_mode = Enum("value", "track") + + traits_view = View( Group( Item('plot', editor=ComponentEditor(), show_label=False), HGroup( HGroup( - Item('object.plot.x_mapper.range.low_setting', label='Low'), - Item('object.plot.x_mapper.range.high_setting', label='High'), + Item('object.plot.x_mapper.range.low_setting', label='Low', editor=TextEditor(), visible_when='object.low_mode == "value" ', ), + Item('low_mode', label='Low Mode'), + Item('object.plot.x_mapper.range.high_setting', label='High', editor=TextEditor(), visible_when='object.high_mode == "value" '), + Item('high_mode', label='High Mode'), + Item('object.plot.x_mapper.range.tracking_amount', label='Tracking Amount', editor=TextEditor(read_only=True), visible_when='object.high_mode == "track" or object.low_mode == "track"'), label='X', show_border=True ), HGroup( - Item('object.plot.y_mapper.range.low_setting', label='Low'), - Item('object.plot.y_mapper.range.high_setting', label='High'), + Item('object.plot.y_mapper.range.low_setting', label='Low', editor=TextEditor()), + Item('object.plot.y_mapper.range.high_setting', label='High', editor=TextEditor()), label='Y', show_border=True ), ), @@ -51,6 +58,14 @@ def yfunc(self, low, high): x = self.xfunc(low, high) return sin(1.0/x) + def _low_mode_changed(self, newvalue): + if newvalue != "value": + self.plot.x_mapper.range.low_setting = newvalue + + def _high_mode_changed(self, newvalue): + if newvalue != "value": + self.plot.x_mapper.range.high_setting = newvalue + def _plot_default(self): container = DataView() From 3b91e3f6d9fa9111824d6f3565bd04a58c3fc9c0 Mon Sep 17 00:00:00 2001 From: Midhun PM Date: Mon, 30 Dec 2019 09:45:29 -0600 Subject: [PATCH 2/2] flake8 Fix source code line lengths --- examples/demo/functionplotter.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/examples/demo/functionplotter.py b/examples/demo/functionplotter.py index 348213ba9..4f3d4e9f4 100644 --- a/examples/demo/functionplotter.py +++ b/examples/demo/functionplotter.py @@ -31,16 +31,26 @@ class PlotExample(HasTraits): Item('plot', editor=ComponentEditor(), show_label=False), HGroup( HGroup( - Item('object.plot.x_mapper.range.low_setting', label='Low', editor=TextEditor(), visible_when='object.low_mode == "value" ', ), + Item('object.plot.x_mapper.range.low_setting', label='Low', + editor=TextEditor(), + visible_when='object.low_mode == "value" ', ), Item('low_mode', label='Low Mode'), - Item('object.plot.x_mapper.range.high_setting', label='High', editor=TextEditor(), visible_when='object.high_mode == "value" '), + Item('object.plot.x_mapper.range.high_setting', + label='High', editor=TextEditor(), + visible_when='object.high_mode == "value" '), Item('high_mode', label='High Mode'), - Item('object.plot.x_mapper.range.tracking_amount', label='Tracking Amount', editor=TextEditor(read_only=True), visible_when='object.high_mode == "track" or object.low_mode == "track"'), + Item('object.plot.x_mapper.range.tracking_amount', + label='Tracking Amount', + editor=TextEditor(read_only=True), + visible_when='object.high_mode == "track" or ' + 'object.low_mode == "track"'), label='X', show_border=True ), HGroup( - Item('object.plot.y_mapper.range.low_setting', label='Low', editor=TextEditor()), - Item('object.plot.y_mapper.range.high_setting', label='High', editor=TextEditor()), + Item('object.plot.y_mapper.range.low_setting', + label='Low', editor=TextEditor()), + Item('object.plot.y_mapper.range.high_setting', + label='High', editor=TextEditor()), label='Y', show_border=True ), ), @@ -93,7 +103,8 @@ def _plot_default(self): color = "lightgray") container.add(plot2, plot) - plot.tools.append(PanTool(plot, constrain_direction="x", constrain=True)) + plot.tools.append(PanTool(plot, constrain_direction="x", + constrain=True)) plot.tools.append(ZoomTool(plot, axis="index", tool_mode="range")) return container