Use custom function to render a string message onto a pad

This commit is contained in:
Yohann D'ANELLO
2020-11-26 12:35:52 +01:00
parent b6f5fe9364
commit 8b187ec2b3
5 changed files with 27 additions and 23 deletions

View File

@ -20,13 +20,13 @@ class MenuDisplay(Display):
# Menu values are printed in pad
self.pad = self.newpad(self.trueheight, self.truewidth + 2)
for i in range(self.trueheight):
self.pad.addstr(i, 0, " " + self.values[i])
self.addstr(self.pad, i, 0, " " + self.values[i])
def update_pad(self) -> None:
for i in range(self.trueheight):
self.pad.addstr(i, 0, " " + self.values[i])
self.addstr(self.pad, i, 0, " " + self.values[i])
# set a marker on the selected line
self.pad.addstr(self.menu.position, 0, ">")
self.addstr(self.pad, self.menu.position, 0, ">")
def display(self) -> None:
cornery = 0 if self.height - 2 >= self.menu.position - 1 \
@ -79,8 +79,8 @@ class MainMenuDisplay(Display):
def display(self) -> None:
for i in range(len(self.title)):
self.pad.addstr(4 + i, max(self.width // 2
- len(self.title[0]) // 2 - 1, 0), self.title[i])
self.addstr(self.pad, 4 + i, max(self.width // 2
- len(self.title[0]) // 2 - 1, 0), self.title[i])
self.pad.refresh(0, 0, self.y, self.x, self.height + self.y - 1,
self.width + self.x - 1)
menuwidth = min(self.menudisplay.preferred_width, self.width)