From 73a66290456bb8e8e2a85be03b2b6402ed6fd524 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Fri, 6 Jan 2023 15:53:48 -0500 Subject: [PATCH] Added option to enable/disable manual entry --- DemoPrograms/Demo_Time_Chooser.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DemoPrograms/Demo_Time_Chooser.py b/DemoPrograms/Demo_Time_Chooser.py index eb36b66e..89e20a97 100644 --- a/DemoPrograms/Demo_Time_Chooser.py +++ b/DemoPrograms/Demo_Time_Chooser.py @@ -16,7 +16,7 @@ import PySimpleGUI as sg -def popup_get_time(title='Time Entry', starting_hour=1, starting_minute=0, font=None): +def popup_get_time(title='Time Entry', starting_hour=1, starting_minute=0, allow_manual_input=True, font=None): """ Shows a window that will gather a time of day. @@ -26,6 +26,8 @@ def popup_get_time(title='Time Entry', starting_hour=1, starting_minute=0, font= :type starting_hour: int :param starting_minute: Value to initially show in the minute field :type starting_minute: int + :param allow_manual_input: If True, then the Spin elements can be manually edited + :type allow_manual_input: bool :param font: Font to use for the window :type font: str | tuple :return: Tuple with format: (hour, minute, am-pm string) @@ -36,9 +38,9 @@ def popup_get_time(title='Time Entry', starting_hour=1, starting_minute=0, font= hour_list = [i for i in range(0, 15)] minute_list = [i for i in range(-1, 62)] - layout = [[sg.Spin(hour_list, initial_value=starting_hour, key='-HOUR-', s=3, enable_events=True, readonly=False), + layout = [[sg.Spin(hour_list, initial_value=starting_hour, key='-HOUR-', s=3, enable_events=True, readonly=not allow_manual_input), sg.Text(':'), - sg.Spin(minute_list, initial_value=starting_minute, key='-MIN-', s=3, enable_events=True, readonly=False), + sg.Spin(minute_list, initial_value=starting_minute, key='-MIN-', s=3, enable_events=True, readonly=not allow_manual_input), sg.Combo(['AM', 'PM'], 'AM', readonly=True, key='-AMPM-')], [sg.Button('Ok'), sg.Button('Cancel')]]