Calculate Area GUI Application | Python Tutorial

preview_player
Показать описание
Calculate Area GUI Application | Python Tutorial

How to create a GUI application that calculates the area of a rectangle using Tkinter and Python.

Рекомендации по теме
Комментарии
Автор

Thank You, for this tutorial you have made. Thank you very much.


Anyone who needs the code:
from tkinter import*


def calcArea(w, h):
return w*h


def clickArea():
area.set(calcArea(height.get(), width.get()))


root = Tk()
root.title("Calculator Area")

Label(root, text="Width").grid(row=0, column=0)
width = IntVar()


Entry(root, textvariable=width).grid(row=0, column=1)
Label(root, text="Height").grid(row=1, column=0)
height = IntVar()


Entry(root, textvariable=height).grid(row=1, column=1)
Label(root, text="Area").grid(row=2, column=0)
area = IntVar()


Label(root, textvariable=area).grid(row=2, column=1)
button = Button(root, text="Calculate Area", command=clickArea)

button.grid(row=3, column=0, columnspan=2)

root.mainloop()

striker_eureka
Автор

Can you drop a video showing the test program🤲

DanielHassan-jl
Автор

from tkinter import *


def Rectangle(l, w):
return length*width


def clickArea(l, w):
area.set(Rectangle(l.get(), w.get))


root = Tk()
root.title("Area Calculator")

w = IntVar()
l = IntVar()
area = IntVar()

Label(root, text="Rectangle", font=("Comic San", 15, "bold")).grid(row=0, column=0)
Label(root, text="Width", font=("Arial", 15)).grid(row=1, column=0)
Label(root, text=" Length", font=("Arial", 15)).grid(row=3, column=0)
Label(root, text="Area", font=("Arial", 16)).grid(row=4, column=0)
Label(root, textvariable=area, font=("Arial", 15)).grid(row=4, column=1)

Entry(root, textvariable=w, font=("Arial", 15)).grid(row=1, column=1)
Entry(root, textvariable=l, font=("Arial", 15)).grid(row=3, column=1)

button = Button(root, text="Calculate Area", command=clickArea)
button.place(x=100, y=120)

root.mainloop()

ProdigyStarsTED
Автор

from tkinter import *

def calcArea(w, h):
return w*h

def clickArea() :
area.set(calcArea(height.get(), width.get()))

root = Tk ()
root.title("Area Calculator")

Label(root, text="Width").grid(row=0, column=0)
width = IntVar()

Entry(root, textvariable=width).grid(row=0, column=1)
Label(root, text="Height").grid(row=1, column=0)
height = IntVar()

Entry(root, textvariable=height).grid(row=1, column=1)
Label(root, text="Area").grid(row=2, column=0)
area=IntVar()

Label(root, textvariable=area).grid(row=2, column=1)
button = Button(root, text="Calculate Area", command=clickArea)

button.grid(row=3, column=0, columnspan=2)

root.mainloop()

vernadetteechavia
Автор

from tkinter import *

window = Tk ()
window.title("Area Calculator")
window.geometry('500x250')

def calcArea(w, h):
return w*h

def clickArea() :
area.set(calcArea(height.get(), width.get()))

width = IntVar()
Label(window, text="Width").grid(row=0, column=0, padx=5, pady=10)
Entry(window, bg='light blue', textvariable=width).grid(row=0, column=1)

height = IntVar()
Label(window, text="Height").grid(row=1, column=0)
Entry(window, bg='light blue', textvariable=height).grid(row=1, column=1)

area=IntVar()
Label(window, text="Area").grid(row=4, column=0)
Label(window, fg='red', textvariable=area).grid(row=4, column=1)

button = Button(window, text="Calculate Area", command=clickArea)
button.grid(row=3, column=0, columnspan=2, padx=5, pady=10)

window.mainloop()

lovinghusbandos