self.max_value = max_value
+ # Make textbox
+ self.textbox = snack.TextboxReflowed(self.width, self.text)
+
# Make progressbar
self.scale = snack.Scale(self.width, self.max_value or 0)
grid = snack.GridFormHelp(self.tui.screen, self.title, self.help, 1, 2)
# Add the textbox
- textbox = snack.TextboxReflowed(self.width, self.text)
- grid.add(textbox, 0, 0)
+ grid.add(self.textbox, 0, 0)
# Optionally add the progress bar
if self.max_value:
self.tui.refresh()
+ # Return the callbacks
+ return ProgressWindowCallbacks(self)
+
def __exit__(self, type, value, traceback):
self.tui.screen.popWindow()
- def update(self, value):
+
+class ProgressWindowCallbacks(object):
+ def __init__(self, window):
+ self.window = window
+
+ def progress(self, value):
"""
Updates the progressbar value
"""
- if self.max_value:
- self.scale.set(value)
- self.tui.refresh()
+ if self.window.max_value:
+ self.window.scale.set(value)
+ self.window.tui.refresh()
+
+ def status(self, text):
+ """
+ Updates the text in the textbox
+ """
+ self.window.textbox.setText(text)
+ self.window.tui.refresh()
+
+ @property
+ def callbacks(self):
+ """
+ Returns callbacks that can be passed to Pakfire
+ """
+ return {
+ "status_callback" : self.status,
+ "progress_callback" : self.progress,
+ }
class PasswordWindow(ButtonsWindow):