Python GUI Tkinter Project for Fully Automated Data Entry User Form

Posted by


In this tutorial, we will be creating a fully automated data entry user form using Python and the GUI library Tkinter. This project will allow users to input data into a form, which will then be automatically saved to a CSV file for easy retrieval and analysis.

Step 1: Setting up your environment
First, make sure you have Python installed on your computer. You can download Python from the official website at https://www.python.org/. Once you have Python installed, you will also need to install the Tkinter library, which comes pre-installed with most Python installations.

Step 2: Creating the user interface
To create the user interface, we will use Tkinter to design a simple form with input fields for the user to enter their data. We will create input fields for the user’s name, age, email, and phone number. Additionally, we will add a "Submit" button to save the data to a CSV file.

import tkinter as tk
from tkinter import ttk
import csv

def submit_form():
    name = name_entry.get()
    age = age_entry.get()
    email = email_entry.get()
    phone = phone_entry.get()

    with open('data.csv', mode='a', newline='') as file:
        writer = csv.writer(file)
        writer.writerow([name, age, email, phone])

    name_entry.delete(0, tk.END)
    age_entry.delete(0, tk.END)
    email_entry.delete(0, tk.END)
    phone_entry.delete(0, tk.END)

root = tk.Tk()
root.title("Data Entry Form")

name_label = ttk.Label(root, text="Name:")
name_label.grid(row=0, column=0)
name_entry = ttk.Entry(root)
name_entry.grid(row=0, column=1)

age_label = ttk.Label(root, text="Age:")
age_label.grid(row=1, column=0)
age_entry = ttk.Entry(root)
age_entry.grid(row=1, column=1)

email_label = ttk.Label(root, text="Email:")
email_label.grid(row=2, column=0)
email_entry = ttk.Entry(root)
email_entry.grid(row=2, column=1)

phone_label = ttk.Label(root, text="Phone:")
phone_label.grid(row=3, column=0)
phone_entry = ttk.Entry(root)
phone_entry.grid(row=3, column=1)

submit_button = ttk.Button(root, text="Submit", command=submit_form)
submit_button.grid(row=4, column=0, columnspan=2)

root.mainloop()

Step 3: Saving the data to a CSV file
In the submit_form function, we extract the data entered by the user from the input fields and save it to a CSV file named data.csv. We use the csv.writer class to write the data in a row format, with each field separated by a comma. After saving the data, we clear the input fields to allow the user to enter new data.

Step 4: Running the application
To run the application, save the code in a Python file (e.g., data_entry_form.py) and execute it in your terminal or Python IDE. A window will open with the data entry form, where users can enter their information and click the "Submit" button to save it to the CSV file.

That’s it! You have successfully created a fully automated data entry user form using Python and Tkinter. This project can be expanded further by adding validation checks, error handling, and additional fields to gather more data from users. Thank you for following along with this tutorial, and happy coding!

0 0 votes
Article Rating
44 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@aatifansari8685
1 month ago

Source code please ek sath data store karna h excel or database me

@uroojkanwal66
1 month ago

your all videos very amazing

@abhisheknirmal5111
1 month ago

Sir can u please send the code

@sunitarathore6244
1 month ago

bhai you are so talented and best from others ❤❤😍😍😊😊❤❤

@rahultekam395
1 month ago

Error occurred: module pathlib has no attribute path

@bigreflect7649
1 month ago

Great Tutorial
Thank you 🤗

@kingmenka2085
1 month ago

you the best Sir good video….

@IMISSYOU308
1 month ago

TALLY PRIME MAI KIS TARHA USE KAR SAKTE HAI PAYTHON KO US PAR VIDEO BANAO SIR JI

@parajf
1 month ago

Can u provided sources code

@ziyaefkar2985
1 month ago

file = pathlib.Path("Backened_data.xlsx")

if file exits():

pass

else:

file = Workbook()

sheet = file.active

sheet["A1"] = "Full Name"

sheet["B1"] = "Contact"

sheet["C1"] = "Age"

sheet["D1"] = "Gender"

sheet["E1"] = "Adress"

file.save("Backened_data.xlsx")

Thanks for your works.. what is wrong here that ı see: if file exits():

^^^^^

SyntaxError: invalid syntax

@greengrass4221
1 month ago

file.save(r.'Backemed_data.xlsx')

Error a rha hai sir

@elvinaadellia6737
1 month ago

❤❤❤❤❤❤❤❤❤❤❤❤

@adjouwadalhadhur8658
1 month ago

^^^^^^^^^^^^^^^^

line 31, in submit

sheet=file.active()

^^^^^^^^^^^^^

TypeError: 'Worksheet' object is not callable

Can you help please???

@MarioNabil-c2y
1 month ago

We want to get these projects or codes, please send them to me
How do I get projects

@JeremiahEboh
1 month ago

i'm having this error code :Cannot convert <class 'tkinter.StringVar'> to Excel

@NatureNomad13
1 month ago

how can i get this code?

@micmike
1 month ago

Hello again, never mind my previous question. I discovered the "Entry" you coded is a widget and that by using form tkinter import all you can access "Entry" widget. I didn't import * from Tkinter because it's not recommended by many. So, i would like to mention that it would be nice when your working with a widget to say so but perhaps not everyone is a dummy like me…

@micmike
1 month ago

How did you declare 'nameEntry = Entry' I get an error, Entry not defined? Should I assign Entry to a textbox? or just create "textbox_name=tk.Text()"?

@vashhdastampede7305
1 month ago

i dont see how this i faster than just writing the same info in the spread sheet

@mathansubramani430
1 month ago

i need to save my data to a different sheets depending upon data entered by user by "one combo box field " can you help with that