top of page
Search

CALCULATOR OF ICE-CREAM PARLOR - GUI INTERFACE IN TKINTER

  • Writer: Jayesh Malviya
    Jayesh Malviya
  • Sep 1, 2022
  • 1 min read

Updated: Sep 19, 2022

INTRODUCTION

we are going to develop an Ice-Cream parlor calculator GUI interface in python Tkinter that calculates the amount for the parlor. This project is help to learn the basics starting in Tkinter.

  • START

  • Take quantity input of all products.

  • Also, Take the price input of all products.

  • Show all calculated input in total using the Label() function.

  • then calculate the net amount.

  • STOP

Let's get started:

import all needed modules.

from tkinter import * from tkinter import messagebox

then, set the window off the screen.

root = Tk() root.geometry("800x400") root.title("Ice-Cream Parlour")

then, put this code after setting geometry.


def ice_cream(): # labeling part Label(root, text="Ice Cream Parlour",font="Ariel 20 bold").pack(fill="x" , side="top") Label(root, text="Ice Cream", font="Ariel 15 bold").place(x=30, y=50) Label(root, text="Quantity", font="Ariel 15 bold").place(x=300, y=50) Label(root, text="price", font="Ariel 15 bold").place(x=480, y=50) Label(root, text="Total", font="Ariel 15 bold").place(x=650, y=50) #veritcal labeling. Radiobutton(root, text="Strawberry", value="v1").place(x=30, y=120) Radiobutton(root, text="Chocolate", value="v2").place(x=30, y=190) Radiobutton(root, text="Vanilla", value="v3").place(x=30, y=260) # get input. ice_cream.q1 = Entry(root,border=4, font="Ariel 10 bold") ice_cream.q1.place(x=290, y=120) ice_cream.q2 = Entry(root,border=4, font="Ariel 10 bold") ice_cream.q2.place(x=290, y=190) ice_cream.q3 = Entry(root,border=4, font="Ariel 10 bold") ice_cream.q3.place(x=290, y=260) # input box of price. ice_cream.p1 = Entry(root,border=4, font="Ariel 10 bold") ice_cream.p1.place(x=470, y=120) ice_cream.p2 = Entry(root,border=4, font="Ariel 10 bold") ice_cream.p2.place(x=470, y=190) ice_cream.p3 = Entry(root,border=4, font="Ariel 10 bold") ice_cream.p3.place(x=470, y=260) # total amount. Label(root, text="Total Amount",font="Ariel 10 bold").place(x=30, y=320) # total amount show command. Button(root, text="Calculate", border=3, command=get_input).place(x=290, y=320) Button(root, text="Close", border=3, command=Close).place(x=480, y=320)


def get_input(): # quantity input. a = int(ice_cream.q1.get()) b = int(ice_cream.q2.get()) c = int(ice_cream.q3.get()) # price input. price_1 = int(ice_cream.p1.get()) price_2 = int(ice_cream.p2.get()) price_3 = int(ice_cream.p3.get()) # calculations v1 = a * price_1 v2 = b * price_2 v3 = c * price_3 # show in total t1 = Label(root, text=v1, font="Ariel 9 bold") t1.place(x=650, y=120) t2 = Label(root, text=v2, font="Ariel 9 bold") t2.place(x=650, y=190) t3 = Label(root, text=v3, font="Ariel 9 bold") t3.place(x=650, y=260) # show in net total. net_value = v1 + v2 + v3 Label(root, text=net_value, font="Ariel 9 bold").place(x=170, y=320)


def Close(): Quit = messagebox.askquestion("Quit", "Are you sure to quit this application.") if Quit == "Yes" or Quit == "yes": quit() else: pass



In this code, we create three functions, first ice_cream() which holds the whole GUI input, Buttons, and labels in format. The second is get_input() function in this we take input from entry widget using get() function. and third is a close() function in this function we activate the quit button in the ice_cream() function we ask a question to the user that "Are you sure to quit this application", then we create the condition that if the user chooses yes then run quit() function which closes the application else it's run uniformly, in this we show as a message so we use Tkinter message box function and because we ask a question from the user we use askquestion() function.


OUTPUT IS -



ree



So we hope this is helpful for you.

Thanks for reading.

 
 
 

Comments


pythonlearner

  • Instagram
  • Facebook

©2022 by pythonlearner. Proudly created with Wix.com

bottom of page