GUI Billing System and Menu Card Using Python

Last Updated : 03 Jun, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

So imagine that we’re starting a new restaurant or being appointed as one of the employees in a restaurant company, and we find out that there’s no fast method of doing the billing of customers, and it usually takes times for us to calculate the amount that a customer has to pay. This can be really annoying and time taking thing for us as well as for customers. So now what to do? Here’s when python comes to the rescue and since we know it, it will be just a few seconds of work.

So, in this article, we’re going to build a GUI billing system and a menu card with the help of python’s module Tkinter.

Step 1: Importing the tkinter package

from tkinter import *

Step 2: Downloading the required files

Here’s only one file we have to install in this project which will work as the background image of our GUI Billing System or we can choose any other image. After downloading make sure that the python program which we are creating and these assets are in the same folder.

Image Used:

bg1compressed2-copy-2


Step 3: Making tkinter window and setting the background

Now we make the tkinter window and set the background for the GUI 

Python
# import tkinter module
from tkinter import *

# make a window
window = Tk()

# specify it's size
window.geometry("700x600")

# take a image for background
bg = PhotoImage(file='bg.png')

# label it in the background
label17 = Label(window, image=bg)

# position the image as well
label17.place(x=0, y=0)

# closing the main loop
window.mainloop()

Output: 

Step 4: Adding the title and menu card

Now we will add the title and menu card for the GUI billing system with help of “Label()” function. Tkinter Label is a widget that is used to implement display boxes where we can place text or images. The text displayed by this widget can be changed by the developer at any time you want. It is also used to perform tasks such as underlining the part of the text and span the text across multiple lines. It is important to note that a label can use only one font at a time to display text. To use a label, we just have to specify what to display in it (this can be text, a bitmap, or an image).

Syntax: w = Label ( master, option, … )

Parameters:  

  • master: This represents the parent window
  • options: These options can be used as key-value pairs separated by commas
Python
# main title
label8 = Label(window, text="Saransh Restaurant",
               font="times 28 bold")
label8.place(x=350, y=20, anchor="center")

# Menu Card
label1 = Label(window, text="Menu",
               font="times 28 bold")
label1.place(x=520, y=70)

label2 = Label(window, text="Aloo Paratha Rs 30",
               font="times 18")
label2.place(x=450, y=120)

label3 = Label(window, text="Samosa  Rs 5",
               font="times 18")
label3.place(x=450, y=150)

label4 = Label(window, text="Pizza   Rs 150",
               font="times 18")
label4.place(x=450, y=180)

label5 = Label(window, text="Chilli Potato  Rs 50",
               font="times 18")
label5.place(x=450, y=210)

label6 = Label(window, text="Chowmein   Rs 70",
               font="times 18")
label6.place(x=450, y=240)

label7 = Label(window, text="Gulab Jamun  Rs 35",
               font="times 18")
label7.place(x=450, y=270)

# closing the main loop
window.mainloop()

Output:  

Step 5: Adding the billing section

Now we will add the billing section by using the same label widget and the entry widget. The Entry Widget is a Tkinter Widget used to Enter or display a single line of text. Also, Label.place(x,y) indicates the position of the label in the tkinter window.

Syntax: entry = tk.Entry(parent, options)

Parameters:  

  • parent: This represents the parent window
  • options: These options can be used as key-value pairs separated by commas
Python
#------billing section---------
label9=Label(window,text="Select the items",
             font="times 18")
label9.place(x=115,y=70)

label10=Label(window,text="Aloo Paratha",
              font="times 18")
label10.place(x=20,y=120)

e1=Entry(window)
e1.place(x=20,y=150)

label11=Label(window,text="Samosa",
              font="times 18")
label11.place(x=20,y=200)

e2=Entry(window)
e2.place(x=20,y=230)

label12=Label(window,text="Pizza",
              font="times 18")
label12.place(x=20,y=280)

e3=Entry(window)
e3.place(x=20,y=310)

label13=Label(window,text="Chilli Potato",
              font="times 18")
label13.place(x=20,y=360)

e4=Entry(window)
e4.place(x=20,y=390)

label14=Label(window,text="Chowmein",
              font="times 18")
label14.place(x=250,y=120)

e5=Entry(window)
e5.place(x=250,y=150)

label15=Label(window,text="Gulab Jamun",
              font="times 18")
