Hi all,
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.)
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:
Traceback (most recent call last):
? File "basic_mpl_connect.py", line 20, in <module>
? ? plt.show()
? File "/Users/jni/conda/envs/ana/lib/python3.5/site-packages/matplotlib/pyplot.py", line 252, in show
? ? return _show(*args, **kw)
? File "/Users/jni/conda/envs/ana/lib/python3.5/site-packages/matplotlib/backend_bases.py", line 192, in __call__
? ? self.mainloop()
? File "/Users/jni/conda/envs/ana/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 74, in mainloop
? ? Tk.mainloop()
? File "/Users/jni/conda/envs/ana/lib/python3.5/tkinter/__init__.py", line 405, in mainloop
? ? _default_root.tk.mainloop(n)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
This is true even if I explicitly connect the ?scroll_event? (below).
Any ideas?
Thanks,
Juan.
···
===================================
import matplotlib
matplotlib.use('TkAgg')
matplotlib.verbose.level = 'debug'
import matplotlib.pyplot as plt
def process_key(event):
? ? print("Key:", event.key)
def process_button(event):
? ? print("Button:", event.x, event.y, event.xdata, event.ydata, event.button)
def process_scroll(event):
? ? print("Scroll")
fig, ax = plt.subplots(1, 1)
fig.canvas.mpl_connect('key_press_event', process_key)
fig.canvas.mpl_connect('button_press_event', process_button)
fig.canvas.mpl_connect('scroll_event', process_scroll)
plt.show()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170110/d8fa8a73/attachment.html>