如何将用户重定向到另一个窗口而不必弹出两个窗口

2024-09-29 23:27:35 发布

您现在位置:Python中文网/ 问答频道 /正文

如何将用户重定向到另一个窗口,而不必在用户使用用户名/密码登录后弹出两个窗口?你知道吗

from  tkinter import *
import sys

#_________USERNAME&PASSOWRD_______________________
username = 'gjergjk71'
password = 'gjergji.123'
#__________LOGIN FUNCTION_________________________
def other_window():
    root1 = Toplevel()
    root1.minsize(width=1000,height=700)
    root1.mainloop()

def login1(*args):
    if login_input.get() == username and password_input.get() == password:
        MESSAGE.set("LOGGED IN SUCCESFULLY!")
        other_window()
    else:
        MESSAGE.set("[error] Username or Password incorrect !")

def about():
    print("dadsa")
    MESSAGE.set("""Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    Cras quis venenatis lectus. Maecenas 
    et molestie eros. Nullam ornare sagittis justo 
    quis molestie. Suspendisse pretium lacinia volutpat. 
    Quisque tempus augue nibh, et mattis elit fermentum id. Inte
    ger scelerisque vehicula tempor. Maecenas elit neq
    ue, imperdiet non pretium et, vulputate quis nunc.
    Sed ac pulvinar leo. Praesent condimentum urna et massa aliqua
    """)
def help():
    MESSAGE.set("""ndisse pretium lacinia volutpat. 
    Quisque tempus augue nibh, et mattis elit fermentum id. Inte
    ger scelerisque vehicNullam ornare sagittis justo 
    quis molestie. Suspea tulLorem ipsum dolor sit amet, consectetur
    adipiscing elit. Cras quis venenatis lectus. Maecenas 
     et molestie eros. empor. Maecenas elit neq
    ue, imperdiet non pretium et, vulputate quis nunc.
    Sed ac pulvinar leo. Praesent condimentum urna et massa aliqua

    """)

#______________________________________
#______________________________________


root = Tk()
root.title("BUSINESS MENAGEMENT")

menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
menubar.add_command(label="ABOUT",command=about)
menubar.add_command(label="HELP",command=help)
root.config(menu=menubar)

Label1 = Label(root, text="CodeSCHOOL", font=("Helvetica",26))
Label1.configure(text="BUSINESS MENAGEMENT")
Label1.pack()

Label2= Label(root,text="USER LOGIN", font=("Helvetica",20))
Label2.pack()

login_input = StringVar()
Login = Entry(root,textvariable= login_input)
Login.pack()

Label3= Label(root,text="USER PASSWORD", font=("Helvetica",20))
Label3.pack()

password_input = StringVar()
Password1 = Entry(root,textvariable= password_input, show="*")
Password1.pack()

Button1= Button(root,text="LOGIN",command=login1)
Button1.pack()

MESSAGE = StringVar()
message1 = Label(root,textvariable=MESSAGE).pack()

root.bind("<Escape>",sys.exit)
root.bind("<Return>", login1)

root.mainloop()

Tags: textmessageinputdefrootpasswordcommandpack

热门问题