Why is my wx.App interfering with my matplotlib plots?

谁说胖子不能爱 提交于 2019-12-12 02:55:25

问题


I am trying to build a GUI with wxPython to control a pretty stable, well-established model. The standard output of the model includes a series of plots to screen done via matplotlib. These plots are all OK if the model is run from the command line. If I run from my new GUI, however, they all show up, but I have no control over them: I can't click their respective "save" buttons; if they get covered up by other windows, they are "grayed out" when the blocking window is moved away. Things like that. If I close my GUI window, however, I get full control of my plots again. But this is no way to run this code.

I think my procedure is pretty standard. The bare outlines of the code are:

import wx
import model_code

class gui_for_model(wx.Frame):
    # lots of stuff with hooks into model_code,
    # including a "go" button that starts model_code running

#end of class

app=wx.App(False)
gm = gui_for_model()
app.MainLoop()

Anyone know what I should do differently? Thanks.


回答1:


Here is a link to a site that has some demo code of using matplotlib with wxPython GUIs. eli.thegreenplace.net/2008/08/01/matplotlib-with-wxpython-guis

Also this - matplotlib.org/faq/usage_faq.html talks about changing the backend.

And i found a package on pypi pypi.python.org/pypi/wxmplot/0.9.12



来源:https://stackoverflow.com/questions/16042881/why-is-my-wx-app-interfering-with-my-matplotlib-plots

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!