diff --git a/gooey/gui/components/widgets/core/chooser.py b/gooey/gui/components/widgets/core/chooser.py index b64c7f5..e250201 100644 --- a/gooey/gui/components/widgets/core/chooser.py +++ b/gooey/gui/components/widgets/core/chooser.py @@ -64,13 +64,24 @@ class Chooser(wx.Panel): class FileChooser(Chooser): """ Retrieve an existing file from the system """ def getDialog(self): - return wx.FileDialog(self, _('open_file'), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) + options = self.Parent._options + return wx.FileDialog(self, message=options.get('message', _('open_file')), + style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, + defaultFile=options.get('defaultFile', _("enter_filename")), + defaultDir=options.get('defaultDir', _('')), + wildcard=options.get('wildcard', wx.FileSelectorDefaultWildcardStr)) class MultiFileChooser(Chooser): """ Retrieve an multiple files from the system """ def getDialog(self): - return wx.FileDialog(self, _('open_files'), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE) + options = self.Parent._options + return wx.FileDialog(self, message=options.get('message', _('open_files')), + style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE, + defaultFile=options.get('defaultFile', _("enter_filename")), + defaultDir=options.get('defaultDir', _('')), + wildcard=options.get('wildcard', wx.FileSelectorDefaultWildcardStr)) + def getResult(self, dialog): return os.pathsep.join(dialog.GetPaths()) @@ -78,26 +89,32 @@ class MultiFileChooser(Chooser): class FileSaver(Chooser): """ Specify the path to save a new file """ def getDialog(self): + options = self.Parent._options return wx.FileDialog( self, style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT, - defaultFile=_("enter_filename"), - message=_('choose_file') + defaultFile=options.get('defaultFile', _("enter_filename")), + defaultDir=options.get('defaultDir', _('')), + message=options.get('message', _('choose_file')), + wildcard=options.get('wildcard', wx.FileSelectorDefaultWildcardStr) ) class DirChooser(Chooser): """ Retrieve a path to the supplied directory """ def getDialog(self): - return wx.DirDialog(self, message=_('choose_folder')) - + options = self.Parent._options + return wx.DirDialog(self, message=options.get('message', _('choose_folder')), + defaultPath=options.get('defaultPath', os.getcwd())) + class MultiDirChooser(Chooser): """ Retrieve an multiple directories from the system """ def getDialog(self): + options = self.Parent._options return MDD.MultiDirDialog(self, - message=_('choose_folders_msg'), + message=options.get('message', _('choose_folders')), title=_('choose_folders_title'), - defaultPath=os.getcwd(), + defaultPath=options.get('defaultPath', os.getcwd()), agwStyle=MDD.DD_MULTIPLE | MDD.DD_DIR_MUST_EXIST) def getResult(self, dialog): return os.pathsep.join(dialog.GetPaths())