Outils pour utilisateurs

Outils du site


start:raspberry:python_mpd

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
start:raspberry:python_mpd [2019/06/13 12:25] gerardadminstart:raspberry:python_mpd [2023/01/27 16:08] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +======= Python et MPD =======
 +
 +
 +[[https://github.com/Mic92/python-mpd2/| librairie python-mpd2  sur Github]]
 +
 +
 +===== Programmes de test =====
 +
 +=== menu en mode texte en python 2.7.13 ===
 +
 +<code python 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..")
 +
 +</code>
 +
 +
 +=== menu en mode texte en python 3.5.3 ===
 +
 +<code python 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..")
 +</code>
 +
 +