- path = wx.FileSelector(_("Select a File"),
- self._lastDirectory,
- _(""),
- wildcard = descr,
- flags = wx.HIDE_READONLY,
- parent = self.FindSuitableParent())
- if path:
- if not FileExists(path):
- msgTitle = wx.GetApp().GetAppName()
- if not msgTitle:
- msgTitle = _("File Error")
- wx.MessageBox("Could not open '%s'." % FileNameFromPath(path),
- msgTitle,
- wx.OK | wx.ICON_EXCLAMATION,
- parent)
- return (None, None)
- self._lastDirectory = PathOnly(path)
-
+ dlg = wx.FileDialog(self.FindSuitableParent(),
+ _("Select a File"),
+ wildcard=descr,
+ style=wx.OPEN|wx.FILE_MUST_EXIST|wx.CHANGE_DIR)
+ # dlg.CenterOnParent() # wxBug: caused crash with wx.FileDialog
+ if dlg.ShowModal() == wx.ID_OK:
+ path = dlg.GetPath()
+ else:
+ path = None
+ dlg.Destroy()
+
+ if path: