I have created a program which convert Miles into Km. and Km. into Miles the result displayed is almost of 10 characters so can can help me take out he first 3 characters which come after . here is the code--
from tkinter import *
import tkinter.messagebox as tmsg
def convert():
if numv.get() == "":
tmsg.showinfo("Error","You may have not entered anything in the text box or "
"you may have not selected wether you want to convert from "
"Km. to Mile or from Mile to Km.")
elif numv.get() == 0:
tmsg.showinfo("Error","You may have not entered anything in the text box or "
"you may have not selected wether you want to convert from "
"Km. to Mile or from Mile to Km.")
else:
if var.get() == "Km. to Mile":
tmsg.showinfo("Result", f"{(numv.get()/1.609}")
if var.get() == "Mile to Km.":
tmsg.showinfo("Result", f"{numv.get()*1.609}")
root = Tk()
root.geometry("500x322")
root.configure(bg="khaki2")
Label(root, text="Select what operation would you like to have", bg="khaki2").pack()
var = StringVar()
var.set("Radio")
Radio = Radiobutton(root, text="Km. to Mile", variable=var,
value="Km. to Mile", bg="khaki2").pack()
Radio = Radiobutton(root, text="Mile to Km.", variable=var,
value="Mile to Km.", bg="khaki2").pack()
numv = IntVar()
num = Entry(root, textvariable=numv, bg="khaki3").pack()
Button(root, text="Convert", command=convert, bg="burlywood2").pack()
root.mainloop()