chaco tools: signals ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

chaco tools: signals ?

Barth
Hello,

I am using chaco to develop tools for data analysis. In the plots i draw, i
use both the ZoomTool and the PanTool.
I am also using an external window ( based on QtGui) to control more
precisely the plots. There i have some lineedit that allow me to specify
exactly the index_range and value_range with function of the type:

class AxisWin(QtGui.QDialog):
...
...

   #Communication Chaco Plot -----> QtGUi
    def update_plot_range_linedit(self):
            self.x_axis_min.setText(str(self.plot.x_mapper.range.low))
            self.x_axis_max.setText(str(self.plot.x_mapper.range.high))
            self.y_axis_min.setText(str(self.plot.y_mapper.range.low))
            self.y_axis_max.setText(str(self.plot.y_mapper.range.high))
   #Communication QtGui --------> Chaco Plot
    def update_plot_range(self):
            self.plot.x_mapper.range.low=float(self.x_axis_min.text())
            self.plot.x_mapper.range.high=float(self.x_axis_max.text())
            self.plot.y_mapper.range.low=float(self.y_axis_min.text())
            self.plot.y_mapper.range.high=float(self.y_axis_max.text())

My question is: is there a way to connect these functions to some signal of
the ZoomTool and PanTool, so that when i use them, it automatically tells
to the Gui to update the lineedit values ?
Is there a signal emitted by the ZoomTool that i could connect to these
functions ?

Pierre
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: chaco tools: signals ?

Robert Kern
On Tue, Mar 6, 2012 at 3:55 PM, Pierre Barthelemy <[hidden email]> wrote:

> Hello,
>
> I am using chaco to develop tools for data analysis. In the plots i draw, i
> use both the ZoomTool and the PanTool.
> I am also using an external window ( based on QtGui) to control more
> precisely the plots. There i have some lineedit that allow me to specify
> exactly the index_range and value_range with function of the type:
>
> class AxisWin(QtGui.QDialog):
> ...
> ...
>
>   #Communication Chaco Plot -----> QtGUi
>    def update_plot_range_linedit(self):
>            self.x_axis_min.setText(str(self.plot.x_mapper.range.low))
>            self.x_axis_max.setText(str(self.plot.x_mapper.range.high))
>            self.y_axis_min.setText(str(self.plot.y_mapper.range.low))
>            self.y_axis_max.setText(str(self.plot.y_mapper.range.high))
>   #Communication QtGui --------> Chaco Plot
>    def update_plot_range(self):
>            self.plot.x_mapper.range.low=float(self.x_axis_min.text())
>            self.plot.x_mapper.range.high=float(self.x_axis_max.text())
>            self.plot.y_mapper.range.low=float(self.y_axis_min.text())
>            self.plot.y_mapper.range.high=float(self.y_axis_max.text())
>
> My question is: is there a way to connect these functions to some signal of
> the ZoomTool and PanTool, so that when i use them, it automatically tells
> to the Gui to update the lineedit values ?
> Is there a signal emitted by the ZoomTool that i could connect to these
> functions ?

Listen to the .updated trait on the DataRange1Ds. Just be sure to
guard against updating the QLineEdits when you do that otherwise you
will get a cycle.

def update_plot_range_linedit(self):
    if not self._updating_ranges:
        ...

def update_plot_range(self):
    self._updating_ranges = True
    try:
        ...
    finally:
        self._updating_ranges = False

--
Robert Kern
Enthought
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev