Skip to content

Commit c874c67

Browse files
Modified weight_con_gui.py
1 parent 21fd191 commit c874c67

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

Weight-Converter-GUI/weight_con_gui.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ def WeightConv():
3434
kilograms = float(e1.get())
3535

3636
# insert the output in textboxes correct upto 2 places after decimal
37-
t1.insert(END, "%.2f Carat" % (kilograms * 5000))
38-
t2.insert(END, "%.2f Gram" % (kilograms * 1000))
39-
t3.insert(END, "%.2f Ounce" % (kilograms * 35.274))
40-
t4.insert(END, "%.2f Pound" % (kilograms * 2.20462))
41-
t5.insert(END, "%.2f Quintal" % (kilograms * 0.01))
42-
t6.insert(END, "%.2f Tonne" % (kilograms * 0.001))
37+
t1.insert(END, "%.2f" % (kilograms * 5000))
38+
t2.insert(END, "%.2f" % (kilograms * 1000))
39+
t3.insert(END, "%.2f" % (kilograms * 35.274))
40+
t4.insert(END, "%.2f" % (kilograms * 2.20462))
41+
t5.insert(END, "%.2f" % (kilograms * 0.01))
42+
t6.insert(END, "%.2f" % (kilograms * 0.001))
4343

4444
# if blank or invalid input is given then exception is thrown
4545
except ValueError:
@@ -90,6 +90,24 @@ def WeightConv():
9090
t6l6 = Label(root, text = "kg to t : ")
9191
t6l6.grid(row = 9, column = 1, columnspan=1)
9292

93+
t1r1 = Label(root, text = "Carat")
94+
t1r1.grid(row = 4, column = 4, columnspan=1)
95+
96+
t2r2 = Label(root, text = "Gram")
97+
t2r2.grid(row = 5, column = 4, columnspan=1)
98+
99+
t3r3 = Label(root, text = "Ounce")
100+
t3r3.grid(row = 6, column = 4, columnspan=1)
101+
102+
t4r4 = Label(root, text = "Pound")
103+
t4r4.grid(row = 7, column = 4, columnspan=1)
104+
105+
t5r5 = Label(root, text = "Quintal")
106+
t5r5.grid(row = 8, column = 4, columnspan=1)
107+
108+
t6r6 = Label(root, text = "Tonne")
109+
t6r6.grid(row = 9, column = 4, columnspan=1)
110+
93111
# creating textbox and defining grid to show output
94112
t1 = Text(root, height = 1, width = 20)
95113
t1.grid(row = 4, column = 2, columnspan = 2)
@@ -116,4 +134,4 @@ def WeightConv():
116134
root.grid_columnconfigure(c,minsize = 50)
117135

118136
# infinite loop to run program
119-
root.mainloop()
137+
root.mainloop()

0 commit comments

Comments
 (0)