als PySimpleGUI-Neuling stelle ich mir gerade folgende frage:
Ich habe eine Funktion welche mir aus mehreren json Dateien Inhalte ausliest:
Code: Alles auswählen
#####---- create the list of files -----#######
dir_path = os.path.dirname(os.path.realpath(__file__))
filePath = str(dir_path +"/datafiles/")
list_of_files = glob.glob(filePath+ '*.json')
####---- read files and show content for every file in path ----#######
def readShoes(lang_params):
print(lang_params["text01"])
for file_name in list_of_files:
with open(file_name) as json_file:
data = json.load(json_file)
for p in data['Details']:
print('Name: ' + p['Name'])
print('KM: ' + p['KM'])
print(lang_params["date01"], ':' + p['Date'])
print('')
json_file.close()
Code: Alles auswählen
#read language paramters/text
lang_params=readLanguageKey() #dienst zum auslesen der Anzeige texte (gespeichert in properties für Mehrsprachigkeit)
sg.change_look_and_feel('BrownBlue')
#create a button
layout = [
[sg.Text("The ShoeAdmin-Tool")],
[sg.Button(lang_params["option01"])]
]
#create the mainWindow
mainWindow = sg.Window("ShoeAdmin", layout, size=(600,400))
#create an event loop
while True:
event, values = mainWindow.read()
if event == sg.WIN_CLOSED:
break
if event == lang_params["option01"]:
readShoes(). #hier wollte ich auf die Funktion zugreifen
Aber wie bekomme ich die Verknüpfung zwischen einem Textfeld und dem anzuzeigendem text hin?
Danke schon mal für eure Unterstzützung.