wxPhthon Ultimatelistctrl超链接示例代码

时间:2014-05-01 02:53:40

标签: hyperlink wxpython

我需要使用Ultimatelistctrl来显示带有超线的图标。

在Ultimatelistctrl API中,它提到了 “超链接类型的项目和子项目:它们看起来像一个超链接,正确的鼠标光标悬停在上面;” 但是没有工作样本。

我在下面创建渲染代码。 DrawSubItem函数称为成功。但从未调用过OnMouseEvent。 如何将用户点击绑定到OnMouseEvent函数

class CustomizedRenderer(object):

def __init__(self, parent, fileName):

    self.parent = parent
    self.fileName = fileName

    self.normalFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
    self.normalFont.SetPointSize(self.normalFont.GetPointSize() + 1)        
    self.smallerFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)

    self.greyColour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)

    fileType = wx.TheMimeTypesManager.GetFileTypeFromExtension(extension)

    bmp = wx.Bitmap(os.path.join(bitmapDir, "empty_icon.png"), wx.BITMAP_TYPE_PNG)
    bmp = wx.IconFromBitmap(bmp)


    self.icon = bmp
    self.description = convert(fileType.GetDescription())

def OnMouseEvent(self, e):
    if e.LeftUp():
        webbrowser.open_new("http://www.google.com")
    e.Skip()

def DrawSubItem(self, dc, rect, line, highlighted, enabled):

    ***********************


def GetLineHeight(self):

    ***********************


def GetSubItemWidth(self):

    ***********************

我可以在更改C:\ Python27 \ Lib \ site-packages \ wx-2.9.5-msw \ wx \ lib \ agw \ ultimatelistctrl.py

后使其正常工作

更改是在ultimatelistctrl.py onMouse()上添加一些逻辑,然后调用模块代码。

0 个答案:

没有答案
相关问题