3

I want to put a graph that self updates. So when I press a Kivy button on my GUI script written with Python and it's supposed to take me to a Screen. The Screen has a graph on a part of the Screen and buttons on the rest of the screen. However, I add the graph and it opens in a separate window. How do I do that?

I used the matplotlib library for plotting the graph.

I used plt.show() and it opens a different window.

Peter Badida
  • 11,310
  • 10
  • 44
  • 90

1 Answers1

1

To prevent matplotlib from stealing the focus of your Window you need to tell it to do so for some strange reason (maybe because of high usage of MPL in IPython notebook?)

import matplotlib
matplotlib.use('Agg')

After those lines the window should stop stealing. The updating on the other hand is something way different and that's why there's garden.graph and garden.matplotlib.

If you intend to just draw some simple plots, just use the Graph. If you really need MPL and/or you want to do something complex, use the MPL backend (garden.matplotlib).

Aurora0001
  • 13,139
  • 5
  • 50
  • 53
Peter Badida
  • 11,310
  • 10
  • 44
  • 90
  • I believed that would be a backend and would not show the graph on the gui. Is there is a way for the code to export the graph so it could be seen? Thank you. – Ayomide Awe Jun 12 '17 at 22:15
  • Well, you can save the MPL plot to an image and load it into kivy image widget later (or just into bare texture), but I think you'll have more luck with `garden.matplotlib` instead of this workaround. – Peter Badida Jun 12 '17 at 22:19