0
我目前有一個使用wx.TextCtrl的工作應用程序,我打開一個選擇文件夾對話框。我想添加拖放功能,因此我只需拖放文件夾即可獲取文件夾路徑,這樣我就可以爲用戶提供這兩種選項。 這是我目前的代碼段:wx.TextCtrl使用拖放文件夾獲取文件路徑
self.pathindir = wx.TextCtrl(panel, -1, pos=(35, 380), size=(300, 25)) self.buttonin = wx.Button(panel, -1, "Open", pos=(350, 378)) self.buttonin.Bind(wx.EVT_BUTTON, self.openindir)
def openindir(self, event):
dlg = wx.DirDialog(self, "Choose your input lookup directory:", style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
if dlg.ShowModal() == wx.ID_OK:
global pathindir
pathindir = dlg.GetPath()
self.SetStatusText("Your selected input lookup directory is: %s" % pathindir)
self.pathindir.Clear()
self.pathindir.WriteText(pathindir)
dlg.Destroy()