我是 wxpython 的新手(和 python 也是:)),我正在尝试为我做一个自定义程序并学习,但有些事情我不能做。我一直在寻找 Objectlistview 的示例,但没有那么多。我从这里复制/粘贴/编辑代码(最后一个例子),我想做这样的事情来避免重复的项目:
self.olv = ObjectListView(self, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
...
self.olv.SetDropTarget(MyFileDropTarget(self))
self.setFiles()
self.RemoveDuplicated(self.olv)
def RemoveDuplicated(self, X):
for all in X:
Counter = 0
for B in X:
if X.path(A) == X.path(B):
Counter += 1
if (X.path(A) == X.path(B) and Counter >=2):
Counter += 1
RemoveObject(B)
有什么想法或教程吗?先感谢您。
现在完成了:D,又是迈克。
def __init__(self, window):
"""Constructor"""
wx.FileDropTarget.__init__(self)
self.window = window
self.all_filenames = []
#----------------------------------------------------------------------
def OnDropFiles(self, x, y, filenames):
"""
When files are dropped, update the display
"""
self.entriesList = list() # Actual dropped file entries; duplicates are avoided.
self.haveEntries = False # Tracks actual dropped file entries, but not help entries.
self.RemoveDuplicated(self.all_filenames, filenames)
self.all_filenames += filenames
self.window.updateDisplay(filenames)
print len(all_filenames) , len(filenames)
def RemoveDuplicated(self, X, Y):
for A in X:
for B in Y:
if A == B:
Y.remove(B)