Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 28, 2020 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/5aa203d06cb1a72363b6fdedbaec8ef7 to your computer and use it in GitHub Desktop.
Save amankharwal/5aa203d06cb1a72363b6fdedbaec8ef7 to your computer and use it in GitHub Desktop.
from tkinter import *
# Creating a GUI Window
window = Tk()
def from_kg():
gram = float(e2_value.get())*1000
pound = float(e2_value.get())*2.20462
ounce = float(e2_value.get())*35.274
t1.delete("1.0",END)
t1.insert(END, gram)
t2.delete("1.0", END)
t2.insert(END, pound)
t3.delete("1.0", END)
t3.insert(END, ounce)
e1 = Label(window, text="Input the weight in KG")
e2_value = StringVar()
e2 = Entry(window, textvariable=e2_value)
e3 = Label(window, text="Gram")
e4 = Label(window, text="Pound")
e5 = Label(window, text="Ounce")
t1 = Text(window, height=5, width=30)
t2 = Text(window, height=5, width=30)
t3 = Text(window, height=5, width=30)
b1 = Button(window, text="Convert", command=from_kg)
e1.grid(row=0, column=0)
e2.grid(row=0, column=1)
e3.grid(row=1, column=0)
e4.grid(row=1, column=1)
e5.grid(row=1, column=2)
t1.grid(row=2, column=0)
t2.grid(row=2, column=1)
t3.grid(row=2, column=2)
b1.grid(row=0, column=2)
window.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment