Show colors in columns instead of rows
This commit is contained in:
parent
db7b49f2c3
commit
dfabb723a0
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue