python - wxPython wx.lib.plot.PlotCanvas 错误

标签 python wxpython

我正在制作一个非常简单的绘图 wxApp。

我已经安装了 Python 2.7.9 和 wxPython 3.0.2

这是我的代码:

import wx
import wx.lib.plot as plot

class Pantalla(wx.Frame):
    def __init__(self):
        app = wx.App()
        self.frame1 = wx.Frame(None, title = "GRAFICADOR", id = -1, size=(500,500))
        self.panel1 = wx.Panel(self.frame1)
        self.panel1.SetBackgroundColour("white")
        plotter = plot.PlotCanvas(self.panel1, id=-1, pos = wx.Point(-1,-1), size = wx.Size(-1,-1), style = 0, name= 'plotCanvas')

        data = [(1,2), (2,3), (4,6)]
        line = plot.PolyLine(data, colour='red', width = 1)
        gc = plot.PlotGraphics([line], 'Line', 'Eje x', 'Eje y')
        plotter.Draw(gc, xAxis = (0,15), yAxis=(0,15))
        self.frame1.Show(True)
        app.MainLoop()

t = Pantalla()

然而,每当我测试它时,它都会抛出这个错误:

Traceback (most recent call last):

  File "<pyshell#26>", line 1, in <module>

    f = Pantalla()

  File "<pyshell#25>", line 7, in __init__

    plotter = plot.PlotCanvas(self.panel1, id=-1, pos = wx.Point(-1,-1), size = wx.Size(-1,-1), style = 0, name= 'plotCanvas')

  File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\lib\plot.py", line 598, in __init__
    self.HandCursor = wx.Cursor(Hand.GetImage())

  File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_gdi.py", line 1547, in __init__
    _gdi_.Cursor_swiginit(self,_gdi_.new_Cursor(*args, **kwargs))

TypeError: Required argument 'type' (pos 2) not found

我正在传递 wx 文档中所说的所有参数。 我究竟做错了什么?

最佳答案

虽然这是 wx 3.0.2 版本的问题,但我测试了你的代码,这个问题在 wx 3.0.3 'classic' 的源代码中不存在,也不存在使用 wx 3.0.3 '凤凰'。

您可以从这些来源 check out /构建/安装 3.0.3“经典”的存储库:
https://github.com/wxWidgets/wxWidgets.git
https://github.com/wxWidgets/wxPython.git
结帐后的说明将在 wxPython/docs/BUILD.txt

或者,将“phoenix”3.0.3 与使用此源的项目一起使用:
https://github.com/wxWidgets/Phoenix.git
结帐后的说明将在 wxPython/README.rst

关于python - wxPython wx.lib.plot.PlotCanvas 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30383786/

相关文章:

python - Django rest 框架文档 View

dialog - wXPython:无法让小部件放大/扩展尺寸

python - 如何删除初始 wx.RadioBox 选择?

python - Pygame 水波纹效果

Python - 是五边形数检查

python gnupg 如何对文件进行 pgp 加密,而无需指定 homedir,或将 key 存储在目录中

python - wxPython | wxDataViewListCtrl 获取所有选定的行/项目

python - Tkinter 错误 : cannot use geometry manager grid inside . 已经有由包管理的从站

python - 在线程中使用 while True 循环时出现 wxPython Pango 错误

python - wxPython 按钮更改面板上的文本