簡體   English   中英

如何在tkinter python中設置用戶名和密碼

[英]how to make a set username and password in tkinter python

在tk inter中,他們可以使特定的用戶名和密碼打開特定的文件,就像管理員登錄后將其帶到管理員頁面一樣。

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

不確定您要問的是什么,但我認為這可以回答。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM