Create a registration form in python using Tkinter package
In this session, we are going to learn to create a registration form using the Tkinter package in python.
How to create a registration form in Python using Tkinter package
Tkinter is a Graphics User Interface toolkit which is used to create a user interface
So 1st we have to install Tkinter package through the command :
pip install Tkinter
Now we are going to jump into the coding part:
1st import the package:
from tkinter import*
second, we have to draw a window for that this is python code:
from tkinter import* root = Tk() root.geometry('500x500') root.title("Registration Form")
now we have to add some level as well as some entry boxes:
label_0 = Label(root, text="Registration form",width=20,font=("bold", 20)) label_0.place(x=90,y=53) label_1 = Label(root, text="FullName",width=20,font=("bold", 10)) label_1.place(x=80,y=130) entry_1 = Entry(root) entry_1.place(x=240,y=130) label_2 = Label(root, text="Email",width=20,font=("bold", 10)) label_2.place(x=68,y=180) entry_2 = Entry(root) entry_2.place(x=240,y=180) label_3 = Label(root, text="Gender",width=20,font=("bold", 10)) label_3.place(x=70,y=230) var = IntVar() Radiobutton(root, text="Male",padx = 5, variable=var, value=1).place(x=235,y=230) Radiobutton(root, text="Female",padx = 20, variable=var, value=2).place(x=290,y=230) label_4 = Label(root, text="Age:",width=20,font=("bold", 10)) label_4.place(x=70,y=280) entry_2 = Entry(root) entry_2.place(x=240,y=280)
At last, we have to add a submit button to submit the information os users:
Button(root, text='Submit',width=20,bg='brown',fg='white').place(x=180,y=380)
combine the whole program:
from tkinter import* root = Tk() root.geometry('500x500') root.title("Registration Form") label_0 = Label(root, text="Registration form",width=20,font=("bold", 20)) label_0.place(x=90,y=53) label_1 = Label(root, text="FullName",width=20,font=("bold", 10)) label_1.place(x=80,y=130) entry_1 = Entry(root) entry_1.place(x=240,y=130) label_2 = Label(root, text="Email",width=20,font=("bold", 10)) label_2.place(x=68,y=180) entry_2 = Entry(root) entry_2.place(x=240,y=180) label_3 = Label(root, text="Gender",width=20,font=("bold", 10)) label_3.place(x=70,y=230) var = IntVar() Radiobutton(root, text="Male",padx = 5, variable=var, value=1).place(x=235,y=230) Radiobutton(root, text="Female",padx = 20, variable=var, value=2).place(x=290,y=230) label_4 = Label(root, text="Age:",width=20,font=("bold", 10)) label_4.place(x=70,y=280) entry_2 = Entry(root) entry_2.place(x=240,y=280) Button(root, text='Submit',width=20,bg='brown',fg='white').place(x=180,y=380) # it is use for display the registration form on the window root.mainloop() print("registration form seccussfully created...")
Output:
registration form seccussfully created...
Output:
Read other tutorials as well,
how to show that entered info after clicking the submit button?
Where the data of this form will be saved. I have also created a form like this but i am unable to save the data in a csv file. Plz help me to do the same.
After clicking submit button print msg is not displayed what can I do for that msg?