<div dir="ltr">Works for me on macOS 10.12.2, Python 3.5.2 (conda-forge) and matplotlib 2.0rc2.<div><br></div><div>Ryan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 10, 2017 at 12:48 AM, Scott Lasley <span dir="ltr"><<a href="mailto:selasley@icloud.com" target="_blank">selasley@icloud.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I get the error when running under python3.6 and scrolling with the trackpad.<br>
OS X 10.12.2 with the system installed Tk version 8.5, python 3.6.0, matplotlib 2.0.0rc2+2939.g109251f<br>
<span class=""><br>
Traceback (most recent call last):<br>
</span>  File "<stdin>", line 1, in <module><br>
  File "/Library/Frameworks/Python.<wbr>framework/Versions/3.6/lib/<wbr>python3.6/site-packages/<wbr>matplotlib/pyplot.py", line 252, in show<br>
    return _show(*args, **kw)<br>
  File "/Library/Frameworks/Python.<wbr>framework/Versions/3.6/lib/<wbr>python3.6/site-packages/<wbr>matplotlib/backend_bases.py", line 188, in __call__<br>
    self.mainloop()<br>
  File "/Library/Frameworks/Python.<wbr>framework/Versions/3.6/lib/<wbr>python3.6/site-packages/<wbr>matplotlib/backends/backend_<wbr>tkagg.py", line 71, in mainloop<br>
    Tk.mainloop()<br>
  File "/Library/Frameworks/Python.<wbr>framework/Versions/3.6/lib/<wbr>python3.6/tkinter/__init__.py"<wbr>, line 557, in mainloop<br>
<span class="">    _default_root.tk.mainloop(n)<br>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte<br>
>>> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte<br>
<br>
<br>
</span>The script works when run under python 2.7.13 and scrolling with the trackpad.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
> On Jan 9, 2017, at 23:40, Thomas Caswell <<a href="mailto:tcaswell@gmail.com">tcaswell@gmail.com</a>> wrote:<br>
><br>
> I can not reproduce this on linux :/<br>
><br>
> This looks like it is coming out of Tk's handling of the scroll event before it is handed off to mpl.<br>
><br>
> Tom<br>
><br>
> On Mon, Jan 9, 2017 at 10:28 PM Juan Nunez-Iglesias <<a href="mailto:jni.soma@gmail.com">jni.soma@gmail.com</a>> wrote:<br>
> Hi all,<br>
><br>
> I’m trying to play with the `basic_mpl_connect.py` example from Ben Root’s “Interactive Applications Using Matplotlib” book, reproduced below in its entirety. (With the addition of selecting TkAgg as the backend. I need to do this because I’m aiming to embed into a Tk app *and* the MacOSX backend doesn’t capture my keystrokes.)<br>
><br>
> Everything works fine, but when I try to use the scroll wheel on my mouse, or two-finger scrolling on my Macbook trackpad, everything dies with the following message:<br>
><br>
> Traceback (most recent call last):<br>
>   File "basic_mpl_connect.py", line 20, in <module><br>
>     plt.show()<br>
>   File "/Users/jni/conda/envs/ana/<wbr>lib/python3.5/site-packages/<wbr>matplotlib/pyplot.py", line 252, in show<br>
>     return _show(*args, **kw)<br>
>   File "/Users/jni/conda/envs/ana/<wbr>lib/python3.5/site-packages/<wbr>matplotlib/backend_bases.py", line 192, in __call__<br>
>     self.mainloop()<br>
>   File "/Users/jni/conda/envs/ana/<wbr>lib/python3.5/site-packages/<wbr>matplotlib/backends/backend_<wbr>tkagg.py", line 74, in mainloop<br>
>     Tk.mainloop()<br>
>   File "/Users/jni/conda/envs/ana/<wbr>lib/python3.5/tkinter/__init__<wbr>.py", line 405, in mainloop<br>
>     _default_root.tk.mainloop(n)<br>
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte<br>
><br>
> This is true even if I explicitly connect the “scroll_event” (below).<br>
><br>
> Any ideas?<br>
><br>
> Thanks,<br>
><br>
> Juan.<br>
><br>
> ==============================<wbr>=====<br>
><br>
> import matplotlib<br>
> matplotlib.use('TkAgg')<br>
> matplotlib.verbose.level = 'debug'<br>
> import matplotlib.pyplot as plt<br>
><br>
> def process_key(event):<br>
>     print("Key:", event.key)<br>
><br>
> def process_button(event):<br>
>     print("Button:", event.x, event.y, event.xdata, event.ydata, event.button)<br>
><br>
> def process_scroll(event):<br>
>     print("Scroll")<br>
><br>
> fig, ax = plt.subplots(1, 1)<br>
> fig.canvas.mpl_connect('key_<wbr>press_event', process_key)<br>
> fig.canvas.mpl_connect('<wbr>button_press_event', process_button)<br>
> fig.canvas.mpl_connect('<wbr>scroll_event', process_scroll)<br>
> plt.show()<br>
> ______________________________<wbr>_________________<br>
> Matplotlib-users mailing list<br>
> <a href="mailto:Matplotlib-users@python.org">Matplotlib-users@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/matplotlib-<wbr>users</a><br>
> ______________________________<wbr>_________________<br>
> Matplotlib-users mailing list<br>
> <a href="mailto:Matplotlib-users@python.org">Matplotlib-users@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/matplotlib-<wbr>users</a><br>
<br>
______________________________<wbr>_________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/matplotlib-<wbr>users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Ryan May<br><br></div></div></div>
</div>