Login Button Function Login Button Function tkinter tkinter

Login Button Function


There are three issues:

  1. The callback function needs to be assigned to the command option on the Button widget.
  2. The two entry widgets need different variable names for access in the callback
  3. The callback function needs a body of code that does something.

The code should be

import tkinterwindow = tkinter.Tk()window.title("Login")window.geometry("250x150")window.configure(background="#FFFFFF")label = tkinter.Label(window, text="Please Login to continue:", bg="#FFFFFF", font=("PibotoLt", 16))label.pack()label = tkinter.Label(window, text="username:", bg="#FFFFFF")label.pack()entry0 = tkinter.Entry(window) # Renamed entry0 to find in callbackentry0.pack()label = tkinter.Label(window, text="password:", bg="#FFFFFF")label.pack()entry1 = tkinter.Entry(window) # Renamed entry1 to differentiate from entry0entry1.pack()def callback():    """ Callback to process a button click. This will be called whenever the button is clicked.        As a simple example it simply prints username and password.    """    print("Username: ", entry0.get(), "    Password: ", entry1.get())button = tkinter.Button(window, text="Login", fg="#FFFFFF", bg="#000000", command=callback)button.pack()window.mainloop()