Skip to content

Commit b7b02fb

Browse files
author
Aaryan Trivedi
authoredOct 5, 2022
Create weightConverterGUI.py
1 parent f3dabfe commit b7b02fb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
 

‎weightConverterGUI.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from tkinter import *
2+
window = Tk()
3+
def from_kg():
4+
gram = float(e2_value.get())*1000
5+
pound = float(e2_value.get())*2.20462
6+
ounce = float(e2_value.get())*35.274
7+
t1.delete("1.0",END)
8+
t1.insert(END, gram)
9+
t2.delete("1.0", END)
10+
t2.insert(END, pound)
11+
t3.delete("1.0", END)
12+
t3.insert(END, ounce)
13+
14+
e1 = Label(window, text="Input the weight in KG")
15+
e2_value = StringVar()
16+
e2 = Entry(window, textvariable=e2_value)
17+
e3 = Label(window, text="Gram")
18+
e4 = Label(window, text="Pound")
19+
e5 = Label(window, text="Ounce")
20+
21+
t1 = Text(window, height=5, width=30)
22+
t2 = Text(window, height=5, width=30)
23+
t3 = Text(window, height=5, width=30)
24+
25+
b1 = Button(window, text="Convert", command=from_kg)
26+
27+
e1.grid(row=0, column=0)
28+
e2.grid(row=0, column=1)
29+
e3.grid(row=1, column=0)
30+
e4.grid(row=1, column=1)
31+
e5.grid(row=1, column=2)
32+
t1.grid(row=2, column=0)
33+
t2.grid(row=2, column=1)
34+
t3.grid(row=2, column=2)
35+
b1.grid(row=0, column=2)
36+
37+
window.mainloop()

0 commit comments

Comments
 (0)
Please sign in to comment.