42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
|
from tkinter import *
|
||
|
|
||
|
def convert_km_to_ml():
|
||
|
km = textbox1.get()
|
||
|
km = int(km)
|
||
|
message = km * 0.6214
|
||
|
textbox2.delete(0, 'end')
|
||
|
textbox2.insert('end', str(message))
|
||
|
textbox2.insert('end', " millas")
|
||
|
|
||
|
def convert_ml_to_km():
|
||
|
ml = textbox1.get()
|
||
|
ml = int(ml)
|
||
|
message = round(ml * 1.6093, 3)
|
||
|
textbox2.delete(0, 'end')
|
||
|
textbox2.insert('end', str(message))
|
||
|
textbox2.insert('end', " kilometros")
|
||
|
|
||
|
window = Tk()
|
||
|
window.title("Distancia")
|
||
|
window.geometry("260x200")
|
||
|
|
||
|
label1 = Label(text="Ingresa el valor a convertir:")
|
||
|
label1.place(x=30, y=20)
|
||
|
|
||
|
textbox1 = Entry()
|
||
|
textbox1.place(x=30, y=50, width=200, height=25)
|
||
|
textbox1["justify"] = "center"
|
||
|
textbox1.focus()
|
||
|
|
||
|
convert1 = Button(text="Convertir milas a kilometros", command=convert_ml_to_km)
|
||
|
convert1.place(x=30, y=80, width=200, height=25)
|
||
|
|
||
|
convert2 = Button(text="Convertir kilometros a milas", command=convert_km_to_ml)
|
||
|
convert2.place(x=30, y=110, width=200, height=25)
|
||
|
|
||
|
textbox2 = Entry()
|
||
|
textbox2.place(x=30, y=140, width=200, height=25)
|
||
|
textbox2["justify"] = "center"
|
||
|
|
||
|
window.mainloop()
|