diff --git a/README.md b/README.md
index f1ed49a..5c18891 100644
--- a/README.md
+++ b/README.md
@@ -195,8 +195,8 @@ However, by dropping in `GooeyParser` and supplying a `widget` name, you can dis
| Widget | Example |
|----------------|------------------------------|
-| DirChooser, MultiDirChooser, FileChooser, MultiFileChooser, FileSaver |

|
-| DateChooser | 
|
+| DirChooser, FileChooser, MultiFileChooser, FileSaver, MultiFileSaver | 
|
+| DateChooser/TimeChooser | 
Please note that for both of these widgets the values passed to the application will always be in [ISO format](https://www.wxpython.org/Phoenix/docs/html/wx.DateTime.html#wx.DateTime.FormatISOTime) while localized values may appear in some parts of the GUI depending on end-user settings.
|
| PasswordField | 
|
| Listbox |  |
| BlockCheckbox | 
The default InlineCheck box can look less than ideal if a large help text block is present. `BlockCheckbox` moves the text block to the normal position and provides a short-form `block_label` for display next to the control. Use `gooey_options.checkbox_label` to control the label text |
diff --git a/gooey/gui/components/widgets/choosers.py b/gooey/gui/components/widgets/choosers.py
index 8e7a485..dcdd808 100644
--- a/gooey/gui/components/widgets/choosers.py
+++ b/gooey/gui/components/widgets/choosers.py
@@ -10,9 +10,11 @@ __ALL__ = [
'DirChooser',
'MultiDirChooser',
'DateChooser',
- 'ColourChooser'
+ 'ColourChooser',
+ 'TimeChooser'
]
+
class FileChooser(BaseChooser):
# todo: allow wildcard from argparse
widget_class = core.FileChooser
@@ -51,3 +53,7 @@ class DateChooser(BaseChooser):
class ColourChooser(BaseChooser):
widget_class = core.ColourChooser
+
+
+class TimeChooser(BaseChooser):
+ widget_class = core.TimeChooser
diff --git a/gooey/gui/components/widgets/core/__init__.py b/gooey/gui/components/widgets/core/__init__.py
index 646b555..f0a9683 100644
--- a/gooey/gui/components/widgets/core/__init__.py
+++ b/gooey/gui/components/widgets/core/__init__.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
diff --git a/gooey/gui/components/widgets/core/chooser.py b/gooey/gui/components/widgets/core/chooser.py
index 684fa10..26151b1 100644
--- a/gooey/gui/components/widgets/core/chooser.py
+++ b/gooey/gui/components/widgets/core/chooser.py
@@ -5,6 +5,7 @@ import re
from gooey.gui.components.widgets.core.text_input import TextInput
from gooey.gui.components.widgets.dialogs.calender_dialog import CalendarDlg
+from gooey.gui.components.widgets.dialogs.time_dialog import TimeDlg
from gooey.gui.lang.i18n import _
from gooey.util.functional import merge
@@ -140,6 +141,16 @@ class DateChooser(Chooser):
def getDialog(self):
return CalendarDlg(self)
+class TimeChooser(Chooser):
+ """ Launches a time picker which returns and ISO Time """
+ def __init__(self, *args, **kwargs):
+ defaults = {'label': _('choose_time')}
+ super(TimeChooser, self).__init__(*args, **merge(kwargs, defaults))
+
+
+ def getDialog(self):
+ return TimeDlg(self)
+
class ColourChooser(Chooser):
""" Launches a color picker which returns a hex color code"""
diff --git a/gooey/gui/components/widgets/dialogs/base_dialog.py b/gooey/gui/components/widgets/dialogs/base_dialog.py
new file mode 100644
index 0000000..2e35053
--- /dev/null
+++ b/gooey/gui/components/widgets/dialogs/base_dialog.py
@@ -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)
+
+
+
diff --git a/gooey/gui/components/widgets/dialogs/calender_dialog.py b/gooey/gui/components/widgets/dialogs/calender_dialog.py
index c565833..f664fd2 100644
--- a/gooey/gui/components/widgets/dialogs/calender_dialog.py
+++ b/gooey/gui/components/widgets/dialogs/calender_dialog.py
@@ -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'))
\ No newline at end of file
diff --git a/gooey/gui/components/widgets/dialogs/time_dialog.py b/gooey/gui/components/widgets/dialogs/time_dialog.py
new file mode 100644
index 0000000..3b1af27
--- /dev/null
+++ b/gooey/gui/components/widgets/dialogs/time_dialog.py
@@ -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'))
diff --git a/gooey/gui/three_to_four.py b/gooey/gui/three_to_four.py
index 69c4ad3..100f770 100644
--- a/gooey/gui/three_to_four.py
+++ b/gooey/gui/three_to_four.py
@@ -26,6 +26,11 @@ class Classes:
else:
DatePickerCtrl = wx.DatePickerCtrl
+ if isLatestVersion:
+ TimePickerCtrl = wx.adv.TimePickerCtrl
+ else:
+ TimePickerCtrl = wx.TimePickerCtrl
+
diff --git a/gooey/languages/english.json b/gooey/languages/english.json
index 951e743..ac72abd 100644
--- a/gooey/languages/english.json
+++ b/gooey/languages/english.json
@@ -4,6 +4,7 @@
"checkbox_label": "Enable",
"choose_colour": "Choose Colour",
"choose_date": "Choose Date",
+ "choose_time": "Choose Time",
"choose_file": "Choose File",
"choose_folder": "Choose Folder",
"choose_folders_msg": "Choose one or more folders:",
@@ -29,6 +30,7 @@
"running_msg": "Please wait while the application performs its tasks. \nThis may take a few moments",
"running_title": "Running",
"select_date": "Select a Date",
+ "select_time": "Select a Time",
"select_option": "Select Option",
"settings_title": "Settings",
"simple_config": "Enter Command Line Arguments",
diff --git a/gooey/languages/french.json b/gooey/languages/french.json
index b1b3401..3ad3eab 100644
--- a/gooey/languages/french.json
+++ b/gooey/languages/french.json
@@ -2,6 +2,7 @@
"browse": "Naviguer",
"cancel": "Annuler",
"choose_date": "Choisir une date",
+ "choose_time": "Choisir une heure",
"choose_file": "Choisir un fichier",
"choose_folder": "Choisir un dossier",
"choose_one": "Choisir entre :",
@@ -16,12 +17,15 @@
"finished_forced_quit": "Stoppé par l'utilisateur",
"finished_msg": "Terminé ! Vous pouvez maintenant fermer le programme.",
"finished_title": "Terminé",
+ "ok": "Ok",
"open_file": "Ouvrir fichier",
"optional_args_msg": "Arguments optionnels",
"required_args_msg": "Arguments obligatoires",
"restart": "Redémarrer",
"running_msg": "Veuillez attendre la fin de l'exécution. \nCela peut prendre quelques instants.",
"running_title": "Exécution en cours.",
+ "select_date": "Sélectionner une date",
+ "select_time": "Sélectionner une heure",
"select_option": "Sélectionner une option",
"settings_title": "Paramètres",
"simple_config": "Entrer les arguments de ligne de commande",
diff --git a/gooey/python_bindings/argparse_to_json.py b/gooey/python_bindings/argparse_to_json.py
index f20b0ac..7def51e 100644
--- a/gooey/python_bindings/argparse_to_json.py
+++ b/gooey/python_bindings/argparse_to_json.py
@@ -26,6 +26,7 @@ VALID_WIDGETS = (
'FileSaver',
'DirChooser',
'DateChooser',
+ 'TimeChooser',
'TextField',
'Dropdown',
'Counter',