如何在tkinter python中设置用户名和密码

如何在tkinter python中设置用户名和密码

问题描述:

在tk inter中,他们可以使用特定的用户名和密码打开特定的文件,就像管理员登录后将其带到管理员页面一样.

In tk inter is their away to make a specific username and password open a specific file like if an administrator logs in he would be taken to a administrator page.

from Tkinter import *

root = Tk()

w = Label(root, text="LiftServer(Sign-in)")
w.pack()

e1 = Label(root, text="******************************")
e1.pack()

w1 = Label(root, text="Username")
w1.pack()

e = Entry(root)
e.pack()

w2 = Label(root, text="Password")
w2.pack()

e1 = Entry(root)
e1.pack()

toolbar = Frame(root)


b = Button(toolbar, text="Enter", width=9)
b.pack(side=LEFT, padx=2, pady=2)

b = Button(toolbar, text="Cancel", width=9)
b.pack(side=LEFT, padx=2, pady=2)

def callback():
    execfile("signup.txt")
b = Button(toolbar, text="Sign-Up", command=callback, width=9)
b.pack(side=LEFT, padx=2, pady=2)

toolbar.pack(side=TOP, fill=X)

mainloop()

不能完全确定您要问的是什么,但我认为这可以解决..

not entirely sure what you are asking but I think this answers it ..

def callback():
    if w.get() == "Bob" and w2.get() == "password":
        openfile('file1')
    else:
        openfile('file2')