Skip to content

Commit 48406ed

Browse files
authored
Merge pull request larymak#244 from AakashKotha/main
Added a Weight Conversion GUI Script
2 parents 7f11b68 + ca8ab16 commit 48406ed

File tree

4 files changed

+94
-1
lines changed

4 files changed

+94
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
# Weight Converter
3+
4+
This is a simple GUI script that lets you convert weight in Kg(s) to different Measurement units.
5+
6+
Made with Python using Tkinter module.
7+
8+
9+
10+
11+
# Modules
12+
13+
If not pre-installed, install tkinter using the following command:
14+
(Clone and move to the directory before installation)
15+
16+
```
17+
18+
pip install -r requirements.txt
19+
```
20+
21+
# Use
22+
23+
Simply run the script via terminal and use the GUI.
24+
25+
26+
## Demo
27+
28+
![Demo](https://i.imgur.com/cgoSfWP.png)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tkinter
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#A simple gui script to convert weight in different measurement units
2+
3+
#modules
4+
import tkinter
5+
from tkinter import Label, StringVar, Entry, Text, Button, END
6+
7+
8+
#initialize window
9+
10+
main = tkinter.Tk()
11+
main.title("WeightTable")
12+
main.resizable(0, 0)
13+
main.configure(bg='#0492C2')
14+
15+
16+
def val_kg():
17+
#kilograms to grams
18+
gram = float(e2_value.get()) * 1000
19+
#kilograms to pound
20+
pound = float(e2_value.get()) * 2.20462
21+
#kilograms to ounce
22+
ounce = float(e2_value.get()) * 35.274
23+
24+
#converted text to text widget
25+
t1.delete("1.0", END)
26+
t1.insert(END, gram)
27+
28+
t2.delete("1.0", END)
29+
t2.insert(END, pound)
30+
31+
t3.delete("1.0", END)
32+
t3.insert(END, ounce)
33+
34+
#label widgets
35+
e1 = Label(main, text="Enter Weight In Kilograms")
36+
e2_value = StringVar()
37+
e2 = Entry(main, textvariable=e2_value)
38+
e3 = Label(main, text="Gram")
39+
e4 = Label(main, text="Pound")
40+
e5 = Label(main, text="Ounce")
41+
42+
#Text Widgets
43+
44+
t1 = Text(main, height=1, width=20)
45+
t2 = Text(main, height=1, width=20)
46+
t3 = Text(main, height=1, width=20)
47+
48+
#Convert Button
49+
convert_btn = Button(main, text='Covert', command=val_kg)
50+
51+
#geometry specifiers; grid method.
52+
53+
e1.grid(row=0, column=0)
54+
e2.grid(row=0, column=1)
55+
e3.grid(row=1, column=0)
56+
e4.grid(row=1, column=1)
57+
e5.grid(row=1, column=2)
58+
t1.grid(row=2, column=0)
59+
t2.grid(row=2, column=1)
60+
t3.grid(row=2, column=2)
61+
convert_btn.grid(row=0, column=2)
62+
63+
#run main
64+
65+
main.mainloop()

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,3 @@ guide [HERE](https://github.com/larymak/Python-project-Scripts/blob/main/CONTRIB
115115
| 64 | [Umbrella Reminder](https://github.com/larymak/Python-project-Scripts/tree/main/AUTOMATION/Umbrella%20Reminder) | [Edula Vinay Kumar Reddy](https://github.com/vinayedula) |
116116
| 65 | [Image to PDF](https://github.com/larymak/Python-project-Scripts/tree/main/IMAGES%20%26%20PHOTO%20SCRIPTS/Image%20to%20PDF) | [Vedant Chainani](https://github.com/Envoy-VC) |
117117
| 66 | [KeyLogger](https://github.com/larymak/Python-project-Scripts/tree/main/OTHERS/KeyLogger) | [Akhil](https://github.com/akhil-chagarlamudi) |
118-
| 67 | [Face-detecting](https://github.com/azamtoiri/Python-project-Scripts/tree/main/MachineLearning%20Projects/Face-detecting) | [Azam Toiri](https://github.com/azamtoiri) |

0 commit comments

Comments
 (0)