From 4ca1e2aa4a58d44a50d2731cde4b523d18b1a564 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Fri, 13 Aug 2021 17:05:47 -0400 Subject: [PATCH 1/2] Version that combines the layout with Window Creation --- DemoPrograms/Demo_Color_Names.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/DemoPrograms/Demo_Color_Names.py b/DemoPrograms/Demo_Color_Names.py index 4e69fb1a..fe28cc99 100644 --- a/DemoPrograms/Demo_Color_Names.py +++ b/DemoPrograms/Demo_Color_Names.py @@ -10,6 +10,7 @@ import PySimpleGUI as sg You will find the list of tkinter colors here: http://www.tcl.tk/man/tcl8.5/TkCmd/colors.htm + Copyright 2021 PySimpleGUI """ color_map = { @@ -673,23 +674,27 @@ sg.set_options(button_element_size=(12, 1), border_width=0, tooltip_time=100) # start layout with the tittle -layout = [[sg.Text('Hover mouse to see RGB value, click for popup with buttons', - justification='center', font='Default 20')]] +# layout = [[sg.Text('Hover mouse to see RGB value, click for popup with buttons', # -- Create primary color viewer window -- color_list = list(color_map.keys()) num_colors = len(color_list) colors_per_row = 15 total_rows = num_colors//colors_per_row -for row_num in range(total_rows): - row = [] - for i in range(colors_per_row): - color = color_list[row_num + i * total_rows] - row.append(sg.Button(color, button_color=('black', color), key=color, tooltip=color_map[color], border_width=0)) - layout.append(row) +# for row_num in range(total_rows): +# row = [] +# for i in range(colors_per_row): +# color = color_list[row_num + i * total_rows] +# row.append(sg.Button(color, button_color=('black', color), key=color, tooltip=color_map[color], border_width=0)) +# layout.append(row) -window = sg.Window('Color Viewer', layout, font='Default 9', element_justification='c', use_default_focus=False) +# layout = [[sg.Text('Hover mouse to see RGB value, click for popup with buttons', +# justification='center', font='Default 20')]] + [[sg.Button(color_list[row_num + i * total_rows], button_color=('black', color_list[row_num + i * total_rows]), key=color_list[row_num + i * total_rows], tooltip=color_map[color_list[row_num + i * total_rows]], border_width=0) for i in range(colors_per_row)] for row_num in range(total_rows)] + +window = sg.Window('Color Viewer', + [[sg.Text('Hover mouse to see RGB value, click for popup with buttons', justification='center', font='Default 20')]] + + [[sg.Button(color_list[row_num + i * total_rows], button_color=('black', color_list[row_num + i * total_rows]), key=color_list[row_num + i * total_rows], tooltip=color_map[color_list[row_num + i * total_rows]], border_width=0) for i in range(colors_per_row)] for row_num in range(total_rows)], font='Default 9', element_justification='c', use_default_focus=False) # -- Event loop -- while True: From 0d84bf660b4383bf3d9cf14b2e46071f4972e172 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Fri, 13 Aug 2021 17:06:46 -0400 Subject: [PATCH 2/2] Not sure what happened with the checkin --- DemoPrograms/Demo_Color_Names.py | 1 + 1 file changed, 1 insertion(+) diff --git a/DemoPrograms/Demo_Color_Names.py b/DemoPrograms/Demo_Color_Names.py index fe28cc99..99d06b89 100644 --- a/DemoPrograms/Demo_Color_Names.py +++ b/DemoPrograms/Demo_Color_Names.py @@ -675,6 +675,7 @@ sg.set_options(button_element_size=(12, 1), # start layout with the tittle # layout = [[sg.Text('Hover mouse to see RGB value, click for popup with buttons', +# justification='center', font='Default 20')]] # -- Create primary color viewer window -- color_list = list(color_map.keys())