manually align todos

main
samerbam 1 year ago
parent bb2fb54c2e
commit 5323db351c

@ -63,16 +63,31 @@ class ThermalPrinter():
self.p.text("\n\n") self.p.text("\n\n")
# pass #TODO: add other greetings? # pass #TODO: add other greetings?
def print_todos(self, todos=[{"time": "1:00pm-2:00pm", "text": "Read a book"}]): def print_todos(self, todos=[{"time": "1:00pm to 2:00pm", "text": "Read a book"}]):
for x in self._parse_todos(todos): for x in self._parse_todos(todos):
# print(x) # print(x)
this_line_width = len(x[0])+len(x[1])
# self.p.charcode("cp437") # self.p.charcode("cp437")
self.p.set(align="left") self.p.set(align="left")
self.p.text(x[0]) self.p.text(x[0])
self.p.set(align="right") if this_line_width < 32:
self.p.textln(x[1]) self.p.text(" "*(32-this_line_width))
self.p.set(align="left") else:
self.p.text("\n") # self.p.text(" ")
todo_text_max_len = 32-(len(x[0])+1)
todo_text = textwrap.wrap(x[1], todo_text_max_len)
# t_text = textwrap.wrap()
for t in todo_text:
self.p.text(" "*(len(x[0])+1) )
self.p.text(t + "\n")
# self.p.set(align="right")
# self.p.textln(x[1])
# self.p.set(align="left")
# self.p.text("\n")
def print_sudoku(self): def print_sudoku(self):
self.p.close() self.p.close()

Loading…
Cancel
Save