Home > Learning, Lesson, Problem, Projects/Experiments, Python > Python: Applications Main Menu

Python: Applications Main Menu



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




  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: