Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display options - screen
#1
Hi all,

I need help to create a script that will open a terminal screen with command options.

Example.
1) execute script.py

This will open in the same terminal something like this

########Open Termianl#####################
# selection your options #
##########################################
Press A for ping
Press B for SSH

When I press in my keyboard A it will call a script call ping.

Thanks for any help.
Reply
#2
What have you tried?
Post your attempt in Python code tags, along with questions and/or errors you get in error tags.
Reply
#3
Sorry for my bad post, im working with what I need is to work with Menus. I have this point, but the what I looking is when I press 1 this will run a script but when the script finishes I want it to go back to the main menu and not to stay in the linux prompt.
## Text menu in Python

def print_menu():       ## Your menu design here
    print 30 * "-" , "CLI SYSTEM" , 30 * "-"
    print "1. Test SSH Connection (check ssh to all hosts)"
    print "2. Backup (backup all device in host /tmp)"
    print "3. Startup Provisioning"
    print "4. Update Provisioning"
    print "5. Troublshooting"
    print "6. Exit"
    print 67 * "-"
  
loop=True      
  
while loop:          ## While loop which will keep going until loop = False
    print_menu()    ## Displays menu
    choice = input("Enter your choice [1-6]: ")
     
    if choice==1:     
        print "Menu 1 has been selected"
        ## You can add your code or functions here
    elif choice==2:
        print "Menu 2 has been selected"
        ## You can add your code or functions here
    elif choice==3:
        print "Menu 3 has been selected"
        ## You can add your code or functions here
    elif choice==4:
        print "Menu 4 has been selected"
        ## You can add your code or functions here
    elif choice==5:
	print "Menu 5 has been selected"
        ## You can add your code or function here
    elif choice==6:
        print "Menu 6 has been selected"
        ## You can add your code or functions here
        loop=False # This will make the while loop to end as not value of loop is set to False
    else:
        # Any integer inputs other than values 1-6 we print an error message
        raw_input("Wrong option selection. Enter any key to try again..")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to display <IPython.core.display.HTML object>? pythopen 3 46,013 May-06-2023, 08:14 AM
Last Post: pramod08728
  Performance options for sys.stdout.writelines dgrunwal 11 3,160 Aug-23-2022, 10:32 PM
Last Post: Pedroski55
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,248 Nov-11-2020, 02:23 AM
Last Post: MelfoyGray
  Can argparse support undocumented options? pjfarley3 3 2,227 Aug-14-2020, 06:13 AM
Last Post: pjfarley3
  Help with options raiden 1 1,942 Aug-30-2019, 12:57 AM
Last Post: scidam
  wn = turtle.screen() AttributeError: module 'turtle' has no attribute 'screen' Shadower 1 6,192 Feb-06-2019, 01:25 AM
Last Post: woooee
  Full Screen Display daven2411 1 2,984 Oct-24-2018, 04:24 PM
Last Post: Larz60+
  Options for retaining persistent data? hunnimonstr 4 2,972 Feb-14-2018, 07:49 PM
Last Post: hunnimonstr
  Return options Kongurinn 1 3,303 Sep-28-2017, 03:02 PM
Last Post: ichabod801
  Python Launch Options Flexico 6 7,098 Dec-07-2016, 06:58 AM
Last Post: Flexico

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020