Added a title to dialogs

This commit is contained in:
Manuel Cortez 2017-02-27 16:29:48 -06:00
parent 0158772670
commit d86b3e18c4

View File

@ -30,22 +30,26 @@ enter selects default button or displays error if not one
self.controls[self._controlIndex].onFocus() self.controls[self._controlIndex].onFocus()
return i return i
def __init__(self, screen = None, base = None, y = 0, x = 0, controls = [], can_go_back=True): def __init__(self, screen = None, base = None, y = 0, x = 0, title="", controls = [], can_go_back=True):
self.base = base self.base = base
self.screen = screen self.screen = screen
self.y, self.x = y, x self.y, self.x = y, x
self._controls = controls self._controls = controls
self.controls = [] self.controls = []
self.can_go_back = can_go_back self.can_go_back = can_go_back
self.title = title
self.initialDraw() self.initialDraw()
self.draw() self.draw()
def initialDraw(self): def initialDraw(self):
for i in range(0, len(self._controls)): for i in range(1, len(self._controls)+1):
co = self._controls[i] co = self._controls[i]
c = co[0](screen=self.screen, base=self.base, y=i, can_go_back=self.can_go_back, **co[1]) c = co[0](screen=self.screen, base=self.base, y=i, can_go_back=self.can_go_back, **co[1])
self.controls.append(c) self.controls.append(c)
self.controlIndex = 0 self.controlIndex = 0
self.screen.move(self.y, 0)
self.screen.clrtoeol()
self.screen.addstr(self.y, 0, title)
def draw(self): def draw(self):
for i in self.controls: for i in self.controls: