|
@ -7,6 +7,7 @@ __author__ = 'Chris' |
|
|
from abc import ABCMeta, abstractmethod |
|
|
from abc import ABCMeta, abstractmethod |
|
|
|
|
|
|
|
|
import wx |
|
|
import wx |
|
|
|
|
|
import wx.lib.agw.multidirdialog as MDD |
|
|
|
|
|
|
|
|
from gooey.gui.widgets.calender_dialog import CalendarDlg |
|
|
from gooey.gui.widgets.calender_dialog import CalendarDlg |
|
|
|
|
|
|
|
@ -96,7 +97,6 @@ class BaseFileChooser(BaseChooser): |
|
|
paths = dlg.GetPaths() |
|
|
paths = dlg.GetPaths() |
|
|
return paths[0] if len(paths) < 2 else ' '.join(paths) |
|
|
return paths[0] if len(paths) < 2 else ' '.join(paths) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_dialog(style, exist_constraint=True, **kwargs): |
|
|
def build_dialog(style, exist_constraint=True, **kwargs): |
|
|
if exist_constraint: |
|
|
if exist_constraint: |
|
|
return lambda panel: wx.FileDialog(panel, style=style | wx.FD_FILE_MUST_EXIST, **kwargs) |
|
|
return lambda panel: wx.FileDialog(panel, style=style | wx.FD_FILE_MUST_EXIST, **kwargs) |
|
@ -104,12 +104,36 @@ def build_dialog(style, exist_constraint=True, **kwargs): |
|
|
return lambda panel: wx.FileDialog(panel, style=style, **kwargs) |
|
|
return lambda panel: wx.FileDialog(panel, style=style, **kwargs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class multiDirChooser(BaseChooser): |
|
|
|
|
|
def __init__(self, dialog): |
|
|
|
|
|
BaseChooser.__init__(self) |
|
|
|
|
|
self.dialog = dialog |
|
|
|
|
|
|
|
|
|
|
|
def onButton(self, evt): |
|
|
|
|
|
dlg = self.dialog(self.parent) |
|
|
|
|
|
result = (self.get_path(dlg) |
|
|
|
|
|
if dlg.ShowModal() == wx.ID_OK |
|
|
|
|
|
else None) |
|
|
|
|
|
if result: |
|
|
|
|
|
self.text_box.SetValue(result) |
|
|
|
|
|
|
|
|
|
|
|
def get_path(self, dlg): |
|
|
|
|
|
paths = dlg.dirCtrl.GetPaths() |
|
|
|
|
|
return paths[0] if len(paths) < 2 else ' '.join(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) |
|
|
|
|
|
|
|
|
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")) |
|
|
MultiFileSaverPayload = partial(BaseFileChooser, dialog=build_dialog(wx.FD_MULTIPLE, False)) |
|
|
MultiFileSaverPayload = partial(BaseFileChooser, dialog=build_dialog(wx.FD_MULTIPLE, False)) |
|
|
DirChooserPayload = partial(BaseFileChooser, dialog=lambda parent: wx.DirDialog(parent, 'Select Directory', style=wx.DD_DEFAULT_STYLE)) |
|
|
DirChooserPayload = partial(BaseFileChooser, dialog=lambda parent: wx.DirDialog(parent, 'Select Directory', style=wx.DD_DEFAULT_STYLE)) |
|
|
DateChooserPayload = partial(BaseFileChooser, dialog=CalendarDlg) |
|
|
DateChooserPayload = partial(BaseFileChooser, dialog=CalendarDlg) |
|
|
|
|
|
|
|
|
|
|
|
MultiDirChooserPayload = partial(multiDirChooser, dialog=lambda parent: MDD.MultiDirDialog(None, title="Select Directories", defaultPath=os.getcwd(), agwStyle=MDD.DD_MULTIPLE|MDD.DD_DIR_MUST_EXIST)) |
|
|
|
|
|
|
|
|
class TextInputPayload(WidgetPack): |
|
|
class TextInputPayload(WidgetPack): |
|
|
def __init__(self): |
|
|
def __init__(self): |
|
@ -198,4 +222,3 @@ class CounterPayload(WidgetPack): |
|
|
repeated_args = arg * int(dropdown_value) |
|
|
repeated_args = arg * int(dropdown_value) |
|
|
return '-' + repeated_args |
|
|
return '-' + repeated_args |
|
|
|
|
|
|
|
|
|
|
|
|