Merge pull request #2743 from PySimpleGUI/Dev-latest

Updated Calendar Demo to use new calendar chooser
This commit is contained in:
PySimpleGUI 2020-03-30 10:13:37 -04:00 committed by GitHub
commit 0581489d06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 8 deletions

View File

@ -1,13 +1,24 @@
#!/usr/bin/env python
import PySimpleGUI as sg
"""
Simple test harness to demonstate how to use the CalendarButton and the get date popup
"""
layout = [[sg.Text('Calendar Test')],
[sg.Input('', size=(20, 1), key='input')],
[sg.CalendarButton('Choose Date', target='input', key='date')],
[sg.Ok(key=1)]]
layout = [[sg.Text('Date Chooser Test Harness', key='-TXT-')],
[sg.Input(key='-IN-', size=(20,1)), sg.CalendarButton('Cal US No Buttons', close_when_date_chosen=True, target='-IN-')],
[sg.Input(key='-IN3-', size=(20,1)), sg.CalendarButton('Cal US Monday', close_when_date_chosen=False, target='-IN3-', begin_at_sunday_plus=1)],
[sg.Input(key='-IN2-', size=(20,1)), sg.CalendarButton('Cal German Feb 2020', target='-IN2-', default_date_m_d_y=(2,None,2020), locale='de_DE', begin_at_sunday_plus=1 )],
[sg.Input(key='-IN4-', size=(20,1)), sg.CalendarButton('Cal Format %m-%d', target='-IN4-', format='%m-%d', default_date_m_d_y=(2,None,2020), locale='de_DE', begin_at_sunday_plus=1 )],
[sg.Button('Read'), sg.Button('Date Popup'), sg.Exit()]]
window = sg.Window('Calendar', layout, grab_anywhere=False)
event, values = window.read()
sg.popup(values['input'])
windowclose()
window = sg.Window('window', layout)
while True:
event, values = window.read()
print(event, values)
if event in (None, 'Exit'):
break
elif event == 'Date Popup':
sg.popup('You chose:', sg.popup_get_date())
window.close()