Matrix/API/deps/samples/menu.py
2023-11-22 16:44:11 +01:00

36 lines
1.1 KiB
Python

#!/usr/bin/env python
from ..samplebase import SampleBase
from rgbmatrix import graphics
import time, keyboard, os
class TextMenu(SampleBase):
def __init__(self, *args, **kwargs):
super(TextMenu, self).__init__(*args, **kwargs)
def run(self):
offscreen_canvas = self.matrix.CreateFrameCanvas()
font = graphics.Font()
font.LoadFont("7x13.bdf")
textColor = graphics.Color(255, 255, 255)
my_text = "hahahahahahah"
while True:
offscreen_canvas.Clear()
len = graphics.DrawText(offscreen_canvas, font, 7, 13, textColor, my_text)
if (keyboard.is_pressed('1')):
os.system('sudo /var/SnakeGame/Client/SnakeGame')
break
elif (keyboard.is_pressed('2')):
os.system('sudo /var/FlappyBird/FlappyBird')
break
time.sleep(0.05)
offscreen_canvas = self.matrix.SwapOnVSync(offscreen_canvas)
# Main function
if __name__ == "__main__":
run_text = TextMenu()
if (not run_text.process()):
run_text.print_help()