2019-09-20 20:59:15 +00:00
|
|
|
import PySimpleGUI as sg
|
|
|
|
|
2019-12-24 23:52:47 +00:00
|
|
|
sg.theme('GreenTan')
|
2019-09-20 20:59:15 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
col1 = sg.Col([[sg.Text('in pane1', text_color='blue')],
|
|
|
|
[sg.Text('Pane1')],
|
|
|
|
[sg.Text('Pane1')],
|
|
|
|
])
|
|
|
|
col2 = sg.Col([[sg.Text('in pane2', text_color='red')],
|
|
|
|
[sg.Text('Pane2')],
|
|
|
|
[sg.Input('', key='-IN2-')],
|
|
|
|
[sg.Text('Pane2')],
|
|
|
|
[sg.Text('Pane2')],
|
|
|
|
], key='-COL2-', visible=False)
|
|
|
|
col3 = sg.Col([[sg.Text('in pane 4', text_color='green')],
|
|
|
|
[sg.Input(key='-IN3-', enable_events=True)],
|
|
|
|
], key='-COL3-', visible=False)
|
|
|
|
col4 = sg.Col([[sg.Text('Column 4', text_color='firebrick')],
|
|
|
|
[sg.Input()],
|
|
|
|
], key='-COL4-')
|
|
|
|
col5 = sg.Col([[sg.Frame('Frame', [[sg.Text('Column 5', text_color='purple')],
|
|
|
|
[sg.Input()],
|
|
|
|
])]])
|
2019-09-20 20:59:15 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
layout = [[sg.Text('Click'), sg.Text('', key='-OUTPUT-')],
|
|
|
|
[sg.Button('Remove'), sg.Button('Add')],
|
|
|
|
[sg.Pane([col5,
|
|
|
|
sg.Col([[sg.Pane([col1, col2, col4], handle_size=15,
|
|
|
|
orientation='v', background_color='red', show_handle=True,
|
|
|
|
visible=True, key='-PANE-', border_width=0,
|
|
|
|
relief=sg.RELIEF_GROOVE), ]]), col3],
|
|
|
|
orientation='h', background_color=None, size=(160, 160),
|
|
|
|
relief=sg.RELIEF_RAISED, border_width=0)]
|
|
|
|
]
|
2019-09-20 20:59:15 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
window = sg.Window('Window Title', layout, border_depth=5,
|
|
|
|
default_element_size=(15, 1), resizable=True)
|
2019-09-20 20:59:15 +00:00
|
|
|
|
|
|
|
while True: # Event Loop
|
2019-10-23 20:10:03 +00:00
|
|
|
event, values = window.read()
|
2019-09-20 20:59:15 +00:00
|
|
|
print(event, values)
|
2019-10-23 20:10:03 +00:00
|
|
|
if event in (None, 'Exit'):
|
2019-09-20 20:59:15 +00:00
|
|
|
break
|
|
|
|
if event == 'Remove':
|
2019-10-23 20:10:03 +00:00
|
|
|
window['-COL2-'].update(visible=False)
|
|
|
|
window['-COL3-'].update(visible=False)
|
2019-09-20 20:59:15 +00:00
|
|
|
elif event == 'Add':
|
2019-10-23 20:10:03 +00:00
|
|
|
window['-COL2-'].update(visible=True)
|
|
|
|
window['-COL3-'].update(visible=True)
|
|
|
|
window['-IN2-'].update(values['-IN3-'])
|
2019-09-20 20:59:15 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
window.close()
|