Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python、Tkinter、SQlite3在成功登录后将用户重定向到新窗口_Python_Tkinter_Sqlite - Fatal编程技术网

Python、Tkinter、SQlite3在成功登录后将用户重定向到新窗口

Python、Tkinter、SQlite3在成功登录后将用户重定向到新窗口,python,tkinter,sqlite,Python,Tkinter,Sqlite,我是编程新手,我创建了以下源代码来验证用户是否成功登录。我想在用户在条目中输入正确的凭据后,将用户重定向到一个新窗口并删除当前窗口。是否可以使用顶级方法进行此操作 def Is_Valid(): UsernameValidity=UserName_Entry.get() PasswordValidity=Password_Entry.get() cursor.execute('''SELECT password FROM users WHERE user

我是编程新手,我创建了以下源代码来验证用户是否成功登录。我想在用户在条目中输入正确的凭据后,将用户重定向到一个新窗口并删除当前窗口。是否可以使用顶级方法进行此操作

def Is_Valid():

    UsernameValidity=UserName_Entry.get()        
    PasswordValidity=Password_Entry.get()
    cursor.execute('''SELECT password FROM users WHERE username = ?''', (UsernameValidity,))
    cursor.execute('''SELECT username FROM users WHERE password = ?''', (PasswordValidity,))
    LogInAttempt = cursor.fetchone()?
    print (Is_Valid) # Testing 
    if LogInAttempt:
        print (" One of the accounts have successfully logged in ")
        IsValidText.config(text=" You have logged in! ", fg="black", highlightthickness=1)
    else:?
        print (" One of the accounts inputted the wrong credentials! ")
        IsValidText.config(text=" Invalid username or Password! ", fg="black", highlightthickness=1)

假设您的程序能够完美地工作到这一点,那么非常欢迎您使用
Toplevel
方法。我还将包括
.after()
,以便给用户留出时间让用户看到消息

def NewPage():
    global NewRoot
    root.withdraw() # hide (close) the root/Tk window
    NewRoot = tk.Toplevel(root)
    # use the NewRoot as the root now

def Is_Valid():
    # same as before...
    if LogInAttempt:
        print (" One of the accounts have successfully logged in ")
        IsValidText.config(text=" You have logged in! ", fg="black", highlightthickness=1)
        root.after(2000, NewPage) # or whatever your Tk is called
        # redirect to the NewPage function after 2 seconds 
    else:
        print (" One of the accounts inputted the wrong credentials! ")
        IsValidText.config(text=" Invalid username or Password! ", fg="black", highlightthickness=1)
这将关闭原始窗口并弹出一个新的空白窗口。注意:
.after(ms,callback)
使用ms,因此2000ms=2sec


您可能希望去掉cursor.fetchone()和
else
之后的两个随机问号。假设您的程序在这一点上运行良好,您非常欢迎使用
顶级
方法。我还将包括
.after()
,以便给用户留出时间让用户看到消息

def NewPage():
    global NewRoot
    root.withdraw() # hide (close) the root/Tk window
    NewRoot = tk.Toplevel(root)
    # use the NewRoot as the root now

def Is_Valid():
    # same as before...
    if LogInAttempt:
        print (" One of the accounts have successfully logged in ")
        IsValidText.config(text=" You have logged in! ", fg="black", highlightthickness=1)
        root.after(2000, NewPage) # or whatever your Tk is called
        # redirect to the NewPage function after 2 seconds 
    else:
        print (" One of the accounts inputted the wrong credentials! ")
        IsValidText.config(text=" Invalid username or Password! ", fg="black", highlightthickness=1)
这将关闭原始窗口并弹出一个新的空白窗口。注意:
.after(ms,callback)
使用ms,因此2000ms=2sec


你可能想去掉cursor.fetchone()和
else

之后的两个随机问号。你的函数有效吗?它有用吗?如果没有,那就没有继续的必要了是的,它已经测试过了,而且确实有效。但是,我希望在用户输入正确的凭据后,将其重定向到新的干净窗口以及当前正在关闭的主页。您的函数是否有效?它有用吗?如果没有,那就没有继续的必要了是的,它已经测试过了,而且确实有效。但是,我希望在用户输入正确的凭据后,将其重定向到新的干净窗口以及正在关闭的当前主页。我得到以下错误:AttributeError:“\u tkinter.tkapp”对象在toplevel中没有属性“toplevel”大写字母T是的,我尝试过。我仍然收到相同的错误:AttributeError:“\u tkinter.tkapp”对象没有属性“Toplevel”您是如何导入tkinter的?“从tkinter import*”程序保持运行并显示登录成功,但它会自动关闭,并在时间戳后给您该错误。我得到以下错误:AttributeError:“'u tkinter.tkapp'对象在toplevel中没有属性'toplevel'大写字母T是的,我尝试过。我仍然收到相同的错误:AttributeError:“\u tkinter.tkapp”对象没有属性“Toplevel”您是如何导入tkinter的?“from tkinter import*”程序保持运行并显示登录成功,但它会自动关闭,并在时间戳后给出该错误。