The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Create a simple screen locker

Here’s a simple Python script that creates a basic screen locker by displaying a fullscreen window that asks for a password to unlock. It uses tkinter for the GUI and blocks input to other windows until the correct password is entered.

python
import tkinter as tk PASSWORD = "1234" # Set your password here def check_password(): if entry.get() == PASSWORD: root.destroy() else: entry.delete(0, tk.END) label.config(text="Wrong password, try again.", fg="red") root = tk.Tk() root.attributes("-fullscreen", True) root.configure(bg="black") label = tk.Label(root, text="Enter Password to Unlock:", fg="white", bg="black", font=("Arial", 24)) label.pack(pady=20) entry = tk.Entry(root, show="*", font=("Arial", 24)) entry.pack(pady=20) entry.focus() button = tk.Button(root, text="Unlock", command=check_password, font=("Arial", 20)) button.pack(pady=20) root.mainloop()

How it works:

  • Runs a fullscreen black window on top of everything.

  • Shows a password prompt with an entry box.

  • Only closes (unlocks) if the correct password is entered.

  • Blocks interaction with other apps until unlocked.

To run: Save the code as screen_locker.py and run python screen_locker.py.

Would you like a version with additional security features or on another platform?

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About