from tkinter import *
root = Tk()
root.geometry("500x500")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Regra dos 30")
titulo = Label(text="Regra dos 30",
font=("Arial", "28", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.18, rely=0.05)
texto_sub1 = Label(text="Temperatura (em °C):",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.1, rely=0.25)
texto_sub2 = Label(text="Humidade (em %):",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.1, rely=0.4)
texto_sub3 = Label(text="Velocidade do vento (em km/h):",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub3.place(relx=0.1, rely=0.55)
Temperatura = StringVar()
Temperatura_entrada = Entry(textvariable=Temperatura,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Temperatura_entrada.place(relx=0.75, rely=0.25, relwidth=0.2)
Humidade = StringVar()
Humidade_entrada = Entry(textvariable=Humidade,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Humidade_entrada.place(relx=0.75, rely=0.4, relwidth=0.2)
Velocidade = StringVar()
Velocidade_entrada = Entry(textvariable=Velocidade,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Velocidade_entrada.place(relx=0.75, rely=0.55, relwidth=0.2)
def limpar():
Velocidade_entrada.delete(0, END)
Humidade_entrada.delete(0, END)
Temperatura_entrada.delete(0, END)
resultado_texto.config(text="")
def app():
try:
v = float(Velocidade.get())
h = float(Humidade.get())
t = float(Temperatura.get())
if t > 30 and h < 30 and v > 30:
resultado_texto.config(text="Condições de alto risco de incêndio!")
else:
resultado_texto.config(text="Condições dentro da normalidade.")
except ValueError:
resultado_texto.config(text="Digitação de valor errado!!")
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, 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.4, 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.7, rely=0.65, relwidth=0.25, relheight=0.1)
resultado_texto = Label(text="",
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9, relheight=0.15)
root.mainloop()