Hello people,
I've got a small issue with derived classes, namely wx.ListItem with wx.ListCtrl. I succesfully derived wx.ListItem as a MediaItem, the code is not finished but you get the point:
class MediaItem(wx.ListItem):
def __init__ (self, fullname):
wx.ListItem.__init__(self)
self.fullname = fullname
self.filename = os.path.basename(fullname)
# snap...
def getFullname(self):
return self.fullname
wx.ListCtrl gladly accepts that because of Pythons duck philosophy. But now the problem is that using the method wx.ListCtrl.GetItem(index) returns a ListItem, not MediaItem. Python complained about wx.ListItem not having an attribute getFullname.
Casting objects seems to be the wrong way to approach the solution. This probably has nothing to do with the problem, but I paste the offending line as is as well:
filename = self.filelist.GetItem(event.GetIndex()).getFullname()
Where self.filelist is a wx.ListCtrl.