Reputation: 1
I have added pysimplegui calendar and I have added another window to add events. I am looking for a way to show events inside calendar ? please give some ideas
Upvotes: 0
Views: 799
Reputation: 13051
Two ways to get date
CalendarButton
element with an enable_events=True
Input
element, the event will be the key of the Input
element.Button
element with an Input
element, the event will be the key of the Button
element to call function popup_get_date
and update the date to the Input
element if date selected.import PySimpleGUI as sg
layout = [
# First way
[sg.Input(readonly=True, enable_events=True, key='INPUT 1'),
sg.CalendarButton('Calendar 1', close_when_date_chosen=True, format='%Y-%m-%d', key='Calendar 1')],
# Second way
[sg.Input(readonly=True, key='INPUT 2'),
sg.Button('Calendar 2')],
]
window = sg.Window('Calendar Button', layout)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
print(event)
if event == 'Input 1':
print(values[event])
elif event == 'Calendar 2':
date = sg.popup_get_date(close_when_chosen=True)
if date:
m, d, y = date
window['INPUT 2'].update(f'{y:0>4d}-{m:0>2d}-{d:0>2d}')
window.close()
Upvotes: 2