Exemplo n.º 1
0
def create_select_checkbox(screen,
                           title,
                           text,
                           items,
                           buttons=(('Cancel', 'cancel', 'F12'), 'Ok'),
                           width=40,
                           scroll=0,
                           height=-1,
                           help=None):
    """Helper class for displaying a windows with a checkbox list.
    On exit, list of selected items is returned"""
    if (height == -1):
        height = len(items)
    if len(items) > height:
        scroll = 1
    bb = ButtonBar(screen, buttons)
    t = TextboxReflowed(width, text)
    cb = CheckboxTree(height, scroll=scroll)
    count = 0
    for count, item in enumerate(items):
        if isinstance(item, types.TupleType):
            (text, key, selected) = item
        else:
            text = item
            key = count
            selected = 0

        cb.append(text, key, selected)

    g = GridFormHelp(screen, title, help, 1, 3)
    g.add(t, 0, 0)
    g.add(cb, 0, 1, padding=(0, 1, 0, 1))
    g.add(bb, 0, 2, growx=1)
    rc = g.runOnce()
    return (bb.buttonPressed(rc), cb.getSelection())
Exemplo n.º 2
0
 def create_ui(self):
     """ Creates/Draws the UI """
     self.button_bar = ButtonBar(self.screen, ((_("Cancel"), "cancel"),
                                               (_("Install"), "ok")),
                                 compact=True)
     self.textview_changes = Textbox(72, 8, "Changelog", True, True)
     self.checkbox_tree_updates = CheckboxTree(height=8, width=72, scroll=1)
     self.checkbox_tree_updates.setCallback(self.checkbox_changed)
     self.layout = GridForm(self.screen, "Updates", 1, 5)
     self.layout.add(self.checkbox_tree_updates, 0, 0)
     # empty line to make it look less crowded
     self.layout.add(Textbox(60, 1, " ", False, False), 0, 1)
     self.layout.add(self.textview_changes, 0, 2)
     # empty line to make it look less crowded
     self.layout.add(Textbox(60, 1, " ", False, False), 0, 3)
     self.layout.add(self.button_bar, 0, 4)
     # FIXME: better progress than the current suspend/resume screen thing
     self.screen.suspend()
Exemplo n.º 3
0
def ExtCheckboxWindow(screen, title, text, items,
                      buttons=('Ok', 'Cancel'), width=50, height=8):

    g = GridForm(screen, title, 1, 3)
    g.add(Textbox(width, 2, text), 0, 0)

    scroll = 0
    if len(items) > height:
        scroll = 1

    ct = CheckboxTree(height, scroll, width)
    if len(items) > 0:
        for i in items:
            ct.append(i, i, items[i])
        g.add(ct, 0, 1)

    bb = ButtonBar(screen, buttons, compact=1)
    g.add(bb, 0, 2, (0, 2, 0, 0), growx=1, growy=1)

    result = g.runOnce()
    return bb.buttonPressed(result), ct.getSelection()
    def __init__(self, datadir):
        self.screen = SnackScreen()
        # FIXME: self.screen.finish() clears the screen (and all messages)
        #        there too
        #atexit.register(self.restoreScreen)
        self.button_bar = ButtonBar(self.screen, ((_("Cancel"), "cancel"),
                                                  (_("Install"), "ok")),
                                    compact=True)
        self.textview_changes = Textbox(72, 8, _("Changelog"), True, True)
        self.checkbox_tree_updates = CheckboxTree(height=8, width=72, scroll=1)
        self.checkbox_tree_updates.setCallback(self.checkbox_changed)
        self.layout = GridForm(self.screen, _("Updates"), 1, 5)
        self.layout.add(self.checkbox_tree_updates, 0, 0)
        # empty line to make it look less crowded
        self.layout.add(Textbox(60, 1, " ", False, False), 0, 1)
        self.layout.add(self.textview_changes, 0, 2)
        # empty line to make it look less crowded
        self.layout.add(Textbox(60, 1, " ", False, False), 0, 3)
        self.layout.add(self.button_bar, 0, 4)
        # FIXME: better progress than the current suspend/resume screen thing
        self.screen.suspend()
        if not self.DEBUG:
            apt_pkg.pkgsystem_lock()
        self.openCache()
        print(_("Building Updates List"))
        self.fillstore()
        if self.list.distUpgradeWouldDelete > 0:
            print(
                _("""
A normal upgrade can not be calculated, please run:
  sudo apt-get dist-upgrade


This can be caused by:
 * A previous upgrade which didn't complete
 * Problems with some of the installed software
 * Unofficial software packages not provided by Ubuntu
 * Normal changes of a pre-release version of Ubuntu"""))
            sys.exit(1)
        self.screen.resume()
Exemplo n.º 5
0
def select_packages():
    global sellist
    screen = SnackScreen()
    ct = CheckboxTree(height=20, scroll=1)

    for idx, key in enumerate(packages):
        ct.append(key)
        for val in packages[key]:
            ct.addItem(val, (idx, snackArgs["append"]))
            ct.setEntryValue(val)

    bb = ButtonBar(screen, (("Next", "next"), ("Cancel", "cancel")))
    g = GridForm(screen, "Packages", 1, 4)

    g.add(ct, 0, 2)
    g.add(bb, 0, 3, growx=1)

    result = g.runOnce()
    screen.finish()

    # format selected packages list for zypper  and print(result)
    sellist = (str(ct.getSelection()).replace("[",
                                              "").replace("]", "").replace(
                                                  "'", "").replace(",", ""))
    # to confirm Selected Packages
    screen = SnackScreen()
    bb = ButtonBar(screen, (("Next", "next"), ("Cancel", "cancel")))
    tb = Textbox(
        80, 10,
        "the packages selected to install are \n \n" + str(sellist.split(" ")),
        1, 1)
    g = GridForm(screen, "Selected Packages", 1, 4)

    g.add(tb, 0, 2)
    g.add(bb, 0, 3, growx=1)

    result = g.runOnce()
    screen.finish()
    return bb.buttonPressed(result)