Mundo em Python

Salário por hora

from tkinter import *

root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Salário por hora") titulo = Label(text="Salário por hora", font=("Arial", "33", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.06, rely=0.05) sub1 = Label(text="Salário: ", font=("Arial", "25", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.1, rely=0.25)
Salario = StringVar()
Salario_entrada = Entry(textvariable=Salario, font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Salario_entrada.place(relx=0.5, rely=0.27, relwidth=0.4)
Salario_entrada.focus() sub2 = Label(text="Hora: ", font=("Arial", "25", "bold"), bg="#103030", fg="#49e3e3")
sub2.place(relx=0.1, rely=0.4)
hora = StringVar()
hora_entrada = Entry(textvariable=hora, font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
hora_entrada.place(relx=0.5, rely=0.43, relwidth=0.4) def limpar():
hora_entrada.delete(0, END)
Salario_entrada.delete(0, END)
resultado_texto.set("") def app():
try:
h = int(hora.get())
w = float(Salario.get())
salario_hora = w / h
mensagem = f"Salário por hora: {round(salario_hora, 2)} €"
resultado_texto.config(text=mensagem)
except ValueError:
resultado_texto.config(text="Digitação errada!!") but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.55, 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.55, 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.55, relwidth=0.25, relheight=0.1) resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.7, relwidth=0.9, relheight=0.15) root.mainloop()
0