I want to add a feature to change the background using the menu but it doesn't work. When I click on any menu item, nothing happens, the background doesn't change and it doesn't print anything. Maybe I'm also doing the background change in a wrong way, so, if someone could help me, I would be happy.
This is my code:
from time import sleep
import os
try:
import PySimpleGUI as sg
except ModuleNotFoundError:
os.system('pip3 install PySimpleGUI')
import sys
theme = ('dark grey 9')
sg.theme(theme)
menu_def = [['Customize GUI', ['Background', ['White::white', 'Purple::purple']]]]
layout = [[sg.Menu(menu_def)]]
window = sg.Window('Fast reader by Hary', layout)
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
if event == 'Purple::purple':
theme = 'LightPurple'
window.refresh()
elif event == 'White::white':
theme = 'DarkGrey6'
window.refresh()