python program for login page using Tkinter package

In this program, we are going to discuss how we can implement the login page in python using the Tkinter package.

Create a login page using Tkinter in Python

1st of all in the login page we have to design a window with two buttons one for login button and another one is register button.

Let’s move on the code 1st import the Tkinter package.

from tkinter import *

Create a function which generates a login window with a login page as a title.

def main_screen():
    mainscreen = Tk()   # create a GUI window 
    mainscreen.geometry("800x800") # set the configuration of GUI window 
    mainscreen.title(" Login Page") # set the title of GUI window

Create a level for some message:




# create a Form label 
Label(text="Login Window Example", bg="blue", width="30", height="2", font=("Calibri", 13)).pack() 
Label(text="").pack()

Now, at last, we have to create two buttons: Register button and a Login button.

# create Login Button 
Button(text="Login", height="2", width="30").pack() 
Label(text="").pack() 

# create a register button
Button(text="Register", height="2",width="30").pack()

Finally, start the window and call the main_screen function:

 
mainscreen.mainloop() # start the GUI

main_screen() # call the main_account_screen() function

Now combine the whole program into a single program so that you can understand what we did.

from tkinter import *
#Designing Main Screen So, first of all, you have to design the main screen.
#two buttons Login and Register.
def main_screen():
    mainscreen = Tk()   # create a GUI window 
    mainscreen.geometry("800x800") # set the configuration of GUI window 
    mainscreen.title(" Login Page") # set the title of GUI window

# create a Form label 
Label(text="Login Window Example", bg="blue", width="30", height="2", font=("Calibri", 13)).pack() 
Label(text="").pack() 

# create Login Button 
Button(text="Login", height="2", width="30").pack() 
Label(text="").pack() 

# create a register button
Button(text="Register", height="2",width="30").pack()
 
mainscreen.mainloop() # start the GUI

main_screen() # call the main_account_screen() function

 

Output:

login page  using tkinter package

 

Also, read;


Leave a Reply

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