[Matplotlib-users] matplotlib in GTK3 - interactive window while not calling Gtk.main()
tcaswell at gmail.com
Fri Apr 27 20:45:53 EDT 2018
If you are doing custom embedding I suggest staying away from `pyplot`
altogether, it maintains global state you may not want, see for example
For the long answer to your question, see
https://github.com/matplotlib/matplotlib/pull/4779 (which I really need to
finish and get merged). In short, to have both an interactive prompt and a
window you need to have an 'input hook' installed to time-share between the
GUI event loop an the prompt event loop. It sounds like you change a bunch
of things at once (gtk2 -> gtk3 + matplotlib version bumps), did you also
change IPython versions? If so, you will need to use their input hook
mechanism explicitly (`%matplotlib gtk3` should do the trick) as they moved
from readline -> ptprompt so the input hooks the GUI libraries ship no
It may also be worth checking the value of `mpl.get_backend()` to make sure
pyplot as not defaulted to another GUI framework (ex Qt5) and you have 2
GUI frameworks in the same process conflicting with each other!
Hope that helps!
On Sun, Apr 22, 2018 at 4:50 PM michalwd1979 <michalwd1979 at o2.pl> wrote:
> Dear Members,
> Recently I upgraded to from matplotlib 1.4.3 + gtk2 to matplotlib 2.2.2 +
> gtk3 and I have a problems with porting my old code.
> I'm using matplotlib in Gtk window with typical:
> win = Gtk.window()
> vbox = Gtk.Box(...)
> fig = pylab.figure()
> canvas = FigureCanvas(fig)
> toolbar = NavigationToolbar(canvas, fig)
> axis = fig.add_axes(...)
> while(Gtk.events_pending()): Gtk.main_iteration()
> After this code I have a valid window on screen however it does not reacts
> on mouse clicks (zooming etc.) until calling Gtk.main_iteration() in loop
> or Gtk.main(). I can understand why, however it was working differently
> with old matplotlib and gtk2 (window was responsive all time).
> The rest of my code is a python "Text User Interface" application
> (controlled by commands typed to terminal), the window is only for showing
> the results (animated waveform). Now I would like to keep the application
> as it is, but also to have responsive matplotlib window, without calling
> Gtk.main(). Is it possible? If yes, then how to do this?
> Sorry for the long mail - I have no idea how to describe the problem
> shortly and all examples I found always have Gtk.main() called so they are
> in fact full GTK programs. I want a simple text program with matplotlib
> window as a "result showing" addition only.
> Best Regards,
> Michael Widlok
> Matplotlib-users mailing list
> Matplotlib-users at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users