raspberry pi zero based drum machine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

sShutdown.py 948B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import FSM
  2. import utils as u
  3. import menus as m
  4. import os
  5. import pygame
  6. import sys
  7. #====================================
  8. State = type("State", (object,), {})
  9. #====================================
  10. class State(object):
  11. def __init__(self, FSM):
  12. self.FSM = FSM
  13. def Enter(self):
  14. pass
  15. def Execute(self):
  16. pass
  17. def Exit(self):
  18. pass
  19. class Shutdown(State):
  20. def __init__(self,FSM):
  21. super(Shutdown, self).__init__(FSM)
  22. def Enter(self):
  23. o = self.FSM.owner
  24. o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
  25. o.center_block("shutting down", o.h2, [0, 0, o.width,o.height - 20], o.light_grey)
  26. o.center_block("(unplug in 20s)", o.h2, [0, 10, o.width,o.height+10], o.light_grey)
  27. o.update_display(0)
  28. command = 'bash -c "sleep 5; sudo shutdown -h now"&'
  29. os.system(command)
  30. pygame.quit()
  31. sys.exit()
  32. super(Shutdown, self).Enter()
  33. def Execute(self):
  34. pass
  35. def Exit(self):
  36. pass