Example #1
0
    user_value = input(f"\nHi {username.strip()}. Please select an option: ")
    core.function_clear()
    if user_value == "0":
        core.thank_you()
        sys.exit(0)

    elif user_value == "1":  # product menu
        product_menu = True
        while product_menu == True:
            product_functions.product_menu()  # imported function
            p_value = input(
                f"Hi {username.strip()}. Please select an option: ")
            core.function_clear()
            if p_value == "0":
                core.thank_you()
                connectdb.close_connection(
                )  # the data persists and is committed to the database
                sys.exit(0)
            elif p_value == "1":
                core.function_clear()
                product_functions.product_view(products)
                input(
                    f"\nHi {username}, press Enter to continue browsing in the Data Cafe app.\n"
                )  # when input, the programme stops until the user inputs something
                core.function_clear(
                )  # view list of p, then clearing terminal and back to p menu
            elif p_value == "2":
                core.function_clear()
                product_functions.product_add(products)
                input(
                    f"\nHi {username}, press Enter to continue browsing in the Data Cafe app.\n"
                )  # this can also be added at the end of the function, but I added it here for better user experience because I used f-string
Example #2
0
 def onQuit(self, event):
     #close database connection
     connectdb.close_connection(self.conn) 
     self.Close()
     self.Destroy()