Python 3 Tkinter Distance Converter Script Kilometers (KM) to Miles GUI Desktop App

Hello friend you may have many doubts about Python 3 Tkinter Distance Converter Script Kilometers (KM) to Miles GUI Desktop App We hope this article fills in all the doubts in the article. Let’s get back to the article.

Python 3 Tkinter Distance Converter Script Kilometers (KM) to Miles GUI Desktop App

Python 3 Tkinter Distance Converter Script Kilometers (KM) to Miles GUI Desktop App

import tkinter

window = tkinter.Tk()
window.title("Mile To Km Converter")
window.minsize(width=400, height=200)
window.config(padx=80, pady=50)

label1 = tkinter.Label(text="Miles")
label1.grid(column=2, row=0)

label2 = tkinter.Label(text="is equal to")
label2.grid(column=0, row=1)

label3 = tkinter.Label(text="Km")
label3.grid(column=2, row=1)

label4 = tkinter.Label(text=0)
label4.grid(column=1, row=1)


def calc():
    miles = int(entry.get())
    km = round(miles * 1.609)
    label4.config(text=f"{km}")


button = tkinter.Button(text="Calculate", command=calc)
button.grid(column=1, row=2)


entry = tkinter.Entry()
entry.grid(column=1, row=0)


window.mainloop()

Read Also: Python 3 Tkinter Script to Build Advanced Base Unit Converter (Weight + Distance + Length + Volume Temperature + Area + Height) GUI Desktop App

Final Words

Python 3 Tkinter Distance Converter Script Kilometers (KM) to Miles GUI Desktop App the article will satisfy all your doubts.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment