Beispiel #1
0
def login_verify():
    username1 = username_verify.get()
    password1 = password_verify.get()

    # This will clear the fields whence the user is logged in successfully
    username_entry1.delete(0, END)
    password_entry1.delete(0, END)

    # We are checking to see if the user has been added in a data file they created
    # for a successful login
    list_of_files = os.listdir()
    if username1 in list_of_files:
        file1 = open(username1, "r")
        verify = file1.read().splitlines()
        if password1 in verify:
            print("login successful")
            Label(screen2,
                  text="Login successful",
                  fg="green",
                  font=("calibri", 11)).pack()

            # Show a message prompt that the login was successful
            messagebox.showinfo("Success",
                                "We are taking you to the main menu")

            # Destroy the login windows
            screen2.destroy()
            screen.destroy()
            test.vp_start_gui()
            # Open the main menu window
            ##newroot = Tk()
            ##application = School_Portal(newroot)
            ##newroot.mainloop()

        else:
            print(
                "That password seems incorrect.  Please type in the correct password"
            )
            Label(screen2,
                  text="Incorrect password.  Please try again",
                  fg="red",
                  font=("calibri", 11)).pack()
    else:
        print("User not found")
        Label(
            screen2,
            text=
            "Login not successful.  Please check your username and password again",
            fg="red",
            font=("calibri", 11)).pack()
    print('test_support.monthly_theft_line_chart')
    sys.stdout.flush()

def quit():
    if messagebox.askokcancel("Exit", "Would you like to exit the program?"):
        root.destroy()
    print('test_support.quit')
    sys.stdout.flush()

def submit():
    print('test_support.submit')
    sys.stdout.flush()

def top_crimes():
    print('test_support.top_crimes')
    sys.stdout.flush()

def destroy_window():
    # Function which closes the window.
    global top_level
    top_level.destroy()
    top_level = None

if __name__ == '__main__':
    import test
    test.vp_start_gui()