我使用下面的代码创建一个拖放窗口,将文件夹拖放到其中以获取文件夹路径。我想要的是能够删除一个文件夹,然后删除另一个文件夹,该文件夹将添加到列表中,然后可能是另一个文件夹将添加到列表中,依此类推。目前,如果我在第一个文件夹之后放置另一个文件夹,它只会在窗口中显示第一个文件夹。如何让它显示正在添加的新内容,并将它们添加到列表中?
def queue(self, event):
self.Show()
dt1 = MyFileDropTarget(self)
self.tc_files = wx.TextCtrl(self.panel1, wx.ID_ANY, pos=(42, 120), size=(500, 405))
self.tc_files.SetDropTarget(dt1)
def notify(self, indir):
"""Update file in testcontrol after drag and drop"""
self.tc_files.SetValue(indir[0])
class MyFileDropTarget(wx.FileDropTarget):
""""""
def __init__(self, window):
wx.FileDropTarget.__init__(self)
self.window = window
def OnDropFiles(self, x, y, filenames):
self.window.notify(filenames)
最佳答案
正如 @JoranBeasley 评论的那样,您需要使用 indir 列表来设置您显示的字符串:
self.tc_files.SetValue(",".join(indir))
应该这样做。
关于python - wxpython 拖放一个文件夹,然后拖放另一个文件夹以添加到列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21800819/