Table of Contents
Python tkinter
Python is a powerful programming language for the current period of time. Tkinter of Python is a popular package of python to introduce Graphical User Interface (GUI) among the programmers of this langugae.
This package is available for Linux/Unix, MAC OS and Windows system. This tkinter package is also termed as “Tk Interface”. tkinter module is spread across many other modules. For developing a GUI application using tkinter, we need to add tkinter module to the project as well as tkinter.ttk module. You can visit this link to read the whole documentation of Python tkinter.
Login Form
Login Forms are very useful for the applications that require security protection. Programmers develop this form to authenticate the real users of their applications by entering the username and password of the users.
Login Form in Python tkinter
Login Forms can be developed under Python tkinter also. In this tutorial blog, you can learn how to create a simple login form using Python tkinter with a very simple and few lines of code.
The Simple Login Form in Python tkinter will look like this –
In the above login form, a window with geometry 300 x 300 is taken with title “Login”. In this box, two labels with text values Username and Password are declared. Also, two Entry boxes have been declared for entering username and password of the user.
Further, a login button is declared with text value Login. This button will be used for the login process by the user.
The python tkinter code for Simple Login Form –
import tkinter as tk
from tkinter import *
r = tk.Tk()
r.geometry("300x300")
r.title("Login")
lbl1 = tk.Label(r, text="Username: ")
lbl1.place(x = 20, y = 20)
username = tk.Entry(r, width="35")
username.place(x = 100, y = 20, width = 100)
lbl2 = tk.Label(r, text="Password: ")
lbl2.place(x = 20, y = 50)
password = tk.Entry(r, width="35")
password.place(x = 100, y = 50, width = 100)
submitBtn = tk.Button(r, text="Login", bg="green", fg="#ffffff")
submitBtn.place(x = 20, y = 90, width = 100)
r.mainloop()
Above python tkinter code will be very useful for you for creating a simple login form for your application.
Happy Coding …