start:raspberry:python_mpd
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
start:raspberry:python_mpd [2019/06/13 12:08] – créée gerardadmin | start:raspberry:python_mpd [2023/01/27 16:08] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ======= Python et MPD ======= | ||
+ | |||
+ | |||
+ | [[https:// | ||
+ | |||
+ | |||
+ | ===== Programmes de test ===== | ||
+ | |||
+ | === menu en mode texte en python 2.7.13 === | ||
+ | |||
+ | <code python menu_mpd.py> | ||
+ | # | ||
+ | # -*- coding: utf-8 -*- | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | #date : | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | import sys, os | ||
+ | |||
+ | ## Text menu in Python | ||
+ | |||
+ | def print_menu(): | ||
+ | os.system(' | ||
+ | print 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() | ||
+ | choice = input(" | ||
+ | |||
+ | if choice==1: | ||
+ | print "Menu 1 has been selected" | ||
+ | os.system(' | ||
+ | elif choice==2: | ||
+ | print "Menu 2 has been selected" | ||
+ | os.system(' | ||
+ | elif choice==3: | ||
+ | print "Menu 3 has been selected" | ||
+ | os.system(' | ||
+ | elif choice==4: | ||
+ | print "Menu 4 has been selected" | ||
+ | os.system(' | ||
+ | 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(" | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | === menu en mode texte en python 3.5.3 === | ||
+ | |||
+ | <code python menu_mpd.py> | ||
+ | # | ||
+ | # -*- coding: utf-8 -*- | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | #date : | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | import sys, os | ||
+ | |||
+ | ## Text menu in Python | ||
+ | |||
+ | def print_menu(): | ||
+ | os.system(' | ||
+ | print (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() | ||
+ | choice = input(" | ||
+ | |||
+ | if choice==" | ||
+ | print ("Menu 1 has been selected" | ||
+ | os.system(' | ||
+ | elif choice==" | ||
+ | print ("Menu 2 has been selected" | ||
+ | os.system(' | ||
+ | elif choice==" | ||
+ | print ("Menu 3 has been selected" | ||
+ | os.system(' | ||
+ | elif choice==" | ||
+ | print ("Menu 4 has been selected" | ||
+ | os.system(' | ||
+ | elif choice==" | ||
+ | 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(" | ||
+ | </ | ||
+ | |||
+ | |||
/home/chanteri/www/fablab37110/data/pages/start/raspberry/python_mpd.txt · Dernière modification : 2023/01/27 16:08 de 127.0.0.1