# /usr/bin/env python3 import tkinter as tk colors = [ 'gray', 'green', 'greenyellow', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender','lavenderblush', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue','mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue','mintcream', 'mistyrose', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod','palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'snow', 'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkorange', 'darkred', 'darkgreen', 'white', 'tomato', 'yellow', 'tan', 'gold', 'whitesmoke', 'ghostwhite', 'darkmagenta', 'darksalmon', 'firebrick', 'springgreen', 'darkkhaki', 'darkolivegreen', 'darkorchid', 'darkslategray','darkslateblue', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'goldenrod', 'teal', 'thistle' , 'turquoise', 'wheat', 'yellowgreen', 'violetred', ] colors.sort() root = tk.Tk() root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) mainframe = tk.Frame(root) mainframe.grid(column=0, row=0, sticky='news') mainframe.grid_columnconfigure(0, weight=1) topframe = tk.Frame(mainframe) topframe.grid(column=0, row=0, sticky='new') topframe.grid_columnconfigure(0, weight=3) label = tk.Label(topframe) label['text'] = f'{len(colors)} colors that can be used in tkinter.' label['font'] = 'sans 14 bold' label['relief'] = 'solid' label['fg'] = 'chocolate' label['highlightthickness'] = 1 label['highlightbackground'] = 'gray65' label.grid(column=0, row=0, sticky='new') btmframe = tk.Frame(mainframe) btmframe.grid(column=0, row=1, sticky='news') for i in range(9): btmframe.columnconfigure(i, weight=3, uniform='pop') col = 0 row = 0 for color in colors: frame = tk.LabelFrame(btmframe) frame['text'] = f'{color.upper()}' frame['font'] = 'sans 8 normal' frame['fg'] = 'midnightblue' frame.grid(column=col, row=row, padx=2, pady=5, sticky='news') label = tk.Label(frame) label['bg'] = color label.pack(fill='both', expand=1) if col >= 8: col = 0 row += 1 else: col += 1 root.mainloop()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags