Merge pull request #2287 from PySimpleGUI/Dev-latest

Allow starting at any palette in the table - should enable many more …
This commit is contained in:
PySimpleGUI 2019-11-30 18:38:07 -05:00 committed by GitHub
commit 21e72c73ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -29,13 +29,17 @@ import color_themes
figure out how to get the syntax correct for adding it to the main dictionary of themes. figure out how to get the syntax correct for adding it to the main dictionary of themes.
""" """
#----------------- Window to get layout for window ---------#
CANDIDATES_PER_ROW = 4 CANDIDATES_PER_ROW = 4
PALETTES_PER_WINDOW = 5 PALETTES_PER_WINDOW = 5
STARTING_PALETTE = 0
sg.change_look_and_feel('Dark Blue 3') sg.change_look_and_feel('Dark Blue 3')
layout = [ layout = [
[sg.T('Choose your window layout (default is a huge window)')], [sg.T('Choose your window layout (default is a huge window)')],
[sg.In(default_text=CANDIDATES_PER_ROW),sg.T('Candidates Per Row')], [sg.In(default_text=CANDIDATES_PER_ROW),sg.T('Candidates Per Row')],
[sg.In(default_text=PALETTES_PER_WINDOW),sg.T('Palettes Per Window (4 candidates for each)')], [sg.In(default_text=PALETTES_PER_WINDOW),sg.T('Palettes Per Window (4 candidates for each)')],
[sg.In(default_text=0),sg.T(f'Starting palette number of {len(color_themes.themes)} palettes')],
[sg.OK()]] [sg.OK()]]
window = sg.Window('Choose Theme Layout', layout,default_element_size=(4,1)) window = sg.Window('Choose Theme Layout', layout,default_element_size=(4,1))
event, values = window.read() event, values = window.read()
@ -46,11 +50,15 @@ if event is None:
exit() exit()
try: try:
CANDIDATES_PER_ROW = int(values[0]) CANDIDATES_PER_ROW = int(values[0])
TOTAL_CANDIDATES_PER_PAGE = int(values[1]) * 4 PALETTES_PER_WINDOW = int(values[1])
STARTING_PALETTE = int(values[2])
except: except:
sg.popup_no_buttons('Bad input... Aborting....', no_titlebar=True, auto_close=True, keep_on_top=True) sg.popup_no_buttons('Bad input... Aborting....', no_titlebar=True, auto_close=True, keep_on_top=True)
exit() exit()
TOTAL_CANDIDATES_PER_PAGE = PALETTES_PER_WINDOW * 4
#-----------------------------------------------------------#
def rgb_to_hsl(r, g, b): def rgb_to_hsl(r, g, b):
r = float(r) r = float(r)
g = float(g) g = float(g)
@ -85,9 +93,12 @@ def sorted_tuple(tup, position):
sg.popup_quick_message('Hang on this could me a few moments....', background_color='red', text_color='white', keep_on_top=True) sg.popup_quick_message('Hang on this could me a few moments....', background_color='red', text_color='white', keep_on_top=True)
sg.LOOK_AND_FEEL_TABLE = {} # Entirely replace the look and feel table in PySimpleGUI sg.LOOK_AND_FEEL_TABLE = {} # Entirely replace the look and feel table in PySimpleGUI
palette_counter = 0
for key, colors in color_themes.themes.items(): for key, colors in color_themes.themes.items():
if palette_counter < STARTING_PALETTE:
palette_counter += 1
continue
# Sort the colors from darkest to lightest # Sort the colors from darkest to lightest
color_lightness_pairs = [] color_lightness_pairs = []
for color in colors: for color in colors:
if type(color) in (tuple, list): if type(color) in (tuple, list):
@ -196,7 +207,6 @@ if row:
if layout: if layout:
layouts.append(layout) layouts.append(layout)
print(f'len layouts = {len(layouts)}')
for layout in layouts: for layout in layouts:
window = sg.Window('PySimpleGUI Theme Maker', layout, background_color=WINDOW_BACKGROUND, default_element_size=(30,1)) window = sg.Window('PySimpleGUI Theme Maker', layout, background_color=WINDOW_BACKGROUND, default_element_size=(30,1))
event, values = window.read() event, values = window.read()