Application Using python Tkinter | CodeWithArpit🔥🔥

Опубликовано: 18 Март 2026
на канале: CodeWithArpit
35
2

Source Code:
################Import module
import tkinter as tk
from tkinter import messagebox as msgb
import pymysql

#################createing and cutumizing window
root = tk.Tk()
root.title("Application")
root.geometry("710x500+300+80")
root.config(bg="black")
root.resizable(False, False)
####################Variables
idvar = tk.StringVar()
namevar = tk.StringVar()
emailvar = tk.StringVar()
contvar = tk.StringVar()

####################Function
def savedata():
if namevar.get() == "" or emailvar.get() == "" or contvar.get() == "":
msgb.showerror("Application", "All Field Are Requird")

else:
con = pymysql.connect(host="localhost", user="root", password="", db="myapp")
cur = con.cursor()
cur.execute("INSERT INTO `add` (id, name, email, contact_no) VALUES (%s, %s, %s, %s)",
(
idvar.get(),
namevar.get(),
emailvar.get(),
contvar.get()

))

cur.close()
con.commit()

msgb.showinfo("Application", "Data Submited!!!")

idvar.set("")
namevar.set("")
emailvar.set("")
contvar.set("")

####################Title Bar
titlebar = tk.Label(root, text="Application", font=("gouldy", 40, "bold"), bd=10, relief="groove", bg="green", fg="white")
titlebar.pack(fill=tk.X)

####################Labels
lbl1 = tk.Label(root, text="ID :- ", font=("arial", 20), bg="black", fg="white")
lbl1.place(x=10, y=100)

lbl2 = tk.Label(root, text="Name :- ", font=("arial", 20), bg="black", fg="white")
lbl2.place(x=10, y=160)

lbl3 = tk.Label(root, text="Email :- ", font=("arial", 20), bg="black", fg="white")
lbl3.place(x=10, y=220)

lbl4 = tk.Label(root, text="Contact No. :- ", font=("arial", 20), bg="black", fg="white")
lbl4.place(x=10, y=280)


####################Entry Boxes
en1 = tk.Entry(root, textvariable=idvar, font=("arial tur", 20), bg="grey", fg="white")
en1.place(x=220, y=100)

en2 = tk.Entry(root, textvariable=namevar, font=("arial tur", 20), bg="grey", fg="white")
en2.place(x=220, y=160)

en3 = tk.Entry(root, textvariable=emailvar, font=("arial tur", 20), bg="grey", fg="white")
en3.place(x=220, y=220)

en4 = tk.Entry(root, textvariable=contvar, font=("arial tur", 20), bg="grey", fg="white")
en4.place(x=220, y=280)

####################Button
btn1 = tk.Button(root, text="Submit", height=1, width=10, font=("arial", 10), bg="white", fg="black", border=4, relief="groove", command=savedata)
btn1.place(x=80, y=350)


####################Window loop
root.mainloop()