mirror of https://github.com/chriskiehl/Gooey.git
committed by
Chris
11 changed files with 110 additions and 52 deletions
Unified View
Diff Options
-
4README.md
-
8gooey/gui/components/widgets/choosers.py
-
2gooey/gui/components/widgets/core/__init__.py
-
11gooey/gui/components/widgets/core/chooser.py
-
56gooey/gui/components/widgets/dialogs/base_dialog.py
-
57gooey/gui/components/widgets/dialogs/calender_dialog.py
-
12gooey/gui/components/widgets/dialogs/time_dialog.py
-
5gooey/gui/three_to_four.py
-
2gooey/languages/english.json
-
4gooey/languages/french.json
-
1gooey/python_bindings/argparse_to_json.py
@ -1,2 +1,2 @@ |
|||||
from . chooser import Chooser, FileChooser, FileSaver, DirChooser, DateChooser, MultiFileChooser, MultiDirChooser, ColourChooser |
from . chooser import Chooser, FileChooser, FileSaver, DirChooser, DateChooser, TimeChooser, MultiFileChooser, MultiDirChooser, ColourChooser |
||||
from . text_input import PasswordInput, MultilineTextInput, TextInput |
from . text_input import PasswordInput, MultilineTextInput, TextInput |
@ -0,0 +1,56 @@ |
|||||
|
from gooey.gui.lang.i18n import _ |
||||
|
|
||||
|
import wx |
||||
|
|
||||
|
from gooey.gui.three_to_four import Constants |
||||
|
|
||||
|
|
||||
|
class BaseDialog(wx.Dialog): |
||||
|
""" |
||||
|
Common base for CalendarDlg and TimeDlg. |
||||
|
""" |
||||
|
def __init__(self, parent, pickerClass, pickerGetter, localizedPickerLabel): |
||||
|
wx.Dialog.__init__(self, parent, title=localizedPickerLabel) |
||||
|
|
||||
|
self.SetBackgroundColour('#ffffff') |
||||
|
|
||||
|
self.ok_button = wx.Button(self, wx.ID_OK, label=_('ok')) |
||||
|
self.picker = pickerClass(self, style=Constants.WX_DP_DROPDOWN) |
||||
|
self.pickerGetter = pickerGetter |
||||
|
|
||||
|
vertical_container = wx.BoxSizer(wx.VERTICAL) |
||||
|
vertical_container.AddSpacer(10) |
||||
|
vertical_container.Add(self.picker, 0, wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER, 15) |
||||
|
|
||||
|
vertical_container.AddSpacer(10) |
||||
|
button_sizer = wx.BoxSizer(wx.HORIZONTAL) |
||||
|
button_sizer.AddStretchSpacer(1) |
||||
|
button_sizer.Add(self.ok_button, 0) |
||||
|
|
||||
|
vertical_container.Add(button_sizer, 0, wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER, 15) |
||||
|
vertical_container.AddSpacer(20) |
||||
|
self.SetSizerAndFit(vertical_container) |
||||
|
|
||||
|
self.Bind(wx.EVT_BUTTON, self.onOkButton, self.ok_button) |
||||
|
|
||||
|
def onOkButton(self, event): |
||||
|
self.EndModal(wx.ID_OK) |
||||
|
event.Skip() |
||||
|
|
||||
|
def onCancelButton(self, event): |
||||
|
try: |
||||
|
return None |
||||
|
except: |
||||
|
self.Close() |
||||
|
|
||||
|
def GetPath(self): |
||||
|
""" |
||||
|
Return the value chosen in the picker. |
||||
|
The method is called GetPath() instead of getPath() to emulate the WX Pickers API. |
||||
|
This allows the Chooser class to work same way with native WX dialogs or childs of BaseDialog. |
||||
|
""" |
||||
|
|
||||
|
return self.pickerGetter(self.picker) |
||||
|
|
||||
|
|
||||
|
|
@ -1,52 +1,13 @@ |
|||||
from gooey.gui.lang.i18n import _ |
|
||||
|
|
||||
__author__ = 'Chris' |
|
||||
|
|
||||
import wx |
|
||||
|
|
||||
from gooey.gui.util import wx_util |
|
||||
|
|
||||
from gooey.gui.three_to_four import Classes, Constants |
|
||||
|
|
||||
|
|
||||
class CalendarDlg(wx.Dialog): |
|
||||
def __init__(self, parent): |
|
||||
wx.Dialog.__init__(self, parent) |
|
||||
|
|
||||
self.SetBackgroundColour('#ffffff') |
|
||||
|
|
||||
self.ok_button = wx.Button(self, wx.ID_OK, label=_('ok')) |
|
||||
self.datepicker = Classes.DatePickerCtrl(self, style=Constants.WX_DP_DROPDOWN) |
|
||||
|
|
||||
vertical_container = wx.BoxSizer(wx.VERTICAL) |
|
||||
vertical_container.AddSpacer(10) |
|
||||
vertical_container.Add(wx_util.h1(self, label=_('select_date')), 0, wx.LEFT | wx.RIGHT, 15) |
|
||||
vertical_container.AddSpacer(10) |
|
||||
vertical_container.Add(self.datepicker, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 15) |
|
||||
|
|
||||
vertical_container.AddSpacer(10) |
|
||||
button_sizer = wx.BoxSizer(wx.HORIZONTAL) |
|
||||
button_sizer.AddStretchSpacer(1) |
|
||||
button_sizer.Add(self.ok_button, 0) |
|
||||
|
|
||||
vertical_container.Add(button_sizer, 0, wx.LEFT | wx.RIGHT, 15) |
|
||||
vertical_container.AddSpacer(20) |
|
||||
self.SetSizerAndFit(vertical_container) |
|
||||
|
|
||||
self.Bind(wx.EVT_BUTTON, self.OnOkButton, self.ok_button) |
|
||||
|
|
||||
def OnOkButton(self, event): |
|
||||
self.EndModal(wx.ID_OK) |
|
||||
event.Skip() |
|
||||
|
|
||||
def OnCancellButton(self, event): |
|
||||
try: |
|
||||
return None |
|
||||
except: |
|
||||
self.Close() |
|
||||
|
|
||||
def GetPath(self): |
|
||||
return self.datepicker.GetValue().FormatISODate() |
|
||||
|
|
||||
|
from .base_dialog import BaseDialog |
||||
|
from gooey.gui.three_to_four import Classes |
||||
|
from gooey.gui.lang.i18n import _ |
||||
|
|
||||
|
|
||||
|
class CalendarDlg(BaseDialog): |
||||
|
def __init__(self, parent): |
||||
|
super(CalendarDlg, self).__init__(parent, |
||||
|
pickerClass=Classes.DatePickerCtrl, |
||||
|
pickerGetter=lambda datepicker: datepicker.GetValue().FormatISODate(), |
||||
|
localizedPickerLabel=_('select_date')) |
@ -0,0 +1,12 @@ |
|||||
|
|
||||
|
from .base_dialog import BaseDialog |
||||
|
from gooey.gui.three_to_four import Classes |
||||
|
from gooey.gui.lang.i18n import _ |
||||
|
|
||||
|
|
||||
|
class TimeDlg(BaseDialog): |
||||
|
def __init__(self, parent): |
||||
|
super(TimeDlg, self).__init__(parent, |
||||
|
pickerClass=Classes.TimePickerCtrl, |
||||
|
pickerGetter=lambda datepicker: datepicker.GetValue().FormatISOTime(), |
||||
|
localizedPickerLabel=_('select_time')) |
xxxxxxxxxx