Merge pull request #2595 from PySimpleGUI/Dev-latest

Added test to show using Tab.select()
This commit is contained in:
PySimpleGUI 2020-02-10 12:06:40 -05:00 committed by GitHub
commit 5959bcecce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 7 deletions

View File

@ -17,19 +17,14 @@ tab4_layout = [[sg.Text('Tab 3')]]
tab_group_layout = [[sg.Tab('Tab 1', tab1_layout, font='Courier 15', key='-TAB1-'), tab_group_layout = [[sg.Tab('Tab 1', tab1_layout, font='Courier 15', key='-TAB1-'),
sg.Tab('Tab 2', tab2_layout, visible=False, key='-TAB2-'), sg.Tab('Tab 2', tab2_layout, visible=False, key='-TAB2-'),
sg.Tab('Tab 3', tab3_layout, key='-TAB3-'), sg.Tab('Tab 3', tab3_layout, key='-TAB3-'),
sg.Tab('Tab 4', tab3_layout, visible=False, key='-TAB4-'), sg.Tab('Tab 4', tab4_layout, visible=False, key='-TAB4-'),
]] ]]
# The window layout - defines the entire window # The window layout - defines the entire window
layout = [[sg.TabGroup(tab_group_layout, layout = [[sg.TabGroup(tab_group_layout,
# selected_title_color='blue',
# selected_background_color='red',
# tab_background_color='green',
enable_events=True, enable_events=True,
# font='Courier 18',
key='-TABGROUP-')], key='-TABGROUP-')],
[sg.Text('Make tab number'), sg.Input(key='-IN-', size=(3,1)), sg.Button('Invisible'), sg.Button('Visible')]] [sg.Text('Make tab number'), sg.Input(key='-IN-', size=(3,1)), sg.Button('Invisible'), sg.Button('Visible'), sg.Button('Select')]]
window = sg.Window('My window with tabs', layout, no_titlebar=False) window = sg.Window('My window with tabs', layout, no_titlebar=False)
@ -44,5 +39,7 @@ while True:
window[tab_keys[int(values['-IN-'])-1]].update(visible=False) window[tab_keys[int(values['-IN-'])-1]].update(visible=False)
if event == 'Visible': if event == 'Visible':
window[tab_keys[int(values['-IN-'])-1]].update(visible=True) window[tab_keys[int(values['-IN-'])-1]].update(visible=True)
if event == 'Select':
window[tab_keys[int(values['-IN-'])-1]].select()
window.close() window.close()