TypeError:__init __()得到了一个意外的关键字参数'列'
问题描述:
我想在wxpython中创建一个插件并运行到下面的错误,任何人都可以帮助理解为什么我遇到这个错误以及如何解决这个问题?TypeError:__init __()得到了一个意外的关键字参数'列'
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'
答
如果你看一下the documentation for the class's __init__
,你可以看到它有没有keyword argumentcolumns
,可是你想传递一个:
self.view_listctrl = ULC.UltimateListCtrl(package_panel, id=-1,columns=2,selectionType=1)
这基本上就是错误信息告诉你的。
Ami - 我从'从UIElements import OutputConsole'导入,我可以从哪里安装UIElements? – kemosabee
@kemosabee我没有看到你的问题中的代码。这是一个新问题吗?如果是这样,你可以请开一个新的吗?这是事情在SO上完成的方式。如果你在这里下载链接,我会很高兴看到它。 –
Ami - 好吧我会提出一个新的 – kemosabee