Tabs - location and bar color changes. New demo to show tab location, color
This commit is contained in:
parent
d46a292128
commit
71dca41dfa
12
Demo_Tabs.py
12
Demo_Tabs.py
|
@ -8,9 +8,17 @@ else:
|
||||||
tab1_layout = [[sg.T('This is inside tab 1')]]
|
tab1_layout = [[sg.T('This is inside tab 1')]]
|
||||||
|
|
||||||
tab2_layout = [[sg.T('This is inside tab 2')],
|
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')]]
|
[sg.RButton('Read')]]
|
||||||
|
|
||||||
window = sg.Window('My window with tabs', default_element_size=(12,1)).Layout(layout)
|
window = sg.Window('My window with tabs', default_element_size=(12,1)).Layout(layout)
|
||||||
|
|
|
@ -3397,21 +3397,22 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
|
|
||||||
if element.TabLocation is not None:
|
if element.TabLocation is not None:
|
||||||
style = ttk.Style(tk_row_frame)
|
style = ttk.Style(tk_row_frame)
|
||||||
|
custom_style = str(element.Key)+'customtab.TNotebook'
|
||||||
if element.TabLocation == 'left':
|
if element.TabLocation == 'left':
|
||||||
style.configure('customtab.TNotebook', tabposition='ws')
|
style.configure(custom_style, tabposition='ws')
|
||||||
elif element.TabLocation == 'right':
|
elif element.TabLocation == 'right':
|
||||||
style.configure('customtab.TNotebook', tabposition='es')
|
style.configure(custom_style, tabposition='es')
|
||||||
elif element.TabLocation == 'top':
|
|
||||||
style.configure('customtab.TNotebook', tabposition='nw')
|
|
||||||
elif element.TabLocation == 'bottom':
|
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:
|
else:
|
||||||
element.TKNotebook = ttk.Notebook(tk_row_frame)
|
element.TKNotebook = ttk.Notebook(tk_row_frame)
|
||||||
|
|
||||||
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
|
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)
|
PackFormIntoFrame(element, toplevel_form.TKroot, toplevel_form)
|
||||||
|
|
Loading…
Reference in New Issue