0

I currently have a working app using wx.TextCtrl, where I open a select folder dialogue box. I would like to add drag and drop so I could just drag and drop a folder to get the folder path, so I could have both options available to the user. Here is a section of my current code:

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()
speedyrazor
  • 3,127
  • 7
  • 33
  • 51

1 Answers1

0

You can't do it the way you're doing it. You are using a modal dialog, which pauses the main application while the dialog runs. Thus you can't interact with the main application. That means you can't drag and drop the path from the dialog to the frame. You could just Show() the dialog or you could take a look at the wxPython demo which also has an example.

Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88