From 5f3646a252de9f0762b74ad94a989da3d001e5f2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 5 Oct 2018 14:30:58 -0400 Subject: [PATCH] New feature - Theme for tabs --- Demo_Pyploy_Bar_Chart2.py | 17 +---------------- PySimpleGUI.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Demo_Pyploy_Bar_Chart2.py b/Demo_Pyploy_Bar_Chart2.py index 37c9339c..4c8e166c 100644 --- a/Demo_Pyploy_Bar_Chart2.py +++ b/Demo_Pyploy_Bar_Chart2.py @@ -29,22 +29,7 @@ import matplotlib.pyplot as plt import numpy as np label = ['Adventure', 'Action', 'Drama', 'Comedy', 'Thriller/Suspense', 'Horror', 'Romantic Comedy', 'Musical', 'Documentary', 'Black Comedy', 'Western', 'Concert/Performance', 'Multiple Genres', 'Reality'] -no_movies = [ - 941, - 854, - 4595, - 2125, - 942, - 509, - 548, - 149, - 1952, - 161, - 64, - 61, - 35, - 5 -] +no_movies = [941, 854, 4595, 2125, 942, 509, 548, 149, 1952, 161, 64, 61, 35, 5] index = np.arange(len(label)) plt.bar(index, no_movies) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 3dc89358..6b53159c 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -137,6 +137,14 @@ TITLE_LOCATION_TOP_RIGHT = tk.NE TITLE_LOCATION_BOTTOM_LEFT = tk.SW TITLE_LOCATION_BOTTOM_RIGHT = tk.SE +THEME_DEFAULT = 'default' +THEME_WINNATIVE = 'winnative' +THEME_CLAM = 'clam' +THEME_ALT = 'alt' +THEME_CLASSIC = 'classic' +THEME_VISTA = 'vista' +THEME_XPNATIVE = 'xpnative' + # DEFAULT_METER_ORIENTATION = 'Vertical' # ----====----====----==== Constants the user should NOT f-with ====----====----====----# @@ -1550,7 +1558,7 @@ class Tab(Element): # TabGroup # # ---------------------------------------------------------------------- # class TabGroup(Element): - 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): + 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, theme=None, key=None, tooltip=None): self.UseDictionary = False self.ReturnValues = None @@ -1563,6 +1571,7 @@ class TabGroup(Element): self.TKNotebook = None self.TabCount = 0 self.BorderWidth = border_width + self.Theme = theme self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR self.ChangeSubmits = change_submits self.TabLocation = tab_location @@ -3415,6 +3424,8 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): custom_style = str(element.Key)+'customtab.TNotebook' style = ttk.Style(tk_row_frame) + if element.Theme is not None: + style.theme_use(element.Theme) if element.TabLocation is not None: 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'} try: @@ -3426,7 +3437,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: 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": {