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

COMPAT: use tkagg backend on PyPy #9356

Merged
merged 12 commits into from Jan 12, 2018

Merge branch 'master' into tkagg-cffi

  • Loading branch information...
mattip committed Jan 11, 2018
commit 43d975499db443d9e3bbce44f3904fcb2eb3f81e
@@ -4,17 +4,18 @@
===============
"""
import matplotlib
matplotlib.use('TkAgg')
import numpy as np
from six.moves import tkinter as Tk
from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2TkAgg)
# Implement the default Matplotlib key bindings.
from matplotlib.backend_bases import key_press_handler
from matplotlib.figure import Figure
from six.moves import tkinter as Tk
import numpy as np
root = Tk.Tk()
root.wm_title("Embedding in Tk")
@@ -31,17 +32,21 @@
toolbar.update()
canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
canvas.mpl_connect(
"key_press_event", lambda event: print("you pressed {}".format(event.key)))
canvas.mpl_connect(
"key_press_event", lambda event: key_press_handler(event, canvas, toolbar))
def on_key_press(event):
print("you pressed {}".format(event.key))
key_press_handler(event, canvas, toolbar)
canvas.mpl_connect("key_press_event", on_key_press)
def _quit():
root.quit() # stops mainloop
root.destroy() # this is necessary on Windows to prevent
# Fatal Python Error: PyEval_RestoreThread: NULL tstate
button = Tk.Button(master=root, text="Quit", command=_quit)
button.pack(side=Tk.BOTTOM)
You are viewing a condensed version of this merge commit. You can view the full changes here.
ProTip! Use n and p to navigate between commits in a pull request.