python - wxpython 拖放一个文件夹,然后拖放另一个文件夹以添加到列表

标签 python drag-and-drop wxpython

我使用下面的代码创建一个拖放窗口,将文件夹拖放到其中以获取文件夹路径。我想要的是能够删除一个文件夹,然后删除另一个文件夹,该文件夹将添加到列表中,然后可能是另一个文件夹将添加到列表中,依此类推。目前,如果我在第一个文件夹之后放置另一个文件夹,它只会在窗口中显示第一个文件夹。如何让它显示正在添加的新内容,并将它们添加到列表中?

    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/

相关文章:

python - matplotlib 动画在 wxpython gui 中时不会更新,但可以独立工作

python - 在不导入任何模块的情况下以 min :sec, 格式对时间进行排序的有效方法是什么?

Python Turtle 如何在 7x7 网格的单元格内绘制标记

python - "no python application found"uWSGI + nginx + Ubuntu 13

python - 替换 IPython 菜单图标

python - 全局名称 'img' 未定义?

python - pandas stack/unstack 使用交换级别 reshape df

html - Firefox (v10) 中的文件拖放

html - Cocoa WebView 和 HTML5 拖放

JavaScript:如何在表格中设置拖放步骤