Discussion:
How-to "do_pan_view"
cormorant
2011-04-06 07:05:34 UTC
Permalink
Hi! I want to move canvas in my program, for example by pressing arrow
keys. The problem is: I write:
self.curvewidget.plot.do_pan_view((0, 300), (0, 0))
where self.curvewidget is CurveWidget itself.
Arguments are "two tuples composed of (initial pos, dest pos)" --
isnt't it?
But result is:
Traceback (most recent call last):
File "./qwtNadv.py", line 581, in test
self.curvewidget.plot.do_pan_view((10,300),(10,10))
File "/usr/local/lib/python2.6/dist-packages/guiqwt/curve.py", line
1025, in do_pan_view
for (x1, x0, _, w), k in active_axes:
ValueError: need more than 2 values to unpack

Thanks in advance
Ludovic Aubry
2011-04-15 19:05:39 UTC
Permalink
Hi,

Actually the docstring is inexact.

If you look into events.py you'll see that
do_pan_view is called from there and gets its dx,dy from :

get_move_state:
rct = filter.plot.contentsRect()
dx = (pos.x(), self.last.x(), self.start.x(), rct.width())

so it should be : (new_pos, last_pos, starting_pos,
plot_width_or_height) for each axis.

Also note that this function is really intended for mouse
manipulation.

You would be better off using something along :

set_axis_limits("bottom", xmin+delta, xmax+delta)
Post by cormorant
Hi! I want to move canvas in my program, for example by pressing arrow
self.curvewidget.plot.do_pan_view((0, 300), (0, 0))
where self.curvewidget is CurveWidget itself.
Arguments are "two tuples composed of (initial pos, dest pos)" --
isnt't it?
  File "./qwtNadv.py", line 581, in test
    self.curvewidget.plot.do_pan_view((10,300),(10,10))
  File "/usr/local/lib/python2.6/dist-packages/guiqwt/curve.py", line
1025, in do_pan_view
ValueError: need more than 2 values to unpack
Thanks in advance
Loading...