Ejemplo n.º 1
0
    def __init__(self,
                 margin,
                 title,
                 message=None,
                 vendor_text=None,
                 args=None):
        self.debug_mode = args is not None and args.debug

        self.screen = SnackScreen()

        # set usual colors
        for i in colorsets["ROOT"], colorsets["ROOTTEXT"], colorsets[
                "HELPLINE"], colorsets["EMPTYSCALE"]:
            self.screen.setColor(i, "white", "blue") if not self.debug_mode else \
                self.screen.setColor(i, "brightgreen", "black")

        # remove silly default help text
        self.screen.popHelpLine()

        # write static messages
        self.screen.drawRootText((self.screen.width - len(message)) // 2, 4,
                                 message)
        self.screen.drawRootText(-len(vendor_text) - 2, -2, vendor_text)

        if self.debug_mode:
            # write some static debug information
            self.screen.drawRootText(1, 1, _("DEBUG MODE"))
            self.screen.drawRootText(
                2, 2, "screen {}×{}".format(self.screen.width,
                                            self.screen.height))
            self.screen.drawRootText(2, 3, "file {}".format(args.input))

        self.window_width = self.screen.width - margin * 2

        # assemble our progress bar
        self.scale = Scale(self.window_width, 100)
        self.spacer = Label("")
        self.taskbox = Textbox(self.window_width - 2, 1, "")
        self.messagebox = Textbox(self.window_width - 8, 1, " . . . ")

        self.grid = Grid(1, 4)
        self.grid.setField(self.scale, 0, 0)
        self.grid.setField(self.spacer, 0, 1)
        self.grid.setField(self.taskbox, 0, 2)
        self.grid.setField(self.messagebox, 0, 3)
        self.grid.place(1, 1)

        self.screen.gridWrappedWindow(self.grid, title)
        self.form = Form()
        self.form.add(self.scale)
        self.form.add(self.taskbox)
        self.form.add(self.messagebox)
        self.form.draw()
        self.screen.refresh()
Ejemplo n.º 2
0
    def __init__(self, screen, title, item_count=0):
        self.screen = screen
        self.title = title
        self.current_item = 0
        self.item_count = item_count

        g = Grid(1, 2)
        self.fnm_label = Textbox(40, 2, 'Downloading...', 0, 0)
        self.scale = Scale(40, 100)
        self.scale.set(0)
        g.setField(self.fnm_label, 0, 1)
        g.setField(self.scale, 0, 0)
        self.screen.gridWrappedWindow(g, title)
        self.f = Form()
        self.f.add(self.scale)
        self.f.add(self.fnm_label)
Ejemplo n.º 3
0
class DownloadMonitor():

    def __init__(self, screen, title, item_count=0):
        self.screen = screen
        self.title = title
        self.current_item = 0
        self.item_count = item_count

        g = Grid(1, 2)
        self.fnm_label = Textbox(40, 2, 'Downloading...', 0, 0)
        self.scale = Scale(40, 100)
        self.scale.set(0)
        g.setField(self.fnm_label, 0, 1)
        g.setField(self.scale, 0, 0)
        self.screen.gridWrappedWindow(g, title)
        self.f = Form()
        self.f.add(self.scale)
        self.f.add(self.fnm_label)

    def update_url(self, fnm):
        self.current_item = self.current_item + 1
        self.fnm_label.setText("(%s/%s): %s" % (self.current_item,
                                                self.item_count, fnm))

    def download_hook(self, count, blockSize, totalSize):
        donep = int(min(100, float(blockSize * count) / totalSize * 100))
        self.scale.set(donep)
        self.f.draw()
        self.screen.refresh()
Ejemplo n.º 4
0
class DownloadMonitor():
    def __init__(self, screen, title, item_count=0):
        self.screen = screen
        self.title = title
        self.current_item = 0
        self.item_count = item_count

        g = Grid(1, 2)
        self.fnm_label = Textbox(40, 2, 'Downloading...', 0, 0)
        self.scale = Scale(40, 100)
        self.scale.set(0)
        g.setField(self.fnm_label, 0, 1)
        g.setField(self.scale, 0, 0)
        self.screen.gridWrappedWindow(g, title)
        self.f = Form()
        self.f.add(self.scale)
        self.f.add(self.fnm_label)

    def update_url(self, fnm):
        self.current_item = self.current_item + 1
        self.fnm_label.setText("(%s/%s): %s" %
                               (self.current_item, self.item_count, fnm))

    def download_hook(self, count, blockSize, totalSize):
        donep = int(min(100, float(blockSize * count) / totalSize * 100))
        self.scale.set(donep)
        self.f.draw()
        self.screen.refresh()
Ejemplo n.º 5
0
    def __init__(self, screen, title, item_count=0):
        self.screen = screen
        self.title = title
        self.current_item = 0
        self.item_count = item_count

        g = Grid(1, 2)
        self.fnm_label = Textbox(40, 2, 'Downloading...', 0, 0)
        self.scale = Scale(40, 100)
        self.scale.set(0)
        g.setField(self.fnm_label, 0, 1)
        g.setField(self.scale, 0, 0)
        self.screen.gridWrappedWindow(g, title)
        self.f = Form()
        self.f.add(self.scale)
        self.f.add(self.fnm_label)