GUI 入力文字をポップアップで表示する

1/30/2024 何かの役に立つかもね。

# 入力文字をポップアップで表示する.py 

import PySimpleGUI as sg

layout = [
    [sg.Text('入力して下さい'), sg.InputText(key='-Input-')],
    [sg.Button('入力結果を出力します', key='-Btn-')]
]

window = sg.Window('InputTextの値を取得', layout, size=(200, 70))

while True:
    event, value = window.read()  # イベントの入力を待つ

    if event == '-Btn-':
        output = value['-Input-']
        sg.popup(output)
        break
    elif event is None:
        break

window.close()