我目前有以下代碼來手動獲取目錄路徑,我想添加拖放以及,所以我可以將文件夾拖放到窗口中。Wxpython瀏覽或拖放文件夾
self.pathindir1 = wx.TextCtrl(self.panel1, -1, pos=(35, 120), size=(300, 25))
self.buttonout = wx.Button(self.panel1, -1, "Open", pos=(350,118))
self.buttonout.Bind(wx.EVT_BUTTON, self.openindir1)
def openindir1(self, event):
global indir1
dlg = wx.DirDialog(self, "Choose a directory:", style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
if dlg.ShowModal() == wx.ID_OK:
indir1 = dlg.GetPath()
self.SetStatusText("Your selected directory is: %s" % indir1)
self.pathindir1.Clear()
self.pathindir1.WriteText(indir1)
我認爲拖放已經被wx.DirDialog支持,但是這個操作意味着「複製並粘貼」。也許你需要實現你自己的DirDialog –