###############################################################################
import logging
+import time
import snack
"Selecting Cancel on any of the following screens will reboot the computer."),
buttons=(_("Start Installation"), _("Cancel"))
)
+
+
+class UnattendedWarning(Step):
+ @property
+ def enabled(self):
+ # Only enabled in unattended mode
+ return self.bricklayer.unattended
+
+ def run(self, tui):
+ seconds = 10
+
+ p = tui.progress(
+ _("Unattended Installation"),
+ _("Unattended installation is starting in %s seconds") % seconds,
+ max_value=seconds * 10,
+ )
+
+ with p:
+ for i in range(seconds * 10):
+ time.sleep(0.1)
+
+ p.update(i + 1)
return snack.ButtonChoiceWindow(self.screen, title=title, text=text,
buttons=buttons, help=help)
+
+ def progress(self, *args, **kwargs):
+ return ProgressWindow(self, *args, **kwargs)
+
+
+class ProgressWindow(object):
+ def __init__(self, tui, title, text, max_value=1, width=60, help=None):
+ self.tui = tui
+
+ # Compose the window
+ textbox = snack.TextboxReflowed(width, text)
+
+ # Add the progressbar
+ scale = snack.Scale(width, total=max_value)
+ self.update_callback = scale.set
+
+ # Create the grid
+ self.grid = snack.GridFormHelp(tui.screen, title, help, 1, 3)
+ self.grid.add(textbox, 0, 0, padding=(0, 0, 0, 1))
+ self.grid.add(scale, 0, 1, growx=1)
+
+ def __enter__(self):
+ # Render the window
+ self.grid.draw()
+ self.tui.refresh()
+
+ def __exit__(self, type, value, traceback):
+ pass
+
+ def update(self, value):
+ """
+ Updates the progressbar value
+ """
+ self.update_callback(value)
+ self.tui.refresh()