Open In App

Menu Driven Python program for opening the required software Application

Last Updated : 07 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will create a menu-driven Python program which will execute the required user tool when user will give the input as a text.

We can interact to OS through GUI (graphical user interface) and CLI (command line interface). We can also give the instructions to OS through programming language. In this program, you can instruct to OS using Python. This program gives the idea of how can we make a rule-based ChatBot.

In this program, we will use os.system() method of OS module. This method executes the command (a string) in a subshell.

Syntax: os.system(command)

Return : On Unix, the return value is the exit status of the process and on Windows, the return value is the value returned by the system shell after running command.
 

Let’s see the implementation: 

Python3




# import os library
import os
 
# infinite while loop
while True:
    print("Hello! user choose your tool")
    print("Choose your tool :-\n")
    print("-> mousepad")
    print("-> chrome")
    print("-> vlc")
    print("-> virtualbox")
    print("-> camera")
    print("-> telegram")
    print("-> firefox")
    print("-> codeblocks")
    print("-> screenshot")
    print("-> task-manager")
    print("-> libreoffice impress / presentation")
    print("-> libreoffice writer / text editor / notepad")
    print("-> libreoffice clac / spreadsheets")
    print("-> libreoffice")
    print("-> jupyter notebook\n")
    print("chat with system:-",end=' ')
     
    # take input from user
    p = input()
       
    # check conditions
    if (("do not" in p) or ("dont" in p) or ("don't" in p)):
        print("OK user\n")
         
    elif (("open" in p) or ("start" in p) or ("run" in p) or ("execute" in p) or ("launch" in p) or ("activate" in p)):
         
        if (("mousepad" in p) or ("editor" in p)):
           
            # run mention application
            os.system("mousepad")
             
        elif (("vlc" in p) or ("media player" in p)):
            os.system("vlc")
             
        elif (("virtualbox" in p) or ("virtual machine" in p) or ("virtual tool" in p)):
            os.system("virtualbox")
             
        elif (("camera" in p) or ("cheese" in p)):
            os.system("cheese")
             
        elif ("telegram" in p):
            os.system("telegram-desktop")
             
        elif ("codeblocks" in p):
            os.system("codeblocks")
             
        elif ("taskmanager" in p):
            os.system("xfce4-taskmanager")
             
        elif ("screenshot" in p):
            os.system("xfce4-screenshooter")
             
        elif (("jupyter" in p) or ("notebook" in p)):
            os.system("jupyter notebook")
             
        elif (("libreoffice impress" in p) or ("presentation tool" in p)):
            os.system("libreoffice --impress")
             
        elif (("libreoffice writer" in p) or ("text editor" in p)):
            os.system("libreoffice --writer")
 
        elif ("notepad" in p):
            os.system("notepad")
             
        elif (("libreoffice calc" in p) or ("spreadsheet" in p)):
            os.system("libreoffice --calc")
             
        elif ("libreoffice" in p):
            os.system("libreoffice")
             
        elif ("chrome" in p):
            os.system("google-chrome-stable")
             
        elif (("firefox" in p) or ("mozilla" in p)):
            os.system("firefox")
             
        else :
            print("don't support")
     
    # terminating infinite while loop
    elif (("quit" in p) or ("exit" in p) or ("stop" in p) or ("close" in p) or ("deactivate" in p) or ("terminate" in p)):
        print("Thank You!")
        break
         
    else :
        print("don't support")


Output:



Previous Article
Next Article

Similar Reads

Menu driven Python program to execute Linux commands
Linux is one of the most popular operating systems and is a common choice for developers. However, it is difficult to remember the vast range of commands that Linux supports, and hence a Python program that can run these commands easily is demonstrated below. In this article, we will deal with a Python program that can be used to run complex Linux
3 min read
Menu driven program for system control using C++
Prerequisite: Switch-case in C/C++ Problem Statement:Write a menu-driven program to control your system such as shutdown, restart, log off, manual shutdown settings, abort the shutdown, and exit, using Switch-case. Approach: The idea is to use system() in C. This function is used to invoke operating system commands from the C++ program. In this pro
3 min read
Opening multiple color windows to capture using OpenCV in Python
OpenCV is an open source computer vision library that works with many programming languages and provides a vast scope to understand the subject of computer vision.In this example we will use OpenCV to open the camera of the system and capture the video in two different colors. Approach: With the libraries available in OpenCV-Python below we will op
2 min read
Python | Morphological Operations in Image Processing (Opening) | Set-1
Morphological operations are used to extract image components that are useful in the representation and description of region shape. Morphological operations are some basic tasks dependent on the picture shape. It is typically performed on binary images. It needs two data sources, one is the input image, the second one is called structuring compone
3 min read
Python - Opening links using Selenium
Selenium is a powerful tool for controlling the web browser through the program. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python. Selenium Python bindings provide a convenient API to access Selenium WebDrivers like Firefox, Ie, Chrome
2 min read
Opening an IDE with Python
IDE (Integrated Development Environment) is a software application that provides many facilities for easily developing the software. Let us see how to open an IDE with a Python script. First of all, we have to get the path of the IDE. To do that, open the file location and then copy the target in the path. We will be using the os.startfile() method
1 min read
Python - Opening multiple tabs using Selenium
Testing is an important concept in software methodology. Software is said to be effective and efficient only if it is bug-free. Testing can be done manually and also via automation. In Python, selenium is used to do automated testing. The selenium package is available, and they are much helpful to automate web browser interaction from Python. In th
4 min read
Opening tif file using GDAL in Python
To open a raster file we need to register drivers. In python, GDALAllRegister() is implicitly called whenever gdal is imported. Importing the modules: Import the gdal and ogr modules from osgeo. C/C++ Code Opening the file: The raster dataset can be opened using gdal.open() by passing the filename and path. C/C++ Code Getting the metadata: We can f
1 min read
Mahotas - Opening Process on Image
In this article we will see how we can perform opening on the image in mahotas. Opening is a process in which first erosion operation is performed and then dilation operation is performed. It eliminates the thin protrusions of the obtained image and it is used for removing internal noise of the obtained image. In this tutorial we will use “luispedr
2 min read
PYGLET – Opening file using File Location
In this article we will see how we can open a file using file location object in PYGLET module in python. Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia etc. A window is a "heavyweight" object occupying operating system resources. Windows may appear as floating regions or can be set t
3 min read
three90RightbarBannerImg