Skip to content

Commit 54e51a9

Browse files
Merge pull request prathimacode-hub#880 from akash435/colorpalettebranch
Added RGB Color Palette in GUIScripts
2 parents 25d7f63 + fc440f9 commit 54e51a9

File tree

11 files changed

+198
-0
lines changed

11 files changed

+198
-0
lines changed
85.2 KB
Loading
118 KB
Loading
115 KB
Loading
122 KB
Loading
129 KB
Loading
122 KB
Loading
128 KB
Loading
184 KB
Loading
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# ✔ RGB COLOR PALETTE
2+
- ### An RGB Color Palette is an application created in python with tkinter gui.
3+
- ### In this application user will be able to see the RGB color using the scales given for red, green and blue from 1 to 255 values.
4+
- ### Ans as soon as user change the scale, user will be able to see the preview of the RGB color in the preview area.
5+
- ### Also along with that, user will be able to get the Degree, Saturation and Lightness of that color previewed for each instance.
6+
7+
****
8+
9+
# REQUIREMENTS :
10+
- ### python 3
11+
- ### tkinter module
12+
- ### filedialog from tkinter
13+
- ### messagebox
14+
- ### from PIL import Image, ImageTk
15+
- ### colorsys
16+
17+
****
18+
19+
# HOW TO Use it :
20+
- ### User just need to download the file, and run the RGB_color_palette.py, on local system.
21+
- ### After running a GUI window appears, where user can start the palette application by clicking on the START button.
22+
- ### After that a new GUI window will open, in which user will see one preview area, three pallete in form of scales for RED, GREEN and BLUE color.
23+
- ### Now As soon as user changes values in the red, green and blue scales, user will be able to see that RGB color in preview area.
24+
- ### Also along with that, user will be able to get the Degree, Saturation and Lightness of that color previewed for each instance.
25+
26+
# Purpose :
27+
- ### This scripts helps user to easily get the preview of the RGB color and also can get the information about Degree, Saturation and Lightness of that color previewed for each instance.
28+
29+
# Compilation Steps :
30+
- ### Install tkinter, PIL, colorsys
31+
- ### After that download the code file, and run RGB_color_palette.py on local system.
32+
- ### Then the script will start running and user can explore it by seeing the preview of RGB color by selecting the values of R,G, and B using scales and also getting information about Degree, Saturation and Lightness of that color previewed for each instance.
33+
34+
****
35+
36+
# SCREENSHOTS :
37+
****
38+
39+
<p align="center">
40+
<img width = 1000 src="Images/1.jpg" /><br>
41+
<img width = 1000 src="Images/2.jpg" /><br>
42+
<img width = 1000 src="Images/3.jpg" /><br>
43+
<img width = 1000 src="Images/4.jpg" /><br>
44+
<img width = 1000 src="Images/5.jpg" /><br>
45+
<img width = 1000 src="Images/6.jpg" /><br>
46+
<img width = 1000 src="Images/7.jpg" /><br>
47+
</p>
48+
49+
****
50+
51+
# Name :
52+
- ### Akash Ramanand Rajak
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
2+
# RGB Color Palette
3+
4+
# imported necessary library
5+
import tkinter
6+
from tkinter import *
7+
import tkinter as tk
8+
import tkinter.messagebox as mbox
9+
from tkinter import ttk
10+
from PIL import ImageTk, Image
11+
import colorsys
12+
13+
14+
# Main Window & Configuration
15+
window = tk.Tk() # created a tkinter gui window frame
16+
window.title("RGB Color Palette")
17+
window.geometry('1000x700')
18+
19+
# top label
20+
start1 = tk.Label(text="RGB COLOR PALETTE", font=("Arial", 50, "underline"), fg="magenta") # same way bg
21+
start1.place(x=120, y=10)
22+
23+
def start_fun():
24+
window.destroy()
25+
26+
# start button created
27+
startb = Button(window, text="START", command=start_fun, font=("Arial", 25), bg="lightgreen", fg="blue", borderwidth=3,
28+
relief="raised")
29+
startb.place(x=130, y=580)
30+
31+
# image on the main window
32+
path = "Images/front.png"
33+
# Creates a Tkinter-compatible photo image, which can be used everywhere Tkinter expects an image object.
34+
img1 = ImageTk.PhotoImage(Image.open(path))
35+
# The Label widget is a standard Tkinter widget used to display a text or image on the screen.
36+
panel = tk.Label(window, image=img1)
37+
panel.place(x=210, y=100)
38+
39+
40+
# function created for exiting
41+
def exit_win():
42+
if mbox.askokcancel("Exit", "Do you want to exit?"):
43+
window.destroy()
44+
45+
46+
# exit button created
47+
exitb = Button(window, text="EXIT", command=exit_win, font=("Arial", 25), bg="red", fg="blue", borderwidth=3,
48+
relief="raised")
49+
exitb.place(x=730, y=580)
50+
window.protocol("WM_DELETE_WINDOW", exit_win)
51+
window.mainloop()
52+
53+
# Main Window & Configuration
54+
window1 = tk.Tk() # created a tkinter gui window frame
55+
window1.title("RGB Color Palette")
56+
window1.geometry('1000x730')
57+
58+
59+
# top label
60+
start1 = tk.Label(text = "RGB COLOR PALETTE", font=("Arial", 40, "underline"), fg="magenta") # same way bg
61+
start1.place(x =210, y = 10)
62+
63+
# lbl1 = tk.Label(text="Select any video &\nconvert to grayscale video", font=("Arial", 40),fg="green") # same way bg
64+
# lbl1.place(x=170, y=110)
65+
66+
# for preview
67+
preview_text = tk.Text(window1, height=9, width=60, font=("Arial", 15), bg="white", borderwidth=3, relief="solid")
68+
preview_text.place(x=160, y=90)
69+
70+
# preview1 label
71+
top1 = Label(window1, text="PREVIEW AREA", font=("Arial", 40), fg="black", bg="white") # same way bg
72+
top1.place(x=270, y=130)
73+
74+
# preview2 label
75+
top2 = Label(window1, text="Color will be previewed here...", font=("Arial", 25), fg="black",bg="white") # same way bg
76+
top2.place(x=265, y=230)
77+
78+
Label(window1, text="RED", font=("Arial", 40), fg="red").place(x=130, y=335)
79+
Label(window1, text="GREEN", font=("Arial", 40), fg="green").place(x=130, y=415)
80+
Label(window1, text="BLUE", font=("Arial", 40), fg="blue").place(x=130, y=500)
81+
82+
# created a scale from 1 to 10
83+
red_scale = Scale(window1, from_=1, to=255, orient=HORIZONTAL,width = 20, length = 500, font=("Arial", 20), bg = "red", fg = "black", borderwidth=3)
84+
red_scale.place(x = 340, y = 330)
85+
86+
# created a scale from 1 to 10
87+
green_scale = Scale(window1, from_=1, to=255, orient=HORIZONTAL,width = 20, length = 500,font=("Arial", 20), bg = "green", fg = "black", borderwidth=3)
88+
green_scale.place(x = 340, y = 410)
89+
90+
# created a scale from 1 to 10
91+
blue_scale = Scale(window1, from_=1, to=255, orient=HORIZONTAL,width = 20, length = 500,font=("Arial", 20), bg = "blue", fg = "black", borderwidth=3)
92+
blue_scale.place(x = 340, y = 490)
93+
94+
Label(window1, text="Degree", font=("Arial", 35), fg="gray").place(x=70, y=580)
95+
Label(window1, text="Saturation", font=("Arial", 35), fg="gray").place(x=370, y=580)
96+
Label(window1, text="Lightness", font=("Arial", 35), fg="gray").place(x=730, y=580)
97+
98+
d_lbl = Label(window1, font=("Arial", 35), fg="gray")
99+
d_lbl.place(x=70, y=640)
100+
s_lbl = Label(window1, font=("Arial", 35), fg="gray")
101+
s_lbl.place(x=370, y=640)
102+
l_lbl = Label(window1, font=("Arial", 35), fg="gray")
103+
l_lbl.place(x=730, y=640)
104+
105+
def update_color():
106+
red = int(red_scale.get())
107+
green = int(green_scale.get())
108+
blue = int(blue_scale.get())
109+
x = '#%02x%02x%02x' % (red, green, blue)
110+
preview_text.configure(bg = x)
111+
# print(x)
112+
if(x=="#010101"):
113+
top1.configure(bg = x, fg = "white")
114+
top2.configure(bg = x, fg = "white")
115+
else:
116+
top1.configure(bg=x, fg = "black")
117+
top2.configure(bg=x, fg = "black")
118+
119+
r, g, b = [x1 / 255.0 for x1 in (red, green, blue)]
120+
h, l, s = colorsys.rgb_to_hls(r, g, b)
121+
h = round(h,4)
122+
s = round(s, 4)
123+
l = round(l, 4)
124+
d_lbl.config(text = h)
125+
s_lbl.config(text=s)
126+
l_lbl.config(text=l)
127+
# print(red_scale.get(), green_scale.get(), blue_scale.get())
128+
window1.after(1, update_color)
129+
130+
update_color()
131+
132+
# function for exiting
133+
def exit_win1():
134+
if mbox.askokcancel("Exit", "Do you want to exit?"):
135+
window1.destroy()
136+
137+
# # Get Images Button
138+
# getb=Button(window1, text="EXIT",command=exit_win1, font=("Arial", 25), bg = "red", fg = "blue")
139+
# getb.place(x = 750, y = 580)
140+
141+
window1.protocol("WM_DELETE_WINDOW", exit_win1)
142+
window1.mainloop()

0 commit comments

Comments
 (0)