Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b95d1c

Browse files
committed
Merge pull request kivy-garden#6 from andnovar/development
example modified for a safer way to add widgets to a kivy app.
2 parents a0166a1 + ab32b65 commit 8b95d1c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/test_backend.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import matplotlib
2+
matplotlib.use('module://kivy.garden.matplotlib.backend_kivy')
13
from matplotlib.figure import Figure
24
from numpy import arange, sin, pi
35
from kivy.app import App
@@ -85,10 +87,6 @@ def autolabel(rects):
8587
ax.text(rect.get_x() + rect.get_width() / 2., 1.05 * height,
8688
'%d' % int(height), ha='center', va='bottom')
8789

88-
canvas = FigureCanvas(figure=fig)
89-
# canvas.blit(Bbox(np.array([[0, 0], [400, 400]], np.int32)))
90-
canvas2 = FigureCanvas(figure=fig2)
91-
9290
fig.canvas.mpl_connect('button_press_event', press)
9391
fig.canvas.mpl_connect('button_release_event', release)
9492
fig.canvas.mpl_connect('key_press_event', keypress)
@@ -111,6 +109,10 @@ def autolabel(rects):
111109
fig2.canvas.mpl_connect('figure_leave_event', figure_leave)
112110
fig2.canvas.mpl_connect('close_event', close)
113111

112+
canvas = fig.canvas
113+
# canvas.blit(Bbox(np.array([[0, 0], [400, 400]], np.int32)))
114+
canvas2 = fig2.canvas
115+
114116

115117
def callback(instance):
116118
autolabel(rects1)

0 commit comments

Comments
 (0)