From 5323db351c37da5e73a02de9a05a2a1fb58f0eca Mon Sep 17 00:00:00 2001 From: samerbam Date: Wed, 23 Aug 2023 10:13:34 -0400 Subject: [PATCH] manually align todos --- application/thermal_print.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/application/thermal_print.py b/application/thermal_print.py index 8844c41..cb67b6b 100644 --- a/application/thermal_print.py +++ b/application/thermal_print.py @@ -63,16 +63,31 @@ class ThermalPrinter(): self.p.text("\n\n") # 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): # print(x) + this_line_width = len(x[0])+len(x[1]) + # self.p.charcode("cp437") self.p.set(align="left") self.p.text(x[0]) - self.p.set(align="right") - self.p.textln(x[1]) - self.p.set(align="left") - self.p.text("\n") + if this_line_width < 32: + self.p.text(" "*(32-this_line_width)) + else: + # 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): self.p.close()