Browse Source

Fixed missing *kwargs param. Wrapped path output in quotes

pull/94/head
chriskiehl 9 years ago
parent
commit
4038cae503
1 changed files with 14 additions and 9 deletions
  1. 23
      gooey/gui/widgets/widget_pack.py

23
gooey/gui/widgets/widget_pack.py

@ -93,23 +93,28 @@ class BaseFileChooser(BaseChooser):
def get_path(self, dlg): def get_path(self, dlg):
if isinstance(dlg, wx.DirDialog): if isinstance(dlg, wx.DirDialog):
return dlg.GetPath()
return wrap_quotes(dlg.GetPath())
else: else:
paths = dlg.GetPaths() paths = dlg.GetPaths()
return paths[0] if len(paths) < 2 else ' '.join(paths)
return wrap_quotes(paths[0]) if len(paths) < 2 else ' '.join(map(wrap_quotes, paths))
def build_dialog(style, exist_constraint=True, **kwargs):
if exist_constraint:
return lambda panel: wx.FileDialog(panel, style=style | wx.FD_FILE_MUST_EXIST, **kwargs)
else:
return lambda panel: wx.FileDialog(panel, style=style, **kwargs)
def wrap_quotes(string):
return '"{}"'.format(string)
class MyMultiDirChooser(MDD.MultiDirDialog): class MyMultiDirChooser(MDD.MultiDirDialog):
def __init(self, dialog):
def __init(self, *args, **kwargs):
super(MyMultiDirChooser,self).__init__(*args, **kwargs) super(MyMultiDirChooser,self).__init__(*args, **kwargs)
def GetPaths(self): def GetPaths(self):
return (self.dirCtrl.GetPaths())
return self.dirCtrl.GetPaths()
def build_dialog(style, exist_constraint=True, **kwargs):
if exist_constraint:
return lambda panel: wx.FileDialog(panel, style=style | wx.FD_FILE_MUST_EXIST, **kwargs)
else:
return lambda panel: wx.FileDialog(panel, style=style, **kwargs)
FileChooserPayload = partial(BaseFileChooser, dialog=build_dialog(wx.FD_OPEN)) FileChooserPayload = partial(BaseFileChooser, dialog=build_dialog(wx.FD_OPEN))
FileSaverPayload = partial(BaseFileChooser, dialog=build_dialog(wx.FD_SAVE, False, defaultFile="Enter Filename")) FileSaverPayload = partial(BaseFileChooser, dialog=build_dialog(wx.FD_SAVE, False, defaultFile="Enter Filename"))

Loading…
Cancel
Save