Merge pull request #6147 from PySimpleGUI/Dev-latest

Added option to enable/disable manual entry
This commit is contained in:
MikeTheWatchGuy 2023-01-06 15:54:02 -05:00 committed by GitHub
commit cc08622d06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -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')]]