Good afternoon, I'm brand new with PySimpleGUI and I would like to know if it's possible to create a variable from input of button in one window that can be available as a global variable everywhere in the main program even when the window is closed.
Thanks for help
CodePudding user response:
Temp Code - variables a
created and still keep the same after window close.
import PySimpleGUI as sg
sg.theme("DarkBlue3")
layout = [
[sg.T("Window")],
[sg.Button("Create"), sg.Button("Exit")],
]
window = sg.Window('My File Browser', layout)
while True:
event, values = window.read()
if event in (sg.WINDOW_CLOSED, "Exit"):
break
elif event == "Create":
exec("a=10")
window.close()
print(a)
CodePudding user response:
Thanks for your answer. Finally i've found that my problem was due to the identation of a part of it. Now the global declaration works as it must.