Código Decimal RGB

from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#b6d9db")
root.title("Código Decimal RGB ")
titulo = Label(text="Código Decimal RGB",
font=("Arial", "28", "bold"),bg="#b6d9db",fg="#0c666b")
titulo.place(relx=0.04, rely=0.05)
texto_sub1 = Label(text="Vermelho(0-255):",
font=("Arial", "15", "bold"),bg="#b6d9db",fg="red")
texto_sub1.place(relx=0.05, rely=0.25)

texto_sub2 = Label(text="Verde(0-255):",
font=("Arial", "15", "bold"),bg="#b6d9db",fg="green")
texto_sub2.place(relx=0.15, rely=0.4)

texto_sub3 = Label(text="Azul(0-255):",
font=("Arial", "15", "bold"),bg="#b6d9db",fg="blue")
texto_sub3.place(relx=0.15, rely=0.55)

vermelho = IntVar()
vermelho_entrada = Entry(textvariable=vermelho,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
vermelho_entrada.place(relx=0.5, rely=0.25, relwidth=0.3)
verde = IntVar()
verde_entrada = Entry(textvariable=verde,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
verde_entrada.place(relx=0.5, rely=0.4, relwidth=0.3)

azul = IntVar()
azul_entrada = Entry(textvariable=azul,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
azul_entrada.place(relx=0.5, rely=0.55, relwidth=0.3)
def limpar():
azul_entrada.delete(0, END)
verde_entrada.delete(0, END)
vermelho_entrada.delete(0, END)
def app():
a = azul.get()
verm = vermelho.get()
verd = verde.get()
if a>255 or verm>255 or verd>255:
resultado_texto.config(text="Erro! Alguma cor é superior a 255.")
else:
color = f'#{verm:02x}{verd:02x}{a:02x}'
resultado_texto.config(bg=color)
but1 = Button(text="Verificar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.65, relwidth=0.25, relheight=0.1)
but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.35, rely=0.65, relwidth=0.25, relheight=0.1)

but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=root.destroy)
but_sair.place(relx=0.65, rely=0.65, relwidth=0.25, relheight=0.1)

resultado_texto = Label(text="Esta é a cor",
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9,relheight=0.15)
root.mainloop()

Comentários

Mensagens populares deste blogue

Criar Cartões de Visita

12 signos egípcios

Calcular a percentagem de ocupação