PySimpleGUI/DemoPrograms/Demo_Tabs.py

57 lines
2.3 KiB
Python
Raw Normal View History

2018-09-27 20:24:09 +00:00
#!/usr/bin/env python
import sys
import PySimpleGUI as sg
2018-09-24 14:40:08 +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')
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
tab2_layout = [[sg.Text('This is inside tab 2', background_color='tan1')],
[sg.Input(key='-in2-')]]
tab3_layout = [[sg.Text('This is inside tab 3')],
[sg.Input(key='-in2-')]]
tab4_layout = [[sg.Text('This is inside tab 4', background_color='darkseagreen')],
[sg.Input(key='-in3-')]]
tab5_layout = [[sg.Text('This is inside tab 5')],
[sg.Input(key='-in4-')]]
layout = [[sg.TabGroup([[sg.Tab('Tab 1', tab1_layout, background_color='darkslateblue', key='-mykey-'),
sg.Tab('Tab 2', tab2_layout, background_color='tan1'),
sg.Tab('Tab 3', tab3_layout)]],
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-'),
sg.Tab('Tab 2', tab2_layout, background_color='tan1'),
sg.Tab('Tab 3', tab3_layout)]],
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
window = sg.Window('My window with tabs', layout,
default_element_size=(12, 1))
2018-09-24 14:40:08 +00:00
2018-09-24 14:53:24 +00:00
while True:
event, values = window.read()
sg.popup_non_blocking(event, values)
print(event, values)
if event is None: # always, always give a way out!
break
window.close()