Archive

Archive for January 29, 2020

Python: Applications Main Menu

January 29, 2020 Leave a comment


Learning : Application Main Menu
Subject: Main Menu Template

In some of my applications often I start writing codes to create a Menu for some parts in the app. Now in this post we will write a simple general Main Menu Template, to keep the screen prompt waiting for the user we use while True, and to exit we just use return . Here is the code ..

 
'''
Date: 10.1.2020
By: Ali Radwani.  www.ahradwani.com

Main_Menu Function 
'''
import os

def main_menu():

    """
    Template Function to help in creating a Menu for the application.

    You can change the names and functions must be defined.
    """
    while True:
        os.system("clear")
        print('\n ===========[ MENU NAME]=============')
        print('  --------------------------------------')
        print(' 1. Function-1 Name.')
        print(' 2. Function-2 Name. ')
        print(' 3. Function-3 Name')
        print(' 9. Exit')
        uinp= input('\n Enter your Selection: ')

        if uinp == '1':
            Function_1_Name()
        elif uinp == '2':
            Function_2_Name()
        elif uinp == '3':
            Function_3_Name()
        elif uinp =='9':
            return
        else:
            print('\n  Please select from the Menu.'



To Download my Python code (.py) files Click-Here




Follow me on Twitter..




By: Ali Radwani