rpi-rgb-led-matrix/python/samples/runtext.py
Roberto Marquez 6e41022019 Python - Allow the user to specify the text to scroll via a command line flag. (#252)
* Accept the text to scroll as a command line parameter.  If not text flag is given, then the default, "Hello world", is used.
2017-01-04 22:58:23 -08:00

34 lines
1,009 B
Python
Executable file

#!/usr/bin/env python
# Display a runtext with double-buffering.
from samplebase import SampleBase
from rgbmatrix import graphics
import time
class RunText(SampleBase):
def __init__(self, *args, **kwargs):
super(RunText, self).__init__(*args, **kwargs)
def Run(self):
offscreenCanvas = self.matrix.CreateFrameCanvas()
font = graphics.Font()
font.LoadFont("../../fonts/7x13.bdf")
textColor = graphics.Color(255, 255, 0)
pos = offscreenCanvas.width
myText = self.args["text"]
while True:
offscreenCanvas.Clear()
len = graphics.DrawText(offscreenCanvas, font, pos, 10, textColor, myText)
pos -= 1
if (pos + len < 0):
pos = offscreenCanvas.width
time.sleep(0.05)
offscreenCanvas = self.matrix.SwapOnVSync(offscreenCanvas)
# Main function
if __name__ == "__main__":
parser = RunText()
if (not parser.process()):
parser.print_help()