label15.place(x=250,y=200)

e6=Entry(window)
e6.place(x=250,y=230)

# closing the main loop
window.mainloop() 

Output: 

Step 6: Calculating the bill and refreshing the window

After that, we have to add the calculate function which will get executed every second. In the calculate function we have to do simple math where if e.get() returns an empty string then it means that there’s no quantity selected for that particular food, else if there’s any value present in the e.get() then since it is of string type we convert it to int type and multiply this quantity of food with the price of that food. The food variable along with its quantity and price is kept in a dictionary. We look for every key in the dictionary and accordingly increment our ‘total’  variable. After that, we make another label where we use the total variable’s value to display the total amount of foods ordered. Then we made a command that after every 1000 milliseconds we refresh the window to again calculate the total amount of foods ordered which will update our GUI. Also, the total amount label gets updated by destroying the previous one and updating it with a new one every second. 

Python
# function to calculate the
# price of all the orders


def calculate():
  
   # dic for storing the food quantity and price
    dic = {'aloo_partha': [e1, 30],
           'samosa': [e2, 5],
           'pizza': [e3, 150],
           'chilli_potato': [e4, 50],
           'chowmein': [e5, 70],
           'gulab_jamun': [e6, 35]}
    total = 0
    
    for key, val in dic.items():
        if val[0].get() != "":
            total += int(val[0].get())*val[1]
    label16 = Label(window,
                    text="Your Total Bill is - "+str(total),
                    font="times 18")

    # position
    label16.place(x=20, y=490)

    # it will update the label with a new one
    label16.after(1000, label16.destroy)

    # refreshing the window
    window.after(1000, calculate)


# execute calculate function after 1 second
window.after(1000, calculate)
window.mainloop()

Output: 

Below is the full implementation:

Python
# import tkinter module
from tkinter import *

# make a window
window = Tk()

# specify it's size
window.geometry("700x600")

# take a image for background
bg = PhotoImage(file='bg.png')

# label it in the background
label17 = Label(window, image=bg)

# position the image as well
label17.place(x=0, y=0)


# function to calculate the
# price of all the orders
def calculate():

        # dic for storing the
    # food quantity and price
    dic = {'aloo_partha': [e1, 30],
           'samosa': [e2, 5],
           'pizza': [e3, 150],
           'chilli_potato': [e4, 50],
           'chowmein': [e5, 70],
           'gulab_jamun': [e6, 35]}
    total = 0
    for key, val in dic.items():
        if val[0].get() != "":
            total += int(val[0].get())*val[1]

    label16 = Label(window,
                    text="Your Total Bill is - "+str(total),
                    font="times 18")

    # position it
    label16.place(x=20, y=490)
    label16.after(1000, label16.destroy)
    window.after(1000, calculate)


label8 = Label(window,
               text="Saransh Restaurant",
               font="times 28 bold")
label8.place(x=350, y=20, anchor="center")


label1 = Label(window,
               text="Menu",
               font="times 28 bold")

label1.place(x=520, y=70)

label2 = Label(window, text="Aloo Paratha  \
Rs 30", font="times 18")

label2.place(x=450, y=120)

label3 = Label(window, text="Samosa    \
Rs 5", font="times 18")

label3.place(x=450, y=150)

label4 = Label(window, text="Pizza        \
Rs 150", font="times 18")
label4.place(x=450, y=180)

label5 = Label(window, text="Chilli Potato  \
Rs 50", font="times 18")

label5.place(x=450, y=210)

label6 = Label(window, text="Chowmein   \
Rs 70", font="times 18")

label6.place(x=450, y=240)

label7 = Label(window, text="Gulab Jamun  \
Rs 35", font="times 18")

label7.place(x=450, y=270)

# billing section
label9 = Label(window, text="Select the items",
               font="times 18")
label9.place(x=115, y=70)

label10 = Label(window,
                text="Aloo Paratha",
                font="times 18")
label10.place(x=20, y=120)

e1 = Entry(window)
e1.place(x=20, y=150)

label11 = Label(window, text="Samosa",
                font="times 18")
label11.place(x=20, y=200)

e2 = Entry(window)
e2.place(x=20, y=230)

label12 = Label(window, text="Pizza",
                font="times 18")
label12.place(x=20, y=280)

e3 = Entry(window)
e3.place(x=20, y=310)

