Create the registration form with tkinter in Python show pass(*).

Tkinter is a Python library that makes it easy to create graphical user interfaces. Tkinter is the only GUI Framework that comes pre-installed with the Python Standard Library. Tkinter’s main advantage is that it is cross-platform, which means that the same code may run on Windows, Mac OS. X, and Linux. We will discuss an example where we have to create the registration form with tkinter in python. where we mention Name of a person, Email ID, His/Her Contact Number, Gender and password with (*). 

Example 1.

Create the registration form (Mentioned in the picture attached)
Password should show asterisk (*).

Registration form with python
#Python
#Don't work in online compiler, prefer using IDLE
from tkinter import *
root=Tk()
root.geometry("500x500")
root.title("registration form")

l1=Label(root,text="Enter Name",width=10,font=("arial",12))
l1.place(x=20,y=120)
e1=Entry(root)
e1.place(x=200,y=120)

l3=Label(root,text="Enter Email",width=10,font=("arial",12))
l3.place(x=19,y=160)
e3=Entry(root)
e3.place(x=200,y=160)

l4=Label(root,text="Contact Number",width=13,font=("arial",12))
l4.place(x=19,y=200)
e4=Entry(root)
e4.place(x=200,y=200)

l5=Label(root,text="Select Gender",width=15,font=("arial",12))
l5.place(x=5,y=240)
var=IntVar()
Radiobutton(root,text="Male",padx=5,variable=var,value=1).place(x=180,y=240)
Radiobutton(root,text="Female",padx=10,variable=var,value=2).place(x=240,y=240)
Radiobutton(root,text="others",padx=15,variable=var,value=3).place(x=310,y=240)

list_of_Country=("United States","India","Sri Lanka","France")
c=StringVar()
droplist=OptionMenu(root,c,*list_of_Country)
droplist.config(width=15)
c.set("United States")
l2=Label(root,text="Select Country",width=13,font=("arial",12))
l2.place(x=14,y=280)
droplist.place(x=200,y=275)

l6=Label(root,text="Enter Password",width=13,font=("arial",12))
l6.place(x=19,y=320)
e6=Entry(root,show='*')
e6.place(x=200,y=320)

l7=Label(root,text="Re-Enter Password",width=15,font=("arial",12))
l7.place(x=21,y=360)
e7=Entry(root, show='*')
e7.place(x=200,y=360)

Button(root,text="Register",width=10).place(x=200,y=400)
root.mainloop()

This program will work in Python IDLE as Tkinter is by default available in PYTHON . You can even change the color of the button or texts by just typing the color name of your choice,
example

Button(root,text="Register",width=10,bg='blue',fg='white').place(x=200,y=400)

Related Article: 

Add bg=’background Colour name’,fg=’Foreground Color name’)or else only use bg = ‘color name’  As bg is used to add initial color and fg is used to add color when you click on it.

To show password as (*) use show=’*’ in your entry section of password.
Also you can change the dimensions of whole form by changing the value in

root.geometry("500x500")

altering the value between double quotes. This will adjust your form pixels. 
Also you can adjust the place of elements by changing the x and y dimensions of place. x represents the change of position along horizontal line and y represents the change in position vertically.

We have lots of ways to develop GUI based program by

Tkinter:

Tkinter is a typical GUI (graphical user interface) library for Python. Tkinter is Python’s default GUI package, as well as the most popular way to programme GUIs in Python. Tkinter is a collection of wrappers that convert Tk widgets into Python classes.

wxPython:

This is essentially a C++-based, open-source, cross-platform GUI toolkit. Also available as an alternative to Tkinter

JPython:

JPython is a Python platform for Java that gives Python scripts on the local machine smooth access to Java class libraries.

Leave a Comment

Your email address will not be published. Required fields are marked *