summaryrefslogtreecommitdiff
path: root/colorlist
diff options
context:
space:
mode:
authorDavid Wührer <def@gmx.at>2023-04-07 19:25:03 +0200
committerDavid Wührer <def@gmx.at>2023-04-07 19:25:03 +0200
commitdc3b063ef6b370d1b3594ed785c682ea2db09b41 (patch)
treec9f8facefd38f8163e53a08db3b632784b95ce92 /colorlist
parentbe555f29f47f81993c12bf76065a0cb6bb0fee96 (diff)
Add a few incomplete things
Diffstat (limited to 'colorlist')
-rwxr-xr-xcolorlist26
1 files changed, 26 insertions, 0 deletions
diff --git a/colorlist b/colorlist
new file mode 100755
index 0000000..49b8442
--- /dev/null
+++ b/colorlist
@@ -0,0 +1,26 @@
+#!/usr/bin/python3
+
+import tkinter
+from tkinter.constants import *
+
+window = tkinter.Tk ()
+window.wm_title ('X11 Colours')
+
+canvas = tkinter.Canvas (window)
+frame = tkinter.Frame (canvas)
+scrollbar = tkinter.Scrollbar (window, command=canvas.yview)
+canvas.configure (yscrollcommand=scrollbar.set)
+
+scrollbar.pack(fill=Y, expand=1, side=RIGHT)
+canvas.pack (fill=BOTH, expand=1, side=LEFT)
+canvas.create_window ((0,0), window=frame, anchor=NW)
+frame.bind ("<Configure>", lambda e: canvas.configure (scrollregion=canvas.bbox ('all')))
+
+with open ("/etc/X11/rgb.txt") as txt:
+ colours = txt.readlines ()
+
+for r,g,b,name in ((int(l[0]),int(l[1]),int(l[2]),l[3]) for l in (colour.rstrip ().split (maxsplit=3) for colour in colours[1:])):
+ # Each colour band should be weighted: Half red is not as bright as half green.
+ tkinter.Label (frame, text=f'{name} ({r+b+g})', bg=f'#{r:02x}{g:02x}{b:02x}',fg='black' if r+g+b > 381 else 'white').pack (fill=X, expand=1)
+
+window.mainloop ()