From dfabb723a0cd590932fa738ca5f705033a4a6c22 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 11 Dec 2018 13:28:19 -0500 Subject: [PATCH] Show colors in columns instead of rows --- DemoPrograms/Demo_Color_Names.py | 22 +++++++++----- DemoPrograms/Demo_Color_Names_Smaller_List.py | 29 +++++++++++++++---- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/DemoPrograms/Demo_Color_Names.py b/DemoPrograms/Demo_Color_Names.py index a81aaa36..3142ee60 100644 --- a/DemoPrograms/Demo_Color_Names.py +++ b/DemoPrograms/Demo_Color_Names.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import sys if sys.version_info[0] >= 3: - import PySimpleGUI as sg + import PySimpleGUIQt as sg else: import PySimpleGUI27 as sg @@ -683,13 +683,19 @@ layout = [[sg.Text('Hover mouse to see RGB value, click for white & black text', background_color='light green', pad=(0,(0,20))),]] -# -- Create primary color viewer window by building rows and appending to layout -- -row = [] -for i, color in enumerate(color_map): - row.append(sg.Button(color, button_color=('black', color), key=color, tooltip=color_map[color])) - if (i+1) % 15 == 0: # every 15 buttons make a new row - layout.append(row) - row = [] +# -- Create primary color viewer window -- +color_list = [key for key in color_map] +for rows in range(40): + + row = [] + for i in range(12): + try: + color = color_list[rows+40*i] + row.append(sg.Button(color, button_color=('black', color), key=color)) + except: + pass + layout.append(row) + window = sg.Window('Color Viewer', grab_anywhere=False, font=('any 9')).Layout(layout) diff --git a/DemoPrograms/Demo_Color_Names_Smaller_List.py b/DemoPrograms/Demo_Color_Names_Smaller_List.py index c4c2e69b..e6911dcd 100644 --- a/DemoPrograms/Demo_Color_Names_Smaller_List.py +++ b/DemoPrograms/Demo_Color_Names_Smaller_List.py @@ -13,6 +13,9 @@ else: Once large window is shown, you can click on any color and another window will popup showing both white and black text on that color """ + + + COLORS = ['snow', 'ghost white', 'white smoke', 'gainsboro', 'floral white', 'old lace', 'linen', 'antique white', 'papaya whip', 'blanched almond', 'bisque', 'peach puff', 'navajo white', 'lemon chiffon', 'mint cream', 'azure', 'alice blue', 'lavender', @@ -90,16 +93,32 @@ COLORS = ['snow', 'ghost white', 'white smoke', 'gainsboro', 'floral white', 'ol 'grey84', 'grey85', 'grey86', 'grey87', 'grey88', 'grey89', 'grey90', 'grey91', 'grey92', 'grey93', 'grey94', 'grey95', 'grey97', 'grey98', 'grey99'] + + + sg.SetOptions(button_element_size=(12,1), element_padding=(0,0), auto_size_buttons=False, border_width=0) layout = [[sg.Text('Click on a color square to see both white and black text on that color', text_color='blue', font='Any 15')]] row = [] +layout = [] # -- Create primary color viewer window -- -for i, color in enumerate(COLORS): - row.append(sg.Button(color, button_color=('black', color), key=color)) - if (i+1) % 12 == 0: - layout.append(row) - row = [] +for rows in range(40): + + row = [] + for i in range(12): + try: + color = COLORS[rows+40*i] + row.append(sg.Button(color, button_color=('black', color), key=color)) + except: + pass + layout.append(row) + + +# for i, color in enumerate(COLORS): +# row.append(sg.Button(color, button_color=('black', color), key=color)) +# if (i+1) % 12 == 0: +# layout.append(row) +# row = [] window = sg.Window('Color Viewer', grab_anywhere=False, font=('any 9')).Layout(layout)