This example show how to detect pressing on hardware button, then shutdown Raspberry Pi by calling os.system() to send command of "sudo shutdown -h now".
http://helloraspberrypi.blogspot.com/...
En esta página del sitio puede ver el video en línea Hardware button to shutdown Raspberry Pi, using Python de Duración hora minuto segunda en buena calidad , que subió el usuario an Erik 16 marzo 2015, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 1,741 veces y le gustó 5 a los espectadores. Disfruta viendo!