Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError exception in drag_zoom (tk backend) #1944

Merged
merged 2 commits into from Jun 11, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Jun 5, 2013

I have an application that uses Tkinter and matplotlib 1.1.1rc to visualize some plots and axvspans. From time to time, when I drag the plot in pan mode I've got this Exception and I should kill the application:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
    return self.func(*args)
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 271, in motion_notify_event
    FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
  File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 1681, in motion_notify_event
    self.callbacks.process(s, event)
  File "/usr/lib/pymodules/python2.7/matplotlib/cbook.py", line 262, in process
    proxy(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/cbook.py", line 192, in __call__
    return mtd(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 2660, in drag_zoom
    lastx, lasty, a, ind, lim, trans = self._xypress[0]
ValueError: need more than 2 values to unpack

It does not happen always, only from time to time so it makes difficult to reproduce it.

@pelson
Copy link
Member

pelson commented Apr 25, 2013

It does not happen always, only from time to time so it makes difficult to reproduce it.

Hmmm. I use the tk backend all the time and haven't seen this issue. Are you using specific Artist type or projection? Anything that might make it easier to reproduce will be valuable, otherwise I fear we might struggle to fix this one.

@marblestation
Copy link
Author

After some days testing version 1.2, I'm not able to reproduce this bug anymore. Maybe we can just close this issue.

@mdboom mdboom closed this May 6, 2013
@pelson
Copy link
Member

pelson commented May 8, 2013

After some days testing version 1.2, I'm not able to reproduce this bug anymore.

Ok thanks @marblestation. If you ever come across it again (or anybody else does) we can re-open and (hopefully) reproduce.

Cheers,

@lyvic
Copy link

lyvic commented Jun 5, 2013

I encountered the same problem and could reproduce it (by chance):
mplve
The environment where this happend was the following:
A GUI created with Tkinter:

import matplotlib
import ttk
matplotlib.use('TkAgg')
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import Tkinter as tki

If I plot something and start with the zoom-Tool, left-click and start drawing that rectangle to select the area where it should zoom into, but then cancel it by clicking right at the same time and releasing both buttons (nothing happens). Then changing to the pan_tool and trying to move the picture...brings up this error repeatedly.
I'm using 1.2.1 now, it happened with 0.98.0 as well.
It's avoidable by not left-right-clicking while zooming, but it seems to be a common issue that people start draging and realising this is not what they want to do, so they try to escape their action by right clicking but then end up with the above problem

@mdboom
Copy link
Member

mdboom commented Jun 5, 2013

@lyvic: Thanks so much for this investigation and the clear explanation. I can reproduce it now and will look into a fix.

@mdboom mdboom reopened this Jun 5, 2013
@ghost ghost assigned mdboom Jun 5, 2013
…l" rather than putting us in an unresolved state.
@mdboom
Copy link
Member

mdboom commented Jun 5, 2013

@marblestation , @lyvic: Can you confirm that the attached patch resolves your problem?

@mdboom
Copy link
Member

mdboom commented Jun 5, 2013

Note to self: backport this to 1.2.x

@lyvic
Copy link

lyvic commented Jun 5, 2013

@mdboom I would love to, but I'm a little overwhelmed here. First contact with OOP and Python was about two months ago.
I inserted the lines you added into the backend_bases.py of 1.2.1 and it workes somewhat.
Switching back and forth between zooming and panning works. Once I right-blick-cancel the rectangle selection is killed, not canceled. I can't zoom rect anymore.
Panning works fine. I'm using the buttons on the toolbar
self.toolbar = NavigationToolbar2TkAgg(self.Paper, self.toolbarframe)
So interrupting the rectangle now works, switching to pan-tool works. Switching back to zoom is not possible. Only restarting my program helps.

if self._ids_zoom != []:
for zoom_id in self._ids_zoom:
self.canvas.mpl_disconnect(zoom_id)
self.zoom()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be here a self._ids_zoom = [] line, to allow switching back to zoom again (addressing @lyvic comment).

@mdboom
Copy link
Member

mdboom commented Jun 10, 2013

Thanks. I think I have it working so that the zoom rectangle continues to work, even after a cancel.

mdboom added a commit that referenced this pull request Jun 11, 2013
ValueError exception in drag_zoom (tk backend)
@mdboom mdboom merged commit ddf2c57 into matplotlib:v1.3.x Jun 11, 2013
mdboom added a commit that referenced this pull request Jun 11, 2013
ValueError exception in drag_zoom (tk backend)
@lyvic
Copy link

lyvic commented Jun 12, 2013

Great! Thanks for solving this.

@mdboom mdboom deleted the cancel-zoom branch August 7, 2014 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants