Hello I'm currently working on a Interface for fun as a side project using Tkinter. I was wondering if anyone had a small code for a password and shutdown button I do have the button however it doesnt shut down the program. the password has a text box and is * out however the password is not set and pressing enter does nothing. I plan to put a password then you press enter then it opens another window. I'll post my code when i have it. I'm currently at home well writing this. I hope some ideas and some help come about it would be greatful! Thank you.

  • Spencer Longeuay

Which version of Python are you using?

Here is a little example for both Python versions ...

''' tk_Entry_pw1.py
Tkinter program to show masked password entry

    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

root = tk.Tk()

def check_pw():
    pw = pw_entry.get()
    if pw == "peanuts":
        s = "correct"
        s = "incorrect"
    label2['text'] = "{} is {}".format(pw, s)

label1 = tk.Label(root, text="Enter password for user Henri: ")
# shows only * when entering a password
pw_entry = tk.Entry(root, show="*")
# cursor here
# click on button to show the password
button1 = tk.Button(root, text=" check password ", command=check_pw)
# label to show result
label2 = tk.Label(root)
# optional exit button
button2 = tk.Button(root, text=" exit ", command=root.destroy)

# simple widget layout, stack vertical and centered (default)

# start the event loop

I'm currently using the new one i think 3?

This is what I have I do have a CIA background just for fun.

This is the start

from tkinter import *
import tkinter as tk

Create the window
t = Tk()

root = Tk()
root.title("NEOSA Corp Interface")

First Background (Plan to use the same one for the second window.

p = PhotoImage(file="CIA.gif")
l = Label(root, image=p)

Password for main screen #### This is where i have the password box however i'm not sure how to set it up. so that when you enter the password for example: hello it would close the log in window and open the second window.

e = Entry(l, show="*", width=30)
e.pack(side=TOP, anchor=W, padx=450, pady=300)

Main Screen Shut Down #### So I figured out that my shut down button does work how ever it doesn't work in python (dose not respond) however if i run by itself it works.

b = Button(l, command=quit, text="Shut Down")
b.pack(side=BOTTOM, expand=Y, anchor=S)



root = Tk()

Modify root window

root.title("NEOSA Corp Interface")

Kick off the event loop



I'm not sure if that helps I Thanks for taking a look. I did look at your's however I'm not sure how I would put in.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.