TypeError:GridSizer():参数与任何重载调用都不匹配

时间:2016-05-28 17:48:11

标签: wxpython typeerror

我想显示一个包含6个按钮(取消,删除,保存,退出,停止,新)的表,包含3行和2个组。 我尝试在下面运行这个程序,但它没有用。

import wx

class Identifiers(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(200, 150))

        panel = wx.Panel(self, -1)
        grid = wx.GridSizer(3, 2)

        grid.AddMany([(wx.Button(panel, wx.ID_CANCEL), 0, wx.TOP | wx.LEFT, 9),
        (wx.Button(panel, wx.ID_DELETE), 0, wx.TOP, 9),
        (wx.Button(panel, wx.ID_SAVE), 0, wx.LEFT, 9),
        (wx.Button(panel, wx.ID_EXIT)),
        (wx.Button(panel, wx.ID_STOP), 0, wx.LEFT, 9),
        (wx.Button(panel, wx.ID_NEW))])

        self.Bind(wx.EVT_BUTTON, self.OnQuit, id=wx.ID_EXIT)

        panel.SetSizer(grid)
        self.Centre()
        self.Show(True)

    def OnQuit(self, event):
        self.Close()

app = wx.App()
Identifiers(None, -1, '')
app.MainLoop()

这是整个邮件错误。

File "C:/Python34/Test_wxPython/Events/Identifiers.py", line 12, in __init__
    grid = wx.GridSizer(3, 2)
TypeError: GridSizer(): arguments did not match any overloaded call:
  overload 1: not enough arguments
  overload 2: argument 2 has unexpected type 'int'
  overload 3: not enough arguments
  overload 4: not enough arguments

此行grid = wx.GridSizer(3, 2)存在问题,但我无法解决问题。

1 个答案:

答案 0 :(得分:0)

当你运行Python 3.4时,我认为你正在使用wxPython Phoenix。根据文档of wx.GridSizer,两个int与任何允许的签名都不匹配。使用例如而是三个整数。