Tkinter Designer

← All templates

Login form template for tkinter

Open this design in the browser-based designer, rearrange it, and download the Python. Nothing to install, and you don't need an account to try it.

Open in designer →

What this template shows you

  • Reading Entry text with .get() and masking a password with show="*"
  • Wiring a Button command to a class method
  • Clearing a field with .delete(0, "end")

The Python it generates

This is the actual main.py you get when you download it: standard-library tkinter, no framework, yours to edit:

import tkinter as tk
from tkinter import ttk


class Application:
    def __init__(self, root):
        self.root = root
        root.title("Login")
        root.geometry("360x240")

        self.label1 = tk.Label(root, text="Username")
        self.label1.place(x=40, y=42, width=80, height=26)

        self.entry1 = tk.Entry(root)
        self.entry1.place(x=140, y=40, width=170, height=28)

        self.label2 = tk.Label(root, text="Password")
        self.label2.place(x=40, y=92, width=80, height=26)

        self.entry2 = tk.Entry(root, show="*")
        self.entry2.place(x=140, y=90, width=170, height=28)

        self.button1 = tk.Button(root, text="Log in", command=self.on_button1)
        self.button1.place(x=140, y=140, width=100, height=34)

        self.label3 = tk.Label(root, text="")
        self.label3.place(x=40, y=190, width=270, height=26)

    def on_button1(self):
        username = self.entry1.get()
        password = self.entry2.get()
        if username and password:
            self.label3.configure(text="Welcome, " + username + "!")
        else:
            self.label3.configure(text="Enter a username and password.")
        self.entry2.delete(0, "end")


if __name__ == "__main__":
    root = tk.Tk()
    app = Application(root)
    root.mainloop()

Save it and run it the usual way:

python main.py

Make it your own. Edit the layout visually, then download the code.

Open the login form template →

Other templates

  • Calculator: Display plus a 4×4 keypad with working press/clear/equals code.
  • To-do list: Entry, listbox, and add/remove buttons, all wired up.
  • Temperature converter: The classic beginner project: Celsius in, Fahrenheit out.
  • Quiz app: Multiple-choice question with radiobuttons and answer checking.