2018-09-27 20:24:09 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import sys
|
2019-10-23 20:10:03 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-09-24 14:40:08 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
# Usage of Tabs in PSG
|
2019-12-24 23:52:47 +00:00
|
|
|
#
|
|
|
|
# sg.set_options(background_color='cornsilk4',
|
|
|
|
# element_background_color='cornsilk2',
|
|
|
|
# input_elements_background_color='cornsilk2')
|
2018-09-24 14:40:08 +00:00
|
|
|
|
2019-12-24 23:52:47 +00:00
|
|
|
sg.theme('Light Green 5')
|
2018-10-04 23:42:25 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
tab1_layout = [[sg.Text('This is inside tab 1', background_color='darkslateblue', text_color='white')],
|
|
|
|
[sg.Input(key='-in0-')]]
|
2018-09-24 14:40:08 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
tab2_layout = [[sg.Text('This is inside tab 2', background_color='tan1')],
|
|
|
|
[sg.Input(key='-in2-')]]
|
2018-10-04 23:42:25 +00:00
|
|
|
|
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
tab3_layout = [[sg.Text('This is inside tab 3')],
|
|
|
|
[sg.Input(key='-in2-')]]
|
2018-10-03 18:00:44 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
tab4_layout = [[sg.Text('This is inside tab 4', background_color='darkseagreen')],
|
|
|
|
[sg.Input(key='-in3-')]]
|
2018-10-03 18:00:44 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
tab5_layout = [[sg.Text('This is inside tab 5')],
|
|
|
|
[sg.Input(key='-in4-')]]
|
2018-10-03 18:00:44 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
|
|
|
|
layout = [[sg.TabGroup([[sg.Tab('Tab 1', tab1_layout, background_color='darkslateblue', key='-mykey-'),
|
2018-10-04 23:42:25 +00:00
|
|
|
sg.Tab('Tab 2', tab2_layout, background_color='tan1'),
|
|
|
|
sg.Tab('Tab 3', tab3_layout)]],
|
2019-10-23 20:10:03 +00:00
|
|
|
key='-group2-', title_color='red',
|
|
|
|
selected_title_color='green', tab_location='right'),
|
|
|
|
sg.TabGroup([[sg.Tab('Tab 4', tab4_layout, background_color='darkseagreen', key='-mykey-'),
|
|
|
|
sg.Tab('Tab 5', tab5_layout)]], key='-group1-', tab_location='top', selected_title_color='purple')],
|
|
|
|
[sg.TabGroup([[sg.Tab('Tab 1', tab1_layout, background_color='darkslateblue', key='-mykey-'),
|
2018-10-04 23:42:25 +00:00
|
|
|
sg.Tab('Tab 2', tab2_layout, background_color='tan1'),
|
|
|
|
sg.Tab('Tab 3', tab3_layout)]],
|
2019-10-23 20:10:03 +00:00
|
|
|
key='-group3-', title_color='red',
|
|
|
|
selected_title_color='green', tab_location='left'),
|
|
|
|
sg.TabGroup([[sg.Tab('Tab 4', tab4_layout, background_color='darkseagreen', key='-mykey-'),
|
|
|
|
sg.Tab('Tab 5', tab5_layout)]], key='-group4-', tab_location='bottom', selected_title_color='purple')],
|
|
|
|
[sg.Button('Read')]]
|
2018-09-24 14:40:08 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
window = sg.Window('My window with tabs', layout,
|
|
|
|
default_element_size=(12, 1))
|
2018-09-24 14:40:08 +00:00
|
|
|
|
2018-10-04 23:42:25 +00:00
|
|
|
|
2018-09-24 14:53:24 +00:00
|
|
|
while True:
|
2019-10-23 20:10:03 +00:00
|
|
|
event, values = window.read()
|
|
|
|
sg.popup_non_blocking(event, values)
|
2018-10-15 20:07:23 +00:00
|
|
|
print(event, values)
|
|
|
|
if event is None: # always, always give a way out!
|
2018-10-04 23:42:25 +00:00
|
|
|
break
|
2019-10-23 20:10:03 +00:00
|
|
|
window.close()
|