label13 = Label(window,
                text="Chilli Potato",
                font="times 18")
label13.place(x=20, y=360)

e4 = Entry(window)
e4.place(x=20, y=390)

label14 = Label(window,
                text="Chowmein",
                font="times 18")
label14.place(x=250, y=120)

e5 = Entry(window)
e5.place(x=250, y=150)

label15 = Label(window,
                text="Gulab Jamun",
                font="times 18")

label15.place(x=250, y=200)

e6 = Entry(window)
e6.place(x=250, y=230)

# execute calculate function after 1 second
window.after(1000, calculate)

# closing the main loop
window.mainloop()

Output:



Previous Article
Next Article

Similar Reads

Visiting Card Scanner GUI Application using Python
Python is an emerging programming language that consists of many in-built modules and libraries. Which provides support to many web and agile applications. Due to its clean and concise syntax behavior, many gigantic and renowned organizations like Instagram, Netflix so-and-so forth are working in Python work-frame and heading towards magnificent gr
6 min read
Login Application and Validating info using Kivy GUI and Pandas in Python
Prerequisites : Kivy, Pandas Kivy is a multiplatform GUI library, known for being responsive. It provides management of multiple screens in a single application. In this application we will be using multiple screens to log in user's info and validate it. We will save the information in a csv file and use pandas to validate the information inside of
5 min read
Create a GUI to get Sunset and Sunrise time using Python.
Prerequisite: Tkinter module In this article, we are going to write python scripts to get sunset and sunrise time and bind it with the GUI application. Before starting we need to understand suntime and geopy module Modules Needed: suntime module: This module will return the sunset and sunrise time calculation python library. Run this command in you
3 min read
GUI to Shutdown, Restart and Logout from the PC using Python
In this article, we are going to write a python script to shut down or Restart or Logout your system and bind it with GUI Application. The OS module in Python provides functions for interacting with the operating system. OS is an inbuilt library python. Syntax : For shutdown your system : os.system("shutdown /s /t 1") For restart your system : os.s
1 min read
GUI to get views, likes, and title of a YouTube video using YouTube API in Python
Prerequisite: YouTube API, Tkinter Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. In this art
2 min read
GUI to generate and store passwords in SQLite using Python
In this century there are many social media accounts, websites, or any online account that needs a secure password. Often we use the same password for multiple accounts and the basic drawback to that is if somebody gets to know about your password then he/she has the access to all your accounts. It is hard to remember all the distinct passwords. We
8 min read
Using lambda in GUI programs in Python
Python Lambda Functions are anonymous function means that the function is without a name. In this article, we will learn to use lambda functions in Tkinter GUI. We use lambda functions to write our code more efficiently and to use one function many times by passing different arguments. We use the lambda function to pass arguments to other functions
3 min read
Python | Simple GUI calculator using Tkinter
Prerequisite: Tkinter Introduction, lambda function Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter outputs the fastest and easiest way to create GUI a
6 min read
Python | Distance-time GUI calculator using Tkinter
Prerequisites : Introduction to Tkinter | Using google distance matrix API Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter outputs the fastest and easiest wa
7 min read
Cryptography GUI using python
Using cryptography techniques we can generate keys for a plain text which can not be predicted easily. We use Cryptography to ensure the safe and secure flow of data from one source to another without being accessed by a malicious user. Prerequisites: Language used - Python. Tkinter - This module is used to make GUIs using python language. To know
4 min read
Python | Create a GUI Marksheet using Tkinter
Create a python GUI mark sheet. Where credits of each subject are given, enter the grades obtained in each subject and click on Submit. The credits per subject, the total credits as well as the SGPA are displayed after being calculated automatically. Use Tkinter to create the GUI interface. Refer the below articles to get the idea about basics of t
8 min read
Python: Weight Conversion GUI using Tkinter
Prerequisites: Python GUI – tkinterPython offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter outputs the fastest and easiest way to create GUI applications. Crea
2 min read
Python | ToDo GUI Application using Tkinter
Prerequisites : Introduction to tkinter Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. In this article, we will learn how to create a ToDo GUI application using Tkinter, with a step-by-step guide. To create a tkinter : Importing the module – tkinter
5 min read
Python | GUI Calendar using Tkinter
Prerequisites: Introduction to Tkinter Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to create a GUI Calendar application using
4 min read
Sentiment Detector GUI using Tkinter - Python
Prerequisites : Introduction to tkinter | Sentiment Analysis using Vader Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to creat
4 min read
Python - Morse Code Translator GUI using Tkinter
Prerequisites : Introduction to tkinter | Morse Code Translator Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to create a Morse
6 min read
Python - SpongeBob Mocking Text Generator GUI using Tkinter
Prerequisites : Introduction to tkinter | SpongeBob Mocking Text Generator Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to cre
4 min read
Python - Spell Corrector GUI using Tkinter
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter outputs the fastest and easiest way to create GUI applications. In this article, we will learn how to create a GUI Spell Corrector application using Tkinter, with a step-by-step gu
5 min read
Python - UwU text convertor GUI using Tkinter
Prerequisites :Introduction to tkinter | UwU text convertor Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter outputs the fastest and easiest way to crea
4 min read
GST Rate Finder GUI using Python-Tkinter
Prerequisites : Introduction to tkinter | Program to calculate GSTPython offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. In this article, we will learn how to create GST Rate Finder GUI application using Tkinter, with a step-by-step guide. To create a Tki
3 min read
Create GUI for Downloading Youtube Video using Python
Prerequisites: Python GUI – tkinter YouTube is a very popular video-sharing website. Downloading a video's/playlist from YouTube is a tedious task. Downloading that video through Downloader or trying to download it from a random website increase's the risk of licking your personal data. Using the Python Tkinter package, this task is very simple-eff
12 min read
Create Copy-Move GUI using Tkinter in Python
Everyone reading this post is well aware of the importance of Copying the file or moving the file from one specific location to another. In this post, we have tried to explain not only the program but added some exciting pieces of Interface. Up to now, many of you may get about what we are talking about. Yes, you are right, We are going to use "Tki
4 min read
Python - English (Latin) to Hindi (Devanagiri) text convertor GUI using Tkinter
Prerequisites : Introduction to tkinter | Text transliteration from English to Indian languages – Using indic-transliterationPython offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python
4 min read
Standard GUI Unit Converter using Tkinter in Python
Prerequisites: Introduction to tkinter, Introduction to webbrowser In this article, we will learn how to create a standard converter using tkinter. Now we are going to create an introduction window that displays loading bar, welcome text, and user's social media profile links so that when he/she shares his code with some others, they can contact th
12 min read
GUI chat application using Tkinter in Python
Chatbots are computer program that allows user to interact using input methods. The Application of chatbots is to interact with customers in big enterprises or companies and resolve their queries. Chatbots are mainly built for answering standard FAQs. The benefit of this type of system is that customer is no longer required to follow the same tradi
7 min read
Text to speech GUI convertor using Tkinter in Python
Prerequisite: Introduction to Tkinter Tkinter is the standard GUI library for Python. Python when combined with tkinter provides a fast and easy way to create GUI applications.By this library we can make a compelling choice for building GUI applications in Python, especially for applications where a modern sheen is unnecessary, and the top priority
3 min read
Build a GUI Application to Get Live Stock Price using Python
The stock price is the highest amount someone is willing to pay for the stock. In this article, we are going to write code for getting live share prices for each company and bind it with GUI Application. Module Needed Yahoo_fin: This module is used to scrape historical stock price data, as well as to provide current information on market caps, divi
3 min read
Build a Voice Recorder GUI using Python
Prerequisites: Python GUI – tkinter, Create a Voice Recorder using Python Python provides various tools and can be used for various purposes. One such purpose is recording voice. It can be done using the sounddevice module. This recorded file can be saved using the soundfile module Module NeededSounddevice: The sounddevice module provides bindings
2 min read
Build a GUI Application to get distance between two places using Python
Prerequisite: Tkinter In this article, we are going to write a python script to get the distance between two places and bind it with the GUI application. To install the GeoPy module, run the following command in your terminal. pip install geopy Approach used: Import the geopy module.Initialize Nominatim API to get location from the input string.Get
2 min read
Create a GUI to Extract information from VIN number Using Python
Prerequisite: Python GUI – tkinter In this article, we are going to look at how can we use Python to extract vehicle information from its VIN number (Vehicle Identification Number). A VIN consists of 17 characters (digits and capital letters) that act as a unique identifier for the vehicle. It is a unique code that is assigned to every motor vehicl
3 min read
three90RightbarBannerImg