Advertisement
here2share

# Tk_basic_named_color_chart.py

Oct 13th, 2020
1,895
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. # Tk_basic_named_color_chart.py
  2.  
  3. from Tkinter import *
  4.  
  5. MAX_ROWS = 7
  6. FONT_SIZE = 10 # (pixels)
  7.  
  8. COLORS = 'red', 'orange', 'yellow', 'green', 'blue', 'purple', 'maroon', 'violet', 'gold', 'lime green', 'lawn green', 'dark green', 'navy', 'royal blue', 'turquoise', 'cyan', 'gold3', 'dark khaki', 'khaki', 'gray', 'light grey', 'deep pink', 'hot pink', 'pink'
  9.  
  10. root = Tk()
  11. root.title("Named colour chart")
  12. row = 0
  13. col = 0
  14. for color in COLORS:
  15.   e = Label(root, text=color, background=color,
  16.         font=(None, -FONT_SIZE))
  17.   e.grid(row=row, column=col, sticky=E+W)
  18.   row += 1
  19.   if (row > MAX_ROWS):
  20.     row = 0
  21.     col += 1
  22.  
  23. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement