how to make a set username and password in tkinter python

丶灬走出姿态 提交于 2019-12-12 10:28:23

问题


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()

回答1:


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')


来源:https://stackoverflow.com/questions/16525582/how-to-make-a-set-username-and-password-in-tkinter-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!