I wanted to put my live plotting app into a nice gtk3 programm and so far I got this but it doesn't show a window. What am I missing? Thanks in advance!
import serial
import numpy as np
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
from gi.repository import Gtk
class MyWindow(Gtk.ApplicationWindow):
def __init__(self):
Gtk.Window.__init__(self, title="Toolbar Example")
self.set_size_request(700, 500)
self.box = Gtk.Box(spacing=6, orientation=Gtk.Orientation.VERTICAL)
self.add(self.box)
fig = Figure()
ax = fig.add_subplot(111)
ax.set_xlim(0, 50)
ax.set_ylim(0, 20)
ydata = [0] * 50
line, = ax.plot(ydata, label='ydata')
ax.legend()
f = FigureCanvas(fig)
self.box.pack_start(f, True, True, 0)
while True:
ydata.append(10)
line.set_data(np.arange(len(ydata)), ydata)
f.draw()
win = MyWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()