[IPython-dev] Text output from matplotlib event not shown

MinRK benjaminrk at gmail.com
Fri Apr 18 14:34:53 EDT 2014


There's definitely a chance for fixing this in 2.x. I'll try to work on it
this week.


On Fri, Apr 18, 2014 at 11:22 AM, Antonino Ingargiola <tritemio at gmail.com>wrote:

> Unfortunately I have distributed several notebooks that, due to this
> regression, don't work anymore once the user upgrade to 2.0.
>
> Any hope this can be fixed in a 2.x release?
>
> Or, is there is any workaround that does not involve modifying the
> notebook code? The plot function is loaded from a python file, I can change
> this but I would rather not change the notebook? In principle I could
> adding something like get_range() in the notebook for each range selection,
> but this would spoil the purpose of an interactive range selection.
>
> Thanks,
> Antonio
>
>
> On Fri, Apr 18, 2014 at 10:32 AM, MinRK <benjaminrk at gmail.com> wrote:
>
>> This is open as a GitHub Issue<https://github.com/ipython/ipython/issues/5407>.
>> As a result of cleaning up data structures when we think we are done, async
>> output is lost.
>>
>> -MinRK
>>
>>
>> On Thu, Apr 17, 2014 at 11:56 PM, Antonino Ingargiola <tritemio at gmail.com
>> > wrote:
>>
>>> For the record, I tried running the plot from a qtconsole and the text
>>> output is correctly printed. So it is a notebook specific issue.
>>>
>>> Antonio
>>>
>>>
>>> On Thu, Apr 17, 2014 at 10:57 PM, Antonino Ingargiola <
>>> tritemio at gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> in IPython Notebook 1.x I built some QT matplotlib plots that allow to
>>>> select a range (with the mouse) and print to the range boundaries, or
>>>> related information.
>>>>
>>>>  To do that I connect a callback to the standard matplotlib events. The
>>>> callback draws a range highlight and prints the range info.
>>>>
>>>> In IPython 2.0 I can't get the print output anymore, although the range
>>>> is drawn and therefore I'm sure the callback is called. I thought that the
>>>> issue can be related to:
>>>>
>>>> https://github.com/ipython/ipython/issues/5408
>>>>
>>>> If this is the same issue, are they any workaround I can use to get the
>>>> output back?
>>>>
>>>> For completeness I attach the main class I use for the interactive
>>>> range selection:
>>>>
>>>> class GuiSelection(object):
>>>>     """Abstract class for range selection.
>>>>
>>>>     Methods on_press_draw(), on_motion_draw() and on_release_print()
>>>> must
>>>>     be overloaded by children classes.
>>>>     """
>>>>     def __init__(self, fig, ax, debug=False):
>>>>         self.ax = ax
>>>>         self.fig = fig
>>>>         self.pressed = False
>>>>         self.debug = debug
>>>>         self.id_press = fig.canvas.mpl_connect('button_press_event',
>>>>                                                 self.on_press)
>>>>         if self.debug:
>>>>             print 'Figure:', fig, '\nAxis:', ax
>>>>     def on_press(self, event):
>>>>         if event.inaxes != self.ax: return
>>>>         self.pressed = True
>>>>         self.xs, self.ys = event.xdata, event.ydata
>>>>         if self.debug:
>>>>             pprint('PRESS button=%d, x=%d, y=%d, xdata=%f, ydata=%f\n'
>>>> % (
>>>>                 event.button, event.x, event.y, event.xdata,
>>>> event.ydata))
>>>>         self.on_press_draw()
>>>>         self.fig.canvas.draw()
>>>>         self.id_motion =
>>>> self.fig.canvas.mpl_connect('motion_notify_event',
>>>>                                                      self.on_motion)
>>>>         self.fig.canvas.mpl_connect('button_release_event',
>>>>                                              self.on_release)
>>>>
>>>>     def on_motion(self, event):
>>>>         if event.inaxes != self.ax: return
>>>>         if self.debug:
>>>>             pprint('MOTION x=%d, y=%d, xdata=%f, ydata=%f\n' % (
>>>>                 event.x, event.y, event.xdata, event.ydata))
>>>>         self.xe, self.ye = event.xdata, event.ydata
>>>>         self.on_motion_draw()
>>>>         self.fig.canvas.draw()
>>>>
>>>>     def on_release(self, event):
>>>>         if not self.pressed: return
>>>>         self.pressed = False
>>>>         if self.debug:
>>>>             pprint('RELEASE button=%d, x=%d, y=%d, xdata=%f,
>>>> ydata=%f\n' % (
>>>>                 event.button, event.x, event.y, event.xdata,
>>>> event.ydata))
>>>>         self.fig.canvas.mpl_disconnect(self.id_motion)
>>>>         self.on_release_print()
>>>>
>>>>     def on_press_draw(self):
>>>>         pass
>>>>
>>>>     def on_motion_draw(self):
>>>>         pass
>>>>
>>>>     def on_release_print(self):
>>>>         pass
>>>>
>>>>
>>>
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>
>>>
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140418/8a4bdb96/attachment.html>


More information about the IPython-dev mailing list