0% found this document useful (0 votes)
153 views7 pages

Weight Converter (GUI) Using TKinter

This document describes creating a weight converter GUI application using Python and the Tkinter library. It defines standard weight conversion values like grams to kilograms. It then shows how to create a GUI window with labels to input weight in kg and display the converted values in grams, pounds, and ounces. A button is added to trigger the conversion function that gets the input value, performs the calculations, and inserts the results into the output text boxes. This allows building a simple weight converter with a graphical user interface in Python.

Uploaded by

Amey shringare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views7 pages

Weight Converter (GUI) Using TKinter

This document describes creating a weight converter GUI application using Python and the Tkinter library. It defines standard weight conversion values like grams to kilograms. It then shows how to create a GUI window with labels to input weight in kg and display the converted values in grams, pounds, and ounces. A button is added to trigger the conversion function that gets the input value, performs the calculations, and inserts the results into the output text boxes. This allows building a simple weight converter with a graphical user interface in Python.

Uploaded by

Amey shringare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

SMT INDIRA GANDHI COLLEGE OF ENGINEERING

NAVI MUMBAI
PHYTHON CASE STUDY
THE PYTHON CASE STUDY PERFORMED UNDER THE
GUIDANCE OF PROF SARITA BOPALKAR.

WEIGHT CONVERTER(GUI) USING Tkinter


OBJECTIVE:- WEIGHT CONVERSION MEANS TO MULTIPLY THE VALUE OF A UNIT WITH THE STANDARD CONVERSION VALUE. IN THIS
ARTICLE, I WILL TAKE YOU THROUGH HOW TO CREATE A WEIGHT CONVERTER GUI WITH PYTHON PROGRAMMING LANGUAGE.

The standard weight conversion values include:

1 milligram = 0.001 gram

1 centigram = 0.01 gram

1 decigram = 0.1 gram

1 kilogram = 1000 grams

1 gram = 1000 milligrams

1 ton = 2000 pounds

1 pound = 16 ounces
NOW LET’S SEE HOW TO CREATE A WEIGHT CONVERTER APPLICATION WITH PYTHON BY ADDING SOME GRAPHICAL USER INTERFACE FEATURES. I WILL USE THE TKINTER LIBRARY IN PYTHON FOR THIS TASK:
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)
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_k

e1.grid(row=0, column=0)
e2.grid(row=0, column=1)
e3.grid(row=1, column=0)
E1 = LABEL(WINDOW, TEXT="INPUT THE WEIGHT IN KG")
E2_VALUE = STRINGVAR()
e4.grid(row=1, column=1)
E2 = ENTRY(WINDOW, TEXTVARIABLE=E2_VALUE)
E3 = LABEL(WINDOW, TEXT="GRAM")
E4 = LABEL(WINDOW, TEXT="POUND")
e5.grid(row=1, column=2)
E5 = LABEL(WINDOW, TEXT="OUNCE")
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()
SO THIS IS HOW WE CAN CREATE A WEIGHT CONVERTER GRAPHICAL USER INTERFACE
APPLICATION BY USING THE TKINTER LIBRARY IN PYTHON.
THANK YOU !

You might also like