import tkinter as tk
from functools import partial
tempVal = "Litros"
def store_temp(sel_temp):
global tempVal
tempVal = sel_temp
def call_convert(rlabel1, inputn):
tem = inputn.get()
if tempVal == 'Litros':
k = float(tem) / 0.264172
rlabel1.config(text="%f Litros" % k)
if tempVal == 'Galões':
k = float(tem) * 0.264172
rlabel1.config(text="%f Galões" % k)
return
root = tk.Tk()
root.geometry('400x250')
root.title('Converter o Volume')
root.configure(background='#09A3BA')
root.resizable(width=False, height=False)
numberInput = tk.StringVar()
var = tk.StringVar()
titulo_label = tk.Label(root, text="Converter o Volume", background='#09A3BA', foreground="#FFFFFF",
font=("Arial", "25", "bold"))
input_label = tk.Label(root, text="Digite o número: ", background='#09A3BA', foreground="#FFFFFF",
font=("Arial", "14", "bold"))
texto_label = tk.Label(root, text="Coverter a ", background='#09A3BA', foreground="#FFFFFF",
font=("Arial", "10", "bold"))
input_entry = tk.Entry(root, textvariable=numberInput)
titulo_label.place(relx=0.1, rely=0.05)
input_label.place(relx=0.05, rely=0.3)
input_entry.place(relx=0.55, rely=0.3)
texto_label.place(relx=0.05, rely=0.55)
result_label1 = tk.Label(root, background='#09A3BA', foreground="black", font=("Arial", "14", "bold"))
result_label1.place(relx=0.15, rely=0.8)
dropDownList = ["Litros ", "Galões"]
dropdown = tk.OptionMenu(root, var, *dropDownList, command=store_temp)
var.set(dropDownList[0])
dropdown.place(relx=0.25, rely=0.5)
dropdown.config(background='#09A3BA', foreground="#FFFFFF", font=("Arial", "14", "bold"))
dropdown["menu"].config(background='#09A3BA', foreground="#FFFFFF", font=("Arial", "14", "bold"))
call_convert = partial(call_convert, result_label1, numberInput)
result_button = tk.Button(root, text="Convert", command=call_convert, background='#09A3BA',
foreground="#FFFFFF", font=("Arial", "14", "bold"))
result_button.place(relx=0.6, rely=0.5)
root.mainloop()