New super-simple form Demo

This commit is contained in:
PySimpleGUI 2020-05-16 12:54:45 -04:00
parent a46fde5e46
commit e00a427556
1 changed files with 9 additions and 9 deletions

View File

@ -1,11 +1,9 @@
import PySimpleGUI as sg import PySimpleGUI as sg
event, values = sg.Window('Window Title', [[sg.Text('Enter Something')], [sg.Input(key='-IN-'),],[sg.Button('OK'), sg.Button('Cancel')]]).read(close=True) """
Simple Form (a one-shot data entry window)
sg.popup(event, values) Use this design pattern to show a form one time to a user that is "submitted"
"""
# Basic Example
layout = [[sg.Text('Please enter your Name, Address, Phone')], layout = [[sg.Text('Please enter your Name, Address, Phone')],
[sg.Text('Name', size=(10, 1)), sg.InputText(key='-NAME-')], [sg.Text('Name', size=(10, 1)), sg.InputText(key='-NAME-')],
@ -15,6 +13,8 @@ layout = [[sg.Text('Please enter your Name, Address, Phone')],
window = sg.Window('Simple Data Entry Window', layout) window = sg.Window('Simple Data Entry Window', layout)
event, values = window.read(close=True) event, values = window.read(close=True)
print(event, values['-NAME-'], values['-ADDRESS-'], values['-PHONE-'])
sg.popup('test') if event == 'Submit':
window.close() print('The events was ', event, 'You input', values['-NAME-'], values['-ADDRESS-'], values['-PHONE-'])
else:
print('User cancelled')