diff --git a/Demo_Tabs.py b/Demo_Tabs.py index 673c9307..142f42f2 100644 --- a/Demo_Tabs.py +++ b/Demo_Tabs.py @@ -8,9 +8,17 @@ else: tab1_layout = [[sg.T('This is inside tab 1')]] tab2_layout = [[sg.T('This is inside tab 2')], - [sg.In(key='in')]] + [sg.In(key='_in2_')]] -layout = [[sg.TabGroup([[sg.Tab('Tab 1', tab1_layout), sg.Tab('Tab 2', tab2_layout)]])], +tab3_layout = [[sg.T('This is inside tab 3')], + [sg.In(key='_in3_')]] + +tab4_layout = [[sg.T('This is inside tab 4')], + [sg.In(key='_in4_')]] + + +layout = [[sg.TabGroup([[sg.Tab('Tab 1', tab1_layout, key='_mykey_'), sg.Tab('Tab 2', tab2_layout)]], key='_group2_', background_color='green', tab_location='top')], +[sg.TabGroup([[sg.Tab('Tab 3', tab3_layout, key='_mykey_'), sg.Tab('Tab 4', tab4_layout)]], key='_group1_', tab_location='right')], [sg.RButton('Read')]] window = sg.Window('My window with tabs', default_element_size=(12,1)).Layout(layout) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 6cfef052..effff60c 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -3397,21 +3397,22 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): if element.TabLocation is not None: style = ttk.Style(tk_row_frame) + custom_style = str(element.Key)+'customtab.TNotebook' if element.TabLocation == 'left': - style.configure('customtab.TNotebook', tabposition='ws') + style.configure(custom_style, tabposition='ws') elif element.TabLocation == 'right': - style.configure('customtab.TNotebook', tabposition='es') - elif element.TabLocation == 'top': - style.configure('customtab.TNotebook', tabposition='nw') + style.configure(custom_style, tabposition='es') elif element.TabLocation == 'bottom': - style.configure('customtab.TNotebook', tabposition='sw') + style.configure(custom_style, tabposition='sw') + else: + style.configure(custom_style, tabposition='nw') - element.TKNotebook = ttk.Notebook(tk_row_frame, style='customtab.TNotebook') + element.TKNotebook = ttk.Notebook(tk_row_frame, style=custom_style) else: element.TKNotebook = ttk.Notebook(tk_row_frame) if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - ttk.Style().configure("TNotebook", background=element.BackgroundColor) + ttk.Style().configure(str(element.Key)+'customtab.TNotebook', background=element.BackgroundColor) PackFormIntoFrame(element, toplevel_form.TKroot, toplevel_form)