FileBrowseButton wxMULTIPLE support

Heya Folks,

The FileBrowseButton appears to ignore all but the last file selected when you set the fileMode to wxMULTIPLE.

Did i miss something, or is my observation correct?

For now, I've hacked the OnBrowse () method as follows to get all files into the textControl.

--- filebrowsebutton.py.original Mon Dec 1 12:59:29 2003
+++ filebrowsebutton.py Mon Dec 1 12:51:00 2003
@@ -166,7 +166,17 @@
          dlg = wxFileDialog(self, self.dialogTitle, directory, current, self.fileMask, self.fileMode)

          if dlg.ShowModal() == wxID_OK:
- self.SetValue(dlg.GetPath())
+ if self.fileMode == wxMULTIPLE:
+ path = ""
+ paths = dlg.GetPaths()
+ for curpath in paths:
+ if path != "":
+ path = path + "," + curpath
+ else:
+ path = curpath
+ self.SetValue(path)
+ else:
+ self.SetValue(dlg.GetPath())
          dlg.Destroy()

Mazzel,

Martijn.

Use GetPaths() instead of GetPath(). Then you get a list of zero or more
paths that you can iterate through.

···

-----Original Message-----
From: Martijn Ras [mailto:ras@holmes.nl]
Sent: Monday, December 01, 2003 4:05 AM
To: wxpython-dev@lists.wxwindows.org
Subject: [wxPython-dev] FileBrowseButton wxMULTIPLE support

Heya Folks,

The FileBrowseButton appears to ignore all but the last file selected
when you set the fileMode to wxMULTIPLE.

Did i miss something, or is my observation correct?

For now, I've hacked the OnBrowse () method as follows to get all files
into the textControl.

--- filebrowsebutton.py.original Mon Dec 1 12:59:29 2003
+++ filebrowsebutton.py Mon Dec 1 12:51:00 2003
@@ -166,7 +166,17 @@
          dlg = wxFileDialog(self, self.dialogTitle, directory, current,
self.fileMask, self.fileMode)

          if dlg.ShowModal() == wxID_OK:
- self.SetValue(dlg.GetPath())
+ if self.fileMode == wxMULTIPLE:
+ path = ""
+ paths = dlg.GetPaths()
+ for curpath in paths:
+ if path != "":
+ path = path + "," + curpath
+ else:
+ path = curpath
+ self.SetValue(path)
+ else:
+ self.SetValue(dlg.GetPath())
          dlg.Destroy()

Mazzel,

Martijn.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-dev-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-dev-help@lists.wxwindows.org

Martijn Ras wrote:

Heya Folks,

The FileBrowseButton appears to ignore all but the last file selected when you set the fileMode to wxMULTIPLE.

Did i miss something, or is my observation correct?

Yep.

For now, I've hacked the OnBrowse () method as follows to get all files into the textControl.

--- filebrowsebutton.py.original Mon Dec 1 12:59:29 2003
+++ filebrowsebutton.py Mon Dec 1 12:51:00 2003
@@ -166,7 +166,17 @@
         dlg = wxFileDialog(self, self.dialogTitle, directory, current, self.fileMask, self.fileMode)

         if dlg.ShowModal() == wxID_OK:
- self.SetValue(dlg.GetPath())
+ if self.fileMode == wxMULTIPLE:
+ path = ""
+ paths = dlg.GetPaths()
+ for curpath in paths:
+ if path != "":
+ path = path + "," + curpath
+ else:
+ path = curpath

Can this for loop be replaced with this?

  path = ", ".join(paths)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Use GetPaths() instead of GetPath(). Then you get a list of zero or more
paths that you can iterate through.

Sheesh, I was still waking up. Somebody should lock my computer in the
morning. Sorry! :slight_smile: