2019-10-23 20:10:03 +00:00
|
|
|
import PySimpleGUI as sg
|
2018-09-27 20:24:09 +00:00
|
|
|
|
2022-04-20 14:08:20 +00:00
|
|
|
"""
|
|
|
|
Demo - Yet another example of TabGroup element
|
|
|
|
|
|
|
|
These are simple tabs and tab groups. This example simply shows groups within groups.
|
|
|
|
Be careful with tabs to make sure you don't re-use a layout. If you used a layout in one tab
|
|
|
|
you cannot use it again in another tab.
|
|
|
|
|
|
|
|
There was an error in this demo for quite some time that makes for a great example of this error.
|
|
|
|
|
|
|
|
See how tab_layout is in both Tab elements? That's a no-go and you'll get an error poup
|
|
|
|
|
|
|
|
tab_group = sg.TabGroup([[sg.Tab('Tab 7', tab_layout), sg.Tab('Tab 8', tab_layout)]])
|
|
|
|
|
|
|
|
Copyright 2022 PySimpleGUI
|
|
|
|
"""
|
|
|
|
|
2018-09-24 22:01:00 +00:00
|
|
|
|
2019-12-24 23:52:47 +00:00
|
|
|
sg.theme('GreenTan')
|
2019-10-23 20:10:03 +00:00
|
|
|
tab2_layout = [[sg.Text('This is inside tab 2')],
|
|
|
|
[sg.Text('Tabs can be anywhere now!')]]
|
2018-09-24 22:01:00 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
tab1_layout = [[sg.Text('Type something here and click button'), sg.Input(key='in')]]
|
2018-09-24 22:01:00 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
tab3_layout = [[sg.Text('This is inside tab 3')]]
|
|
|
|
tab4_layout = [[sg.Text('This is inside tab 4')]]
|
|
|
|
|
2022-04-20 14:08:20 +00:00
|
|
|
tab_layout7 = [[sg.Text('This is inside of a tab')]]
|
|
|
|
tab_layout8 = [[sg.Text('This is inside of a tab')]]
|
|
|
|
tab_group = sg.TabGroup([[sg.Tab('Tab 7', tab_layout7), sg.Tab('Tab 8', tab_layout8)]])
|
2018-09-25 05:33:32 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
tab5_layout = [[sg.Text('Watch this window')],
|
2022-04-20 14:08:20 +00:00
|
|
|
[sg.Output(size=(40,5))]] # generally better to use a Multline, but for super-simple examples, Output is OK
|
2019-10-23 20:10:03 +00:00
|
|
|
tab6_layout = [[sg.Text('This is inside tab 6')],
|
|
|
|
[sg.Text('How about a second row of stuff in tab 6?'), tab_group]]
|
2018-09-24 22:01:00 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
layout = [[sg.Text('My Window!')], [sg.Frame('A Frame', layout=
|
2018-09-25 05:33:32 +00:00
|
|
|
[[sg.TabGroup([[sg.Tab('Tab 1', tab1_layout), sg.Tab('Tab 2', tab2_layout)]]), sg.TabGroup([[sg.Tab('Tab3', tab3_layout), sg.Tab('Tab 4', tab4_layout)]])]])],
|
2019-10-23 20:10:03 +00:00
|
|
|
[sg.Text('This text is on a row with a column'),sg.Col(layout=[[sg.Text('In a column')],
|
2018-09-24 22:01:00 +00:00
|
|
|
[sg.TabGroup([[sg.Tab('Tab 5', tab5_layout), sg.Tab('Tab 6', tab6_layout)]])],
|
2018-10-29 00:01:03 +00:00
|
|
|
[sg.Button('Click me')]])],]
|
2018-09-24 22:01:00 +00:00
|
|
|
|
2019-10-23 20:10:03 +00:00
|
|
|
window = sg.Window('My window with tabs', layout, default_element_size=(12,1), finalize=True)
|
2018-09-25 05:33:32 +00:00
|
|
|
|
|
|
|
print('Are there enough tabs for you?')
|
2018-09-24 22:01:00 +00:00
|
|
|
|
|
|
|
while True:
|
2019-10-23 20:10:03 +00:00
|
|
|
event, values = window.read()
|
2018-10-15 20:07:23 +00:00
|
|
|
print(event, values)
|
2020-05-07 10:22:59 +00:00
|
|
|
if event == sg.WIN_CLOSED: # always, always give a way out!
|
2019-10-23 20:10:03 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
window.close()
|