This video shows you how to create user data entry form using tkinter.
Our code for this task is as follows
................................................................................................................
import tkinter as tk
class DataEntryForm:
def __init__(self, master):
self.master = master
master.title("Data Entry Form")
create labels and entry fields
self.label1 = tk.Label(master, text="First Name:")
self.label1.grid(row=0, column=0)
self.entry1 = tk.Entry(master)
self.entry1.grid(row=0, column=1)
self.label2 = tk.Label(master, text="Last Name:")
self.label2.grid(row=1, column=0)
self.entry2 = tk.Entry(master)
self.entry2.grid(row=1, column=1)
create submit button
self.submit_button = tk.Button(master, text="Submit", command=self.submit)
self.submit_button.grid(row=2, column=0, columnspan=2)
def submit(self):
get data from entry fields
field1 = self.entry1.get()
field2 = self.entry2.get()
process data (insert into database, etc.)
print("Field 1:", field1)
print("Field 2:", field2)
clear entry fields
self.entry1.delete(0, tk.END)
self.entry2.delete(0, tk.END)
create GUI
root = tk.Tk()
app = DataEntryForm(root)
root.mainloop()
........................................................................................................................
Music:
www.bensound.com/free-music-for-videos License code: B7DGZDZYD4HKGULN
@sonaliabewardana5771
1 year ago
β€β€β€
1 |