Exemplo n.º 1
0
    def _get_check_column(modobj, show_all_buttons):
        # Button to check
        button_check = widget.Button("Check", modobj.check)

        if modobj.parent.globalsave and show_all_buttons is False:
            return widget.Columns([button_check])

        # Button to revert to previously saved settings
        button_cancel = widget.Button("Cancel", modobj.cancel)
        # Button to apply (and check again)
        button_apply = widget.Button("Apply", modobj.apply)

        return widget.Columns(
            [button_check, button_cancel, button_apply, ('weight', 2, blank)])
Exemplo n.º 2
0
    def __init__(self, parent):
        self.name = "Quit Setup"
        self.priority = 99
        self.visible = True
        self.parent = parent
        self.screen = None
        # UI text
        saveandcontinue_button = widget.Button("Save and Continue",
                                               self.save_and_continue)
        saveandquit_button = widget.Button("Save and Quit", self.save_and_quit)
        quitwithoutsaving_button = widget.Button("Quit without saving",
                                                 self.quit_without_saving)
        self.header_content = ["Save configuration before quitting?", blank,
                               saveandcontinue_button, saveandquit_button,
                               quitwithoutsaving_button]

        self.fields = []
        self.defaults = dict()
Exemplo n.º 3
0
 def __init__(self, parent):
     self.name = "Shell Login"
     self.visible = True
     self.parent = parent
     self.screen = None
     # UI text
     text1 = "Press the button below to enter a shell login."
     login_button = widget.Button("Shell Login", self.start_shell)
     self.header_content = [text1, blank, login_button]
     self.fields = []
     self.defaults = dict()
Exemplo n.º 4
0
    def __init__(self, title, body, escape_key, previous_widget, loop):
        self.escape_key = escape_key
        self.previous_widget = previous_widget
        self.keep_open = True
        self.loop = loop

        if isinstance(body, six.string_types):
            body = urwid.Text(body)
        self.title = title
        bodybox = urwid.LineBox(urwid.Pile([body, blank,
                                widget.Button("Close", self.close)]), title)
        overlay = urwid.Overlay(urwid.Filler(bodybox), previous_widget,
                                'center', ('relative', 80), 'middle',
                                ('relative', 80))
        overlay_attrmap = urwid.AttrMap(overlay, "body")
        super(ModalDialog, self).__init__(overlay_attrmap)
Exemplo n.º 5
0
 def _create_button_widget(cls, default_data):
     button = widget.Button(default_data.get('label', ''),
                            default_data.get('callback'))
     return widget.Columns([button])
Exemplo n.º 6
0
    def screenUI(cls,
                 modobj,
                 headertext,
                 fields,
                 defaults,
                 showallbuttons=False,
                 buttons_visible=True):

        log.debug("Preparing screen UI for %s" % modobj.name)
        #Define text labels, text fields, and buttons first
        header_content = []
        for text in headertext:
            if isinstance(text, str):
                header_content.append(urwid.Text(text))
            else:
                header_content.append(text)

        edits = []
        toolbar = modobj.parent.footer
        for key in fields:
            #Example: key = hostname, label = Hostname, value = fuel-pm
            if key == "blank":
                edits.append(blank)
            elif defaults[key]["value"] == "radio":
                label = widget.TextLabel(defaults[key]["label"])
                if "choices" in defaults[key]:
                    choices_list = defaults[key]["choices"]
                else:
                    choices_list = ["Yes", "No"]
                choices = widget.ChoicesGroup(choices_list,
                                              default_value="Yes",
                                              fn=modobj.radioSelect)
                columns = widget.Columns([('weight', 2, label),
                                          ('weight', 3, choices)])
                #Attach choices rb_group so we can use it later
                columns.rb_group = choices.rb_group
                edits.append(columns)
            elif defaults[key]["value"] == "label":
                edits.append(widget.TextLabel(defaults[key]["label"]))
            else:
                ispassword = "******" in key.upper()
                caption = defaults[key]["label"]
                default = defaults[key]["value"]
                tooltip = defaults[key]["tooltip"]
                edits.append(
                    widget.TextField(key,
                                     caption,
                                     23,
                                     default,
                                     tooltip,
                                     toolbar,
                                     ispassword=ispassword))

        listbox_content = []
        listbox_content.extend(header_content)
        listbox_content.append(blank)
        listbox_content.extend(edits)
        listbox_content.append(blank)

        #Wrap buttons into Columns so it doesn't expand and look ugly
        if buttons_visible:
            #Button to check
            button_check = widget.Button("Check", modobj.check)
            #Button to revert to previously saved settings
            button_cancel = widget.Button("Cancel", modobj.cancel)
            #Button to apply (and check again)
            button_apply = widget.Button("Apply", modobj.apply)

            if modobj.parent.globalsave and showallbuttons is False:
                check_col = widget.Columns([button_check])
            else:
                check_col = widget.Columns([
                    button_check, button_cancel, button_apply,
                    ('weight', 2, blank)
                ])
            listbox_content.append(check_col)

        #Add everything into a ListBox and return it
        listwalker = widget.TabbedListWalker(listbox_content)
        screen = urwid.ListBox(listwalker)
        modobj.edits = edits
        modobj.walker = listwalker
        modobj.listbox_content = listbox_content
        return screen