程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

带有 ULC 的 wxpython `GetScrollPos` 不工作

发布于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黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

12 0
收藏该文
已收藏

评论内容:(最多支持255个字符)