为什么我的 wx.App 会干扰我的 matplotlib 绘图? [英] Why is my wx.App interfering with my matplotlib plots?

查看:44
本文介绍了为什么我的 wx.App 会干扰我的 matplotlib 绘图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 wxPython 构建一个 GUI 来控制一个非常稳定、完善的模型.该模型的标准输出包括一系列通过 matplotlib 进行筛选的绘图.如果模型是从命令行运行的,这些图都可以.但是,如果我从我的新 GUI 运行,它们都会出现,但我无法控制它们:我无法单击它们各自的保存"按钮;如果它们被其他窗口覆盖,当阻挡窗口移开时它们会变灰".像这样的东西.但是,如果我关闭 GUI 窗口,我将再次完全控制我的绘图.但这不是运行这段代码的方法.

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.

推荐答案

这是一个站点的链接,该站点包含一些将 matplotlib 与 wxPython GUI 结合使用的演示代码.eli.thegreenplace.net/2008/08/01/matplotlib-with-wxpython-guis

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

还有这个 - matplotlib.org/faq/usage_faq.html 谈到了改变后端.

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

我在 pypi 上找到了一个包 pypi.python.org/pypi/wxmplot/0.9.12

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

这篇关于为什么我的 wx.App 会干扰我的 matplotlib 绘图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