TypeError:__ init __()得到了一个意外的关键字参数'columns'

时间:2016-08-18 22:40:12

标签: python wxpython

我正在尝试在wxpython中创建一个插件并遇到以下错误,任何人都可以帮助理解我遇到此错误的原因以及如何解决此问题?

import wx
from wx.lib.agw import ultimatelistctrl as ULC 


class TestFrame(wx.App):
    def __init__(self):
        wx.App.__init__(self)
        APPNAME = 'plugin'
        self.frame = wx.Frame(None, -1, size=wx.Size(600,700), title=APPNAME, style=wx.DEFAULT_FRAME_STYLE)
        splitter = wx.SplitterWindow(self.frame, -1)
        splitter.SetMinimumPaneSize(180)
        panel1 = wx.Panel(splitter, size=wx.Size(-1, 300))
        commands_panel = wx.Panel(panel1, -1)
        package_panel = wx.Panel(commands_panel, -1)
        self.view_listctrl = ULC.UltimateListCtrl(package_panel, id=-1,columns=2,selectionType=1)
        package_vbox.Add(self.view_listctrl, 2, wx.EXPAND | wx.ALL, 5)
        #view_listctrl = ULC.UltimateListCtrl(package_panel, id=-1)
        itemCount = int('2')
        for x in range(0,itemCount):
            view_listctrl.SetItemKind(x, 2 , 1)

if __name__ == "__main__":
    app = wx.App(False)
    frame = TestFrame()
    app.MainLoop()

错误: -

Traceback (most recent call last):
  File "listctr.py", line 26, in <module>
    frame = TestFrame()
  File "listctr.py", line 15, in __init__
    self.view_listctrl = ULC.UltimateListCtrl(package_panel, id=-1,columns=2,selectionType=1)
TypeError: __init__() got an unexpected keyword argument 'columns'

1 个答案:

答案 0 :(得分:1)

如果您查看the documentation for the class's __init__,就可以看到它没有keyword argument columns,但您却尝试传递一个:

self.view_listctrl = ULC.UltimateListCtrl(package_panel, id=-1,columns=2,selectionType=1)

它基本上就是错误消息告诉你的内容。