Task: Python tkinter GUI Kilogram to Pounds Program
How to Convert Kilograms into Pounds (Kgs to Lbs)
There are 2.20462 Pounds in One Kiologram. Therefore, we can easily convert the given kilograms in to the pounds using the following formula:
1 Kg = 2.20462 Pounds
The tkinter Widgets Used in Kilograms to Pounds Program
- Label
- Entry
- Button
- along with the Root Window or main window.
# Write a Python GUI program # using tkinter module # to input Kilograms in Entry # text box widget and convert # to Pounds on button click. import tkinter as tk def main(): window= tk.Tk() window.title("Kilograms to Pounds Converter") window.geometry("375x200") # create a label with text Enter Kilograms label1 = tk.Label(window, text="Enter Kilograms:") # create a label with text Pounds: label2 = tk.Label(window, text="Pounds:") # place label1 in window at position x,y label1.place(x=50,y=30) # create an Entry widget (text box) textbox1 = tk.Entry(window, width=12) # place textbox1 in window at position x,y textbox1.place(x=200,y=35) # place label2 in window at position x,y label2.place(x=50,y=100) # create a label3 with empty text: label3 = tk.Label(window, text=" ") # place label3 in window at position x,y label3.place(x=180,y=100) def btn1_click(): pounds = round(float(textbox1.get()) * 2.20462,5) label3.configure(text = str(pounds)+ ' Pounds') # create a button with text Button 1 btn1 = tk.Button(window, text="Click Me To Convert", command=btn1_click) # place this button in window at position x,y btn1.place(x=90,y=150) window.mainloop() main()
You may also like:
Kilograms to Pounds Python Program
Python Pounds to Kilograms Conversion Program
Pingback: Adding Menus to Python 3 tkinter GUI Programs | EasyCodeBook.com
Pingback: Python Pounds to Kilogram Converter GUI tkinter Program | EasyCodeBook.com
Pingback: Multiplication Table Python GUI Program | EasyCodeBook.com
Pingback: Find Factorial by Recursive Function Python GUI Program | EasyCodeBook.com
Pingback: Python Digital Clock Program using tkinter GUI | EasyCodeBook.com