发布于2023-02-03 21:17 阅读(778) 评论(0) 点赞(12) 收藏(4)
嗨,我有这段代码:
import wx
import wx.lib.agw.ultimatelistctrl as ULC
class UltimateListCtrl(ULC.UltimateListCtrl):
def __init__(self, parent, ID=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=0):
ULC.UltimateListCtrl.__init__(self, parent, ID, pos, size, agwStyle=agwStyle)
self.Bind( wx.EVT_LIST_ITEM_ACTIVATED, self.onClick)
def onClick(self,event):
print (self.GetScrollPos(wx.HORIZONTAL))
event.Skip()
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((400, 321))
self.SetTitle("frame")
self.panel_1 = wx.Panel(self, wx.ID_ANY)
sizer_1 = wx.BoxSizer(wx.VERTICAL)
self.list_ctrl_1 = UltimateListCtrl(self.panel_1, wx.ID_ANY,agwStyle=ULC.ULC_REPORT | ULC.ULC_VRULES )
self.list_ctrl_1.InsertColumn(0, "A", format=wx.LIST_FORMAT_LEFT, width=-1)
self.list_ctrl_1.InsertColumn(1, "B", format=wx.LIST_FORMAT_LEFT, width=-1)
self.list_ctrl_1.InsertColumn(2, "C", format=wx.LIST_FORMAT_LEFT, width=-1)
sizer_1.Add(self.list_ctrl_1, 1, wx.EXPAND, 0)
index = self.list_ctrl_1.InsertStringItem(0, "1")
self.list_ctrl_1.SetStringItem(index, 1,"2")
self.list_ctrl_1.SetStringItem(index, 2,"3")
index = self.list_ctrl_1.InsertStringItem(1, "1")
self.list_ctrl_1.SetStringItem(index, 1,"2")
self.list_ctrl_1.SetStringItem(index, 2,"3")
self.panel_1.SetSizer(sizer_1)
self.Layout()
# end wxGlade
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None, wx.ID_ANY, "")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()
当我重复单击 ULC(UltimateListCtrl) 中的一个项目时,它必须打印ScrollPos
,但我有这个错误:
Traceback (most recent call last):
File "C:\Users\Dell\Desktop\Ult.py", line 29, in onClick
print 'self.GetScrollPos(wx.HORIZONTAL)' , self.GetScrollPos(wx.HORIZONTAL)
TypeError: GetScrollPos() takes exactly 1 argument (2 given)
但我GetScrollPos()
只给出 1 个参数而不是 2 个参数self.GetScrollPos(wx.HORIZONTAL)
!我的错误是什么?
编辑 :
我在 UltimateListCtrl Doc 中找到了这个注释:
GetScrollPos(自我,方向)
Returns the scrollbar position.
Note
`This method is forwarded to UltimateListMainWindow.`
Parameters
orientation – May be wx.HORIZONTAL or wx.VERTICAL.
转发到 UltimateListMainWindow 是否会导致此错误?如果是,那么如何解决此错误?
作者:黑洞官方问答小能手
链接:https://www.pythonheidong.com/blog/article/1895304/770bb23104d9b34e9663/
来源:python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!