X-Git-Url: https://code.grnet.gr/git/snf-image-creator/blobdiff_plain/7bf9352417c6b43eea0b875b91e081cfc5a71c5e..9e4b4de20ef2c2c23a96fb1ac5d474fa2370695e:/image_creator/output/dialog.py diff --git a/image_creator/output/dialog.py b/image_creator/output/dialog.py index 65ef69f..0cde2a7 100644 --- a/image_creator/output/dialog.py +++ b/image_creator/output/dialog.py @@ -103,10 +103,33 @@ class GaugeOutput(Output): self.goto(self.output.index + 1) -class InitializationOutput(GaugeOutput): - def __init__(self, dialog): - dialog.setBackgroundTitle('snf-image-creator') - super(InitializationOutput, self).__init__(dialog, "Initialization", - "Initializing...") +class InfoBoxOutput(Output): + def __init__(self, dialog, title, msg='', height=20, width=70): + self.d = dialog + self.title = title + self.msg = msg + self.width = width + self.height = height + self.d.infobox(self.msg, title=self.title) + + def output(self, msg='', new_line=True): + nl = '\n' if new_line else '' + self.msg += "%s%s" % (msg, nl) + # If output is long, only output the last lines that fit in the box + lines = self.msg.splitlines() + h = self.height + display = self.msg if len(lines) <= h else "\n".join(lines[-h:]) + self.d.infobox(display, title=self.title, height=self.height, + width=self.width) + + def success(self, result, new_line=True): + self.output(result, new_line) + + def warn(self, msg, new_line=True): + self.output("Warning: %s" % msg, new_line) + + def finalize(self): + self.d.msgbox(self.msg, title=self.title, height=(self.height + 2), + width=self.width) # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :