update examples

This commit is contained in:
samerbam 2023-08-23 12:46:39 -04:00
parent 873b187ca4
commit e84c539cbb

View File

@ -63,7 +63,7 @@ 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 to 2:00pm", "text": "Read a book"}]): def print_todos(self, todos=[{"time": "1:00pm to 2:00pm", "text": "Read a book"}, {"time": "2:00pm to 3:00pm", "text": "Go for a walk"}, {"time": "3:00pm to 4:00pm", "text": "Walk to school while jumping on one leg and scratching your head."},]):
self.p.set(align="left") self.p.set(align="left")
for x in self._parse_todos(todos): for x in self._parse_todos(todos):
# print(x) # print(x)
@ -71,42 +71,40 @@ class ThermalPrinter():
# # 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])
output = [] # output = []
if this_line_width < 32: if this_line_width < 32:
output.append( (" "*(32-this_line_width))+x[1] ) self.p.text( (" "*(32-this_line_width))+x[1] )
for o in output: # for s in range((32-this_line_width)):
self.p.text(o) # self.p.text(" ")
self.p.text("\n") # self.p.text("" + " "*(32-this_line_width))
else:
# # for s in range((32-this_line_width)): # self.p.text(" ")
# # self.p.text(" ") todo_text_max_len = 32-(len(x[0])+1)
# # self.p.text("" + " "*(32-this_line_width)) todo_text = textwrap.wrap(x[1], todo_text_max_len)
# else: # t_text = textwrap.wrap()
# # 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()
# output.append(" " + todo_text[0]) self.p.text(" " + todo_text[0])
# for t in todo_text[1:]: for t in todo_text[1:]:
# # self.p.text("" + " "*(len(x[0])+1) ) # self.p.text("" + " "*(len(x[0])+1) )
# # for s in range((len(x[0])+1)): # for s in range((len(x[0])+1)):
# # self.p.text(" ") # self.p.text(" ")
# output.append( (" "*(32-(len(x[0])+1)))+t ) output.append( (" "*(32-(len(x[0])+1)))+t )
# # self.p.text(t + "\n") # self.p.text(t + "\n")
# print(output) print(output)
# for l in output: for l in output:
# print(l) print(l)
# self.p.text(l) self.p.text(l + "\n")
self.p.text("\n")
self.p.set(align="left") self.p.set(align="left")
self.p.text("\n")
# self.p.set(align="right") # self.p.set(align="right")
# self.p.textln(x[1]) # self.p.textln(x[1])