All checks were successful
docker-image / docker (push) Successful in 10m24s
48 lines
No EOL
1.7 KiB
Python
48 lines
No EOL
1.7 KiB
Python
from datetime import timedelta
|
|
from queue import Queue, Empty
|
|
from time import sleep
|
|
|
|
from buba.bubaanimation import BubaAnimation
|
|
from buba.bubaanimator import LineLayoutColumn
|
|
from buba.bubacmd import BubaCmd
|
|
|
|
|
|
class WebQueue(BubaAnimation):
|
|
"""
|
|
|
|
"""
|
|
def __init__(self, buba, maxlen:int=3, maxrows:int=6):
|
|
"""
|
|
A queue of pages to show. If
|
|
:param buba:
|
|
:param maxlen:
|
|
"""
|
|
super().__init__(buba)
|
|
self.title = "(waiting for input)"
|
|
self.queue = Queue()
|
|
self.maxlen = maxlen
|
|
self.maxrows = maxrows
|
|
|
|
def show(self) -> None:
|
|
try:
|
|
(self.title, self.rows) = self.queue.get(block=False)
|
|
self.layout = self.default_layout
|
|
self.show_pages()
|
|
except Empty:
|
|
self.buba.text(page=0, row=0, col_start=0, col_end=119, text="\u0010\u0010 Your Data Here \u0011\u0011", align=BubaCmd.ALIGN_CENTER)
|
|
self.buba.text(page=0, row=1, col_start=0, col_end=119, text="Submit your own data to", align=BubaCmd.ALIGN_CENTER)
|
|
self.buba.text(page=0, row=2, col_start=0, col_end=119, text="this display! Go to", align=BubaCmd.ALIGN_CENTER)
|
|
self.buba.text(page=0, row=3, col_start=0, col_end=119, text="https://buba.ccchh.net", align=BubaCmd.ALIGN_CENTER)
|
|
sleep(7)
|
|
|
|
def add(self, title, rows) -> bool:
|
|
"""
|
|
Add an entry to the queue. Returns False if the maximum number of entries has been reached.
|
|
:param title:
|
|
:param rows:
|
|
:return:
|
|
"""
|
|
if self.queue.qsize() >= self.maxlen:
|
|
return False
|
|
self.queue.put((title, rows))
|
|
return True |