Merge pull request #411 from MikeTheWatchGuy/Dev-latest

Tab text color and selected text color options (still no background c…
This commit is contained in:
MikeTheWatchGuy 2018-10-03 15:37:47 -04:00 committed by GitHub
commit dc9d627ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 16 deletions

View File

@ -1539,7 +1539,7 @@ class Tab(Element):
# TabGroup # # TabGroup #
# ---------------------------------------------------------------------- # # ---------------------------------------------------------------------- #
class TabGroup(Element): class TabGroup(Element):
def __init__(self, layout, tab_location=None, title_color=None, background_color=None, font=None, change_submits=False, pad=None, border_width=None, key=None, tooltip=None): def __init__(self, layout, tab_location=None, title_color=None, selected_title_color=None, background_color=None, font=None, change_submits=False, pad=None, border_width=None, key=None, tooltip=None):
self.UseDictionary = False self.UseDictionary = False
self.ReturnValues = None self.ReturnValues = None
@ -1547,6 +1547,7 @@ class TabGroup(Element):
self.ReturnValuesDictionary = {} self.ReturnValuesDictionary = {}
self.DictionaryKeyCounter = 0 self.DictionaryKeyCounter = 0
self.ParentWindow = None self.ParentWindow = None
self.SelectedTitleColor = selected_title_color
self.Rows = [] self.Rows = []
self.TKNotebook = None self.TKNotebook = None
self.BorderWidth = border_width self.BorderWidth = border_width
@ -3395,26 +3396,37 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# ------------------------- TabGroup element ------------------------- # # ------------------------- TabGroup element ------------------------- #
elif element_type == ELEM_TYPE_TAB_GROUP: elif element_type == ELEM_TYPE_TAB_GROUP:
custom_style = str(element.Key)+'customtab.TNotebook'
style = ttk.Style(tk_row_frame)
if element.TabLocation is not None: if element.TabLocation is not None:
style = ttk.Style(tk_row_frame) position_dict = {'left':'w','right':'e', 'top':'n', 'bottom':'s', 'lefttop':'wn', 'leftbottom':'ws', 'righttop':'en', 'rightbottom':'es', 'bottomleft':'sw', 'bottomright':'se', 'topleft':'nw', 'topright':'ne'}
custom_style = str(element.Key)+'customtab.TNotebook' try:
if element.TabLocation == 'left': tab_position = position_dict[element.TabLocation]
style.configure(custom_style, tabposition='ws') except:
elif element.TabLocation == 'right': tab_position = position_dict['top']
style.configure(custom_style, tabposition='es') style.configure(custom_style, tabposition=tab_position)
elif element.TabLocation == 'bottom':
style.configure(custom_style, tabposition='sw')
else:
style.configure(custom_style, tabposition='nw')
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: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
ttk.Style().configure(str(element.Key)+'customtab.TNotebook', background=element.BackgroundColor) style.configure(custom_style, background=element.BackgroundColor, foreground='purple')
# style.theme_create("yummy", parent="alt", settings={
# "TNotebook": {"configure": {"tabmargins": [2, 5, 2, 0]}},
# "TNotebook.Tab": {
# "configure": {"padding": [5, 1], "background": mygreen},
# "map": {"background": [("selected", myred)],
# "expand": [("selected", [1, 1, 1, 0])]}}})
# style.configure(custom_style+'.Tab', background='red')
if element.SelectedTitleColor != None:
style.map(custom_style+'.Tab', foreground=[("selected",element.SelectedTitleColor)])
if element.TextColor is not None and element.TextColor != COLOR_SYSTEM_DEFAULT:
style.configure(custom_style+'.Tab', foreground=element.TextColor)
# style.configure(custom_style, background='blue', foreground='yellow')
element.TKNotebook = ttk.Notebook(tk_row_frame, style=custom_style)
PackFormIntoFrame(element, toplevel_form.TKroot, toplevel_form) PackFormIntoFrame(element, toplevel_form.TKroot, toplevel_form)
if element.ChangeSubmits: if element.ChangeSubmits: