start:raspberry:python_mpd
Table des matières
Python et MPD
Programmes de test
menu en mode texte en python 2.7.13
- menu_mpd.py
#!/usr/bin/env python # -*- coding: utf-8 -*- #title :menu_mpc.py #description :Ce programme est un menu interactif en ligne de commande #author : #date : #version :0.1 #usage :python menu_mpc.py #notes : #python_version :2.7.13 import sys, os ## Text menu in Python def print_menu(): ## Your menu design here os.system('clear') print 30 * "-" , "MENU" , 30 * "-" print "1. mpc play 1" print "2. mpc play 2" print "3. mpc play 3" print "4. mpc pause " print "5. 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-5]: ") if choice==1: print "Menu 1 has been selected" os.system('mpc play 1') elif choice==2: print "Menu 2 has been selected" os.system('mpc play 2') elif choice==3: print "Menu 3 has been selected" os.system('mpc play 3') elif choice==4: print "Menu 4 has been selected" os.system('mpc pause') elif choice==5: print "Menu 5 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-5 we print an error message raw_input("Wrong option selection. Enter any key to try again..")
menu en mode texte en python 3.5.3
- menu_mpd.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #title :menu_mpd.py #description :Ce programme est un menu interactif en ligne de commande #author : #date : #version :0.1 #usage :python menu_mpd.py #notes : #python_version :3.5.3 import sys, os ## Text menu in Python def print_menu(): ## Your menu design here os.system('clear') print (30 * "-" , "MENU" , 30 * "-") print ("1. mpc play 1") print ("2. mpc play 2") print ("3. mpc play 3") print ("4. mpc pause ") print ("5. 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-5]: ") if choice=="1": print ("Menu 1 has been selected") os.system('mpc play 1') elif choice=="2": print ("Menu 2 has been selected") os.system('mpc play 2') elif choice=="3": print ("Menu 3 has been selected") os.system('mpc play 3') elif choice=="4": print ("Menu 4 has been selected") os.system('mpc pause') elif choice=="5": print ("Menu 5 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-5 we print an error message input("Wrong option selection. Enter any key to try again..")
/home/chanteri/www/fablab37110/data/pages/start/raspberry/python_mpd.txt · Dernière modification : 2023/01/27 16:08 de 127.0.0.1