【问题标题】:how to make a set username and password in tkinter python如何在 tkinter python 中设置用户名和密码
【发布时间】:2013-05-07 16:41:16
【问题描述】:

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

【问题讨论】:

    标签: python passwords tkinter


    【解决方案1】:

    不完全确定你在问什么,但我认为这回答了它..

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

    【讨论】:

    • Tkinter 回调 Traceback 中的异常(最近一次调用最后一次):调用中的文件“C:\Python27\DLLs\lib\lib-tk\Tkinter.py”,第 1470 行 return self.func(*args) File "C:/Documents and Settings/1209131/Desktop/ftg", line 26, in callback if w1.GetValue() == "Bob" and w2.GetValue() == "password": AttributeError: Label instance has no attribute 'GetValue' 看起来获取值是错误的
    • 这就是我所说的......你需要使用任何你用来“GetValue”的方法来获取文本框(实际上 2 秒的谷歌搜索告诉我它只是 get() 而不是 GetValue() ...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-11
    • 1970-01-01
    • 1970-01-01
    • 2013-10-20
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    相关资源
    最近更新 更多