Reputation: 1054
I am making a very simple interface that requires only three fields. The first one is a text input to introduce the name of a Team, the second one to choose my Team name and the third is a calendar input to introduce a date.
For that I am using the below code:
import PySimpleGUI as sg
layout = [[sg.Text('Interface', key='-TXT-')]
, [sg.Text('Team ID', size=(15, 1)), sg.InputText(size=(45, 1), key='-team_value-')]
, [sg.Text('Team Name', size=(15, 1),), sg.InputText(size=(45, 1), key='-team_name_value-')]
, [sg.Input(key='-IN4-', size=(20,1)), sg.CalendarButton('Calendar', target='-IN4-', default_date_m_d_y=(1,None,2020), )]
, [sg.Button('Introduce'), sg.Button('Search'), sg.Button('End'), sg.Button('Date Popup'), sg.Button('Cancel')]]
window = sg.Window('window', layout)
text_elem = window['-TXT-']
while True:
event, values = window.read()
print(event, values)
if event in (sg.WIN_CLOSED, 'Cancel'):
break
elif event == 'Date Popup':
sg.popup('You chose:', sg.popup_get_date())
window.close()
However, when I open my Calendar date I am not able to select any date, it just opens the calendar and stays static, and it doesn't allow me to choose any date.
What I am doing wrong?
Thanks
Upvotes: 1
Views: 877
Reputation: 44
I had the same problem. The solution is to not use the default theme. Set a new theme above your 'layout' declaration:
sg.theme("Dark Blue 3")
layout = [...]
Alternatively you can create your own theme. The calendar uses the "TEXT" color to color the date numbers and to highlight the first row of the calendar.
my_new_theme = {'BACKGROUND': '#ececec',
'TEXT': 'black',
'INPUT': 'white',
'TEXT_INPUT': 'black',
'SCROLL': 'white',
'BUTTON': ('black', 'white'),
'PROGRESS': ('#0091ff', '#D0D0D0'),
'BORDER': 1,
'SLIDER_DEPTH': 0,
'PROGRESS_DEPTH': 0}
sg.theme_add_new('my_custom_theme', my_new_theme)
sg.theme('my_custom_theme')
layout = [...]
Upvotes: 1