MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / theme_previewer

Function theme_previewer

PySimpleGUI/PySimpleGUI.py:19933–19989  ·  view source on GitHub ↗

Displays a "Quick Reference Window" showing all of the different Look and Feel settings that are available. They are sorted alphabetically. The legacy color names are mixed in, but otherwise they are sorted into Dark and Light halves :param columns: The number of themes to di

(columns=12, scrollable=False, scroll_area_size=(None, None), search_string=None, location=(None, None))

Source from the content-addressed store, hash-verified

19931
19932
19933def theme_previewer(columns=12, scrollable=False, scroll_area_size=(None, None), search_string=None, location=(None, None)):
19934 """
19935 Displays a "Quick Reference Window" showing all of the different Look and Feel settings that are available.
19936 They are sorted alphabetically. The legacy color names are mixed in, but otherwise they are sorted into Dark and Light halves
19937
19938 :param columns: The number of themes to display per row
19939 :type columns: int
19940 :param scrollable: If True then scrollbars will be added
19941 :type scrollable: bool
19942 :param scroll_area_size: Size of the scrollable area (The Column Element used to make scrollable)
19943 :type scroll_area_size: (int, int)
19944 :param search_string: If specified then only themes containing this string will be shown
19945 :type search_string: str
19946 :param location: Location on the screen to place the window. Defaults to the center like all windows
19947 :type location: (int, int)
19948 """
19949
19950 current_theme = theme()
19951
19952 # Show a "splash" type message so the user doesn't give up waiting
19953 popup_quick_message('Hang on for a moment, this will take a bit to create....', keep_on_top=True, background_color='red', text_color='#FFFFFF',
19954 auto_close=True, non_blocking=True)
19955
19956 web = False
19957
19958 win_bg = 'black'
19959
19960 def sample_layout():
19961 return [[Text('Text element'), InputText('Input data here', size=(10, 1))],
19962 [Button('Ok'), Button('Disabled', disabled=True), Slider((1, 10), orientation='h', size=(5, 15))]]
19963
19964 names = list_of_look_and_feel_values()
19965 names.sort()
19966 if search_string not in (None, ''):
19967 names = [name for name in names if search_string.lower().replace(" ", "") in name.lower().replace(" ", "")]
19968
19969 if search_string not in (None, ''):
19970 layout = [[Text('Themes containing "{}"'.format(search_string), font='Default 18', background_color=win_bg)]]
19971 else:
19972 layout = [[Text('List of all themes', font='Default 18', background_color=win_bg)]]
19973
19974 col_layout = []
19975 row = []
19976 for count, theme_name in enumerate(names):
19977 theme(theme_name)
19978 if not count % columns:
19979 col_layout += [row]
19980 row = []
19981 row += [Frame(theme_name, sample_layout() if not web else [[T(theme_name)]] + sample_layout(), pad=(2, 2))]
19982 if row:
19983 col_layout += [row]
19984
19985 layout += [[Column(col_layout, scrollable=scrollable, size=scroll_area_size, pad=(0, 0), background_color=win_bg, key='-COL-')]]
19986 window = Window('Preview of Themes', layout, background_color=win_bg, resizable=True, location=location, keep_on_top=True, finalize=True, modal=True)
19987 window['-COL-'].expand(True, True, True) # needed so that col will expand with the window
19988 window.read(close=True)
19989 theme(current_theme)
19990

Callers 1

mainFunction · 0.85

Calls 10

readMethod · 0.95
themeFunction · 0.85
popup_quick_messageFunction · 0.85
TextClass · 0.85
FrameClass · 0.85
ColumnClass · 0.85
WindowClass · 0.85
expandMethod · 0.80
sample_layoutFunction · 0.70

Tested by

no test coverage detected