How to embed python tkinter window into a browser? How to embed python tkinter window into a browser? tkinter tkinter

How to embed python tkinter window into a browser?


Based on Joe Kington's answer to a similar question, the backend mplh5canvas is possibly what you are looking for. Adapting your example code to work with it,

import numpy as npimport matplotlibimport mplh5canvasmatplotlib.use('module://mplh5canvas.backend_h5canvas')import matplotlib.cbook as cbookimport matplotlib.image as imageimport matplotlib.pyplot as pltfig = plt.figure()ax = fig.add_subplot(111)ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=0.7, mfc='orange')ax.grid()plt.show(open_plot=True)

It seems to work well with the kind of interactivity you are looking for, even allowing animation. Having said that, it doesn't support every browser, as described in it's installation wiki page. If it is acceptable to restrict use to Chrome, Safari or Opera (in this case with some configuration, check that page) then it should suit you well, though might need some experimentation as well.