新来的人在某个循环后,如果政治家

2024-09-30 06:16:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经创建了一个登录页面,在用户成功登录后,我想打开一个新页面。所以我在if之后继续创建rootB。rootB是一个相当大的页面,其他页面总是被不断地往下推。如果我继续从rootB创建新页面,那么整个代码就会变得“混乱”。 所以我的问题是,我如何才能走出这个if循环,继续在底部

提前谢谢。对不起,我完全听不懂

def CheckLogin():
    with open(creds) as f:
        data = f.readlines()
        uname = data[0].rstrip()
        pword = data[1].rstrip()

    if nameEL.get() == uname and pwordEL.get() == pword:  

# What comand o i use so i dont have to continue with the main page here 

        rootB = Tk()  # Opens new window
        rootB.iconbitmap(r"userok.ico")
        rootA.destroy() # Kills previous window
        rootB.title(' ')
        rootB.geometry("900x500")
        rootB.resizable(width=False, height=False)

        topframe = Frame(rootB)
        topframe.pack(side=TOP)
        toolbar = Frame(rootB, bg="blue")

        def doNothing():
            print("ok ok i won`t......")

        insertButton = Button(toolbar, text="insert Image",command=doNothing)
        insertButton.pack(side=RIGHT, padx=2, pady=2)
        printButton = Button(toolbar, text="insert Print", command=doNothing)
        printButton.pack(side=RIGHT, padx=2, pady=2)

        toolbar.pack(side=LEFT, fill=Y)

        bottomframe = Frame(rootB)
        bottomframe.pack(side=BOTTOM)

        button_1 = Button(bottomframe,text="Click me!", fg="green")
        button_2 = Button(bottomframe,text="Click now!", fg="blue")
        button_3 = Button(bottomframe,text="Click friday!", fg="purple")
        button_4 = Button(bottomframe,text="Click sunday!", fg="yellow")

        button_1.pack()
        button_2.pack()
        button_3.pack()
        button_4.pack()

        rootB.mainloop()

    else:
        rootC = Tk()
        rootC.iconbitmap(r"userunknown.ico")
        rootC.title('D:')
        rootC.geometry("400x200")
        rootC.resizable(width=False, height=False)
        rootClbl = Label(rootB, text='\n[!] Invalid Login')
        rootClbl.pack()
        rootC.mainloop()

    def DelUser():
    os.remove(creds)  
    rootA.destroy()  
    Signup()  

    if os.path.isfile(creds):
    Login()

#i would like to continue the main page here

Tags: textfalseifdefbutton页面sidepack

热门问题