I’d like to scroll the first line of text but leave others as static. Where should I start on this?
> from samplebase import SampleBase
> from rgbmatrix import graphics
> import time
> import requests
> from bs4 import BeautifulSoup as bs
> from datetime import datetime
> import datetime
> from time import gmtime, strftime, localtime
>
> class RunText(SampleBase):
>
> def run(self):
> while True:
> offscreen_canvas = self.matrix.CreateFrameCanvas()
> pos = offscreen_canvas.width
>
> while True:
>
> now = datetime.datetime.now() # returns a local datetime
> now_time = now.time() # strips the date component and only take the time part
>
> start = datetime.time(9,0,0)
> end = datetime.time(16,30,0)
>
> if now_time > start and now_time < end:
> now = time.strftime("%H:%M:%S", time.localtime(time.time()))
> print("Script Start: ") + str(now)
>
> res = requests.get('https://mysite.io/stocks/index.php')
> soup = bs(res.content, 'lxml')
> price = soup.select_one('#GME').text
> price1 = soup.select_one('#etsy').text
> price2 = soup.select_one('#aapl').text
> price3 = soup.select_one('#rblx').text
> font = graphics.Font()
> font.LoadFont("../../../fonts/5x7.bdf")
> textColor = graphics.Color(255, 255, 0)
> stock2 = graphics.Color(139, 0, 0)
> stock3 = graphics.Color(64, 0, 255)
> stock4 = graphics.Color(0, 255, 255)
>
> my_text = " GME: " + price
> my_text1 = "ETSY: " + price1
> my_text2 = "AAPL: " + price2
> my_text3 = "RBLX: " + price3
>
> offscreen_canvas.Clear()
> len1 = graphics.DrawText(offscreen_canvas, font, pos, 7, textColor, my_text)
> len2 = graphics.DrawText(offscreen_canvas, font, pos, 15, stock2, my_text1)
> len3 = graphics.DrawText(offscreen_canvas, font, pos, 23, stock3, my_text2)
> len4 = graphics.DrawText(offscreen_canvas, font, pos, 31, stock4, my_text3)
> pos = 1
> offscreen_canvas = self.matrix.SwapOnVSync(offscreen_canvas)
>
> else:
> res = requests.get('https://mysite')
> soup = bs(res.content, 'lxml')
> price = soup.select_one('.message').text
>
> offscreen_canvas.Clear()
> price2 = "Stock Closed"
> font = graphics.Font()
> font.LoadFont("../../../fonts/5x7.bdf")
> textColor = graphics.Color(255, 255, 0)
> textColor2 = graphics.Color(255, 0, 255)
> my_text = price
> my_text2 = price2
> my_text1 = strftime("%H:%M:%S", localtime())
>
> len1 = graphics.DrawText(offscreen_canvas, font, pos, 7, textColor2, my_text)
> len2 = graphics.DrawText(offscreen_canvas, font, pos, 19, textColor2, my_text1)
> len3 = graphics.DrawText(offscreen_canvas, font, pos, 31, textColor, my_text2)
> pos = 1
>
> offscreen_canvas = self.matrix.SwapOnVSync(offscreen_canvas)
>
> #Main function
> if __name__ == "__main__":
> run_text = RunText()
> # time.sleep(0.08)
> if (not run_text.process()):
> run_text.print_help()