Beispiel #1
0
 def build_widget(self):
     rows = [
         Text("Select primary/external network, "
              "and datastore for this deployment:"),
         HR(),
         Columns([
             ('weight', 0.5, Text('primary network', align="right")),
             Color.string_input(
                 self.vsphere_config['primary-network'],
                 focus_map='string_input focus')
         ], dividechars=1),
         HR(),
         Columns([
             ('weight', 0.5, Text('external network (optional)',
                                  align="right")),
             Color.string_input(
                 self.vsphere_config['external-network'],
                 focus_map='string_input focus')
         ], dividechars=1),
         HR(),
         Columns([
             ('weight', 0.5, Text('datastore', align="right")),
             Color.string_input(
                 self.vsphere_config['datastore'],
                 focus_map='string_input focus')
         ], dividechars=1)
     ]
     self.pile = Pile(rows)
     return self.pile
Beispiel #2
0
 def build_widget(self):
     return [
         Columns([('fixed', 16, Text('network bridge', align="right")),
                  Color.string_input(self.lxd_config['network'],
                                     focus_map='string_input focus')],
                 dividechars=1),
         HR(),
         Columns([('fixed', 16, Text('storage pool', align="right")),
                  Color.string_input(self.lxd_config['storage-pool'],
                                     focus_map='string_input focus')],
                 dividechars=1),
     ]
Beispiel #3
0
    def _build_fields(self):
        self.email = Edit()
        self.password = Edit(mask='*')
        self.twofa = Edit()
        # can't use IntEdit because it precludes leading zeros
        self.twofa.valid_char = lambda ch: ch in '0123456789'

        return Pile([
            Color.string_input(self.email),
            Padding.line_break(""),
            Color.string_input(self.password),
            Padding.line_break(""),
            Color.string_input(self.twofa)
        ])
Beispiel #4
0
    def build_widgets(self):
        desc_text = Text(["\n", strip_solo_dots(self.description)])

        self.reset_button = PlainButton("Reset to Default", self.do_reset)
        if self.optype == OptionType.BOOLEAN:
            self.control = CheckBox('', state=bool(self.current_value))
            self.wrapped_control = self.control
        elif self.optype == OptionType.INT:
            self.control = IntEdit(default=self.current_value)
            self.wrapped_control = Color.string_input(
                self.control, focus_map='string_input focus')
        elif self.optype == OptionType.STRING:
            edit_text = self.current_value or ""
            self.control = StringEditor(edit_text=edit_text)
            self.wrapped_control = Color.string_input(
                self.control, focus_map='string_input focus')
        elif self.optype == OptionType.FLOAT:
            edit_text = str(self.current_value)
            self.control = StringEditor(edit_text=edit_text)
            self.wrapped_control = Color.string_input(
                self.control, focus_map='string_input focus')
        else:
            raise Exception("Unknown option type")

        self.control_columns = Columns(
            [
                ('pack', Text("{}:".format(self.name), align='right')),
                (80, self.wrapped_control)
            ],
            dividechars=1
        )

        if self.optype in [OptionType.STRING, OptionType.FLOAT]:
            connect_signal(self.control._edit, 'change',
                           self.handle_value_changed)
        else:
            connect_signal(self.control, 'change',
                           self.handle_value_changed)

        button_grid = GridFlow([
            Color.button_secondary(self.reset_button,
                                   focus_map='button_secondary focus')],
                               36, 1, 0, 'right')

        return Pile([Padding.line_break(""),
                     Padding.left(self.control_columns, left=1),
                     Padding.left(desc_text, left=2),
                     button_grid])
Beispiel #5
0
    def build_widget(self):
        self.step_pile = pile = Pile([
            Columns([
                ('fixed', 3, self.icon),
                self.description,
            ],
                    dividechars=1),
            Padding.line_break(""),
            Padding.push_4(self.output),
        ])

        if utils.is_linux() and self.model.needs_sudo:
            pile.contents.append((Padding.line_break(""), pile.options()))
            label = 'This step requires sudo.'
            if not self.app.sudo_pass:
                label += '  Enter sudo password, if needed:'
                self.sudo_input = PasswordEditor()
            columns = [
                ('weight', 0.5, Padding.left(Text(('body', label)), left=5)),
            ]
            if self.sudo_input:
                columns.append(
                    ('weight', 1,
                     Color.string_input(self.sudo_input,
                                        focus_map='string_input focus')))
            pile.contents.append((Columns(columns,
                                          dividechars=3), pile.options()))
Beispiel #6
0
    def generate_additional_input(self):
        """ Generates additional input fields, useful for doing it after
        a previous step is run
        """
        self.set_description(self.model.description, 'body')
        self.icon.set_text((
            'pending_icon',
            self.icon.get_text()[0]
        ))
        for i in self.additional_input:
            self.app.log.debug(i)
            self.step_pile.contents.append((Padding.line_break(""),
                                            self.step_pile.options()))
            column_input = [
                ('weight', 0.5, Padding.left(i['label'], left=5))
            ]
            if i['input']:
                column_input.append(
                    ('weight', 1, Color.string_input(
                        i['input'],
                        focus_map='string_input focus')))
            self.step_pile.contents.append(
                (Columns(column_input, dividechars=3),
                 self.step_pile.options()))

        self.button = submit_btn(label="Run", on_press=self.submit)
        self.step_pile.contents.append(
            (Padding.right_20(
                Color.button_primary(self.button,
                                     focus_map='button_primary focus')),
             self.step_pile.options()))
        self.step_pile.contents.append((HR(), self.step_pile.options()))
        self.step_pile.focus_position = self.current_button_index
Beispiel #7
0
    def _gen_credentials(self):
        total_items = [
            Text("Enter your {} credentials:".format(
                app.current_cloud.upper()))
        ]
        total_items += [HR()]
        for field in self.schema.fields():
            label = field.key
            if field.label is not None:
                label = field.label

            col = Columns([('weight', 0.5, Text(label, align='right')),
                           Color.string_input(field.widget,
                                              focus_map='string_input focus')],
                          dividechars=1)
            total_items.append(col)
            total_items.append(
                Columns([('weight', 0.5, Text("")),
                         Color.error_major(field.error)],
                        dividechars=1))
            total_items.append(Padding.line_break(""))
        if len(self.regions) > 0:
            total_items.append(
                Columns([
                    ('weight', 0.5, Text("Select a Cloud Region",
                                         align='right')), self.regions_w
                ],
                        dividechars=1))
        return total_items
Beispiel #8
0
 def add_row(label, field):
     rows.extend([
         Columns([('fixed', 23, Text(label)),
                  Color.string_input(field,
                                     focus_map='string_input focus')]),
         Padding.line_break(""),
     ])
Beispiel #9
0
    def generate_additional_input(self):
        """ Generates additional input fields, useful for doing it after
        a previous step is run
        """
        self.set_description(self.model.description, 'body')
        self.icon.set_text(('pending_icon', self.icon.get_text()[0]))
        for i in self.additional_input:
            self.app.log.debug(i)
            self.step_pile.contents.append(
                (Padding.line_break(""), self.step_pile.options()))
            column_input = [('weight', 0.5, Padding.left(i['label'], left=5))]
            if i['input']:
                column_input.append(
                    ('weight', 1,
                     Color.string_input(i['input'],
                                        focus_map='string_input focus')))
            self.step_pile.contents.append(
                (Columns(column_input,
                         dividechars=3), self.step_pile.options()))

            self.button = submit_btn(on_press=self.submit)
            self.step_pile.contents.append((Padding.right_20(
                Color.button_primary(self.button,
                                     focus_map='button_primary focus')),
                                            self.step_pile.options()))
            self.step_pile.contents.append((HR(), self.step_pile.options()))
        self.step_pile.focus_position = self.current_button_index
Beispiel #10
0
    def generate_additional_input(self):
        """ Generates additional input fields, useful for doing it after
        a previous step is run
        """
        self.set_description(self.model.description, 'body')
        self.icon.set_text(('pending_icon', self.icon.get_text()[0]))
        if utils.is_linux() and self.model.needs_sudo:
            self.step_pile.contents.append(
                (Padding.line_break(""), self.step_pile.options()))
            can_sudo = utils.can_sudo()
            label = 'This step requires sudo.'
            if not can_sudo:
                label += '  Please enter sudo password:'******'weight', 0.5, Padding.left(Text(('body', label)), left=5)),
            ]
            if not can_sudo:
                self.sudo_input = PasswordEditor()
                columns.append(
                    ('weight', 1,
                     Color.string_input(self.sudo_input,
                                        focus_map='string_input focus')))
            self.step_pile.contents.append(
                (Columns(columns, dividechars=3), self.step_pile.options()))

        for i in self.additional_input:
            self.app.log.debug(i)
            self.step_pile.contents.append(
                (Padding.line_break(""), self.step_pile.options()))
            column_input = [('weight', 0.5, Padding.left(i['label'], left=5))]
            if i['input']:
                column_input.append(
                    ('weight', 1,
                     Color.string_input(i['input'],
                                        focus_map='string_input focus')))
            self.step_pile.contents.append(
                (Columns(column_input,
                         dividechars=3), self.step_pile.options()))

        self.button = submit_btn(label="Run", on_press=self.submit)
        self.step_pile.contents.append(
            (Padding.line_break(""), self.step_pile.options()))
        self.step_pile.contents.append((Text(""), self.step_pile.options()))
        self.step_pile.contents.append((HR(), self.step_pile.options()))
        self.show_button()
        self.step_pile.focus_position = self.current_button_index
Beispiel #11
0
 def build_widget(self):
     rows = [
         Text("Select a network bridge and storage pool "
              "for this deployment:"),
         HR(),
         Columns([('weight', 0.5, Text('network bridge', align="right")),
                  Color.string_input(self.lxd_config['network'],
                                     focus_map='string_input focus')],
                 dividechars=1),
         HR(),
         Columns([('weight', 0.5, Text('storage pool', align="right")),
                  Color.string_input(self.lxd_config['storage-pool'],
                                     focus_map='string_input focus')],
                 dividechars=1),
     ]
     self.pile = Pile(rows)
     return self.pile
Beispiel #12
0
    def build_widgets(self):
        desc_text = Text(["\n", strip_solo_dots(self.description)])

        self.reset_button = PlainButton("Reset to Default", self.do_reset)
        if self.optype == OptionType.BOOLEAN:
            self.control = CheckBox('', state=bool(self.current_value))
            self.wrapped_control = self.control
        elif self.optype == OptionType.INT:
            self.control = IntEdit(default=self.current_value)
            self.wrapped_control = Color.string_input(
                self.control, focus_map='string_input focus')
        elif self.optype == OptionType.STRING:
            edit_text = self.current_value or ""
            self.control = StringEditor(edit_text=edit_text)
            self.wrapped_control = Color.string_input(
                self.control, focus_map='string_input focus')
        elif self.optype == OptionType.FLOAT:
            edit_text = str(self.current_value)
            self.control = StringEditor(edit_text=edit_text)
            self.wrapped_control = Color.string_input(
                self.control, focus_map='string_input focus')
        else:
            raise Exception("Unknown option type")

        self.control_columns = Columns(
            [('pack', Text("{}:".format(self.name), align='right')),
             (80, self.wrapped_control)],
            dividechars=1)

        if self.optype in [OptionType.STRING, OptionType.FLOAT]:
            connect_signal(self.control._edit, 'change',
                           self.handle_value_changed)
        else:
            connect_signal(self.control, 'change', self.handle_value_changed)

        button_grid = GridFlow([
            Color.button_secondary(self.reset_button,
                                   focus_map='button_secondary focus')
        ], 36, 1, 0, 'right')

        return Pile([
            Padding.line_break(""),
            Padding.left(self.control_columns, left=1),
            Padding.left(desc_text, left=2), button_grid
        ])
Beispiel #13
0
    def __init__(self, app, steps, cb=None):
        """ init

        Arguments:
        cb: process step callback
        """
        self.app = app
        self.table = Table()
        self.cb = cb

        self.steps_queue = steps
        for step_model in self.steps_queue:
            step_widget = self.add_step_widget(step_model)
            self.table.addColumns(
                step_model.path,
                [
                    ('fixed', 3, step_widget['icon']),
                    step_widget['description'],
                ]
            )
            # Need to still prompt for the user to submit
            # even though no questions are asked
            if len(step_widget['additional_input']) == 0:
                self.table.addRow(
                    Padding.right_20(
                        Color.button_primary(
                            submit_btn(on_press=self.submit,
                                       user_data=(step_model, step_widget)),
                            focus_map='button_primary focus')), False)
            for i in step_widget['additional_input']:
                self.table.addRow(Padding.line_break(""), False)
                self.table.addColumns(
                    step_model.path,
                    [
                        ('weight', 0.5, Padding.left(i['label'], left=5)),
                        ('weight', 1, Color.string_input(
                            i['input'],
                            focus_map='string_input focus')),
                    ], force=True
                )
                self.table.addRow(
                    Padding.right_20(
                        Color.button_primary(
                            submit_btn(
                                on_press=self.submit,
                                user_data=(step_model, step_widget)),
                            focus_map='button_primary focus')), False)
                self.table.addRow(Padding.line_break(""), False)

        self.table.addRow(Padding.center_20(
                        Color.button_primary(
                            done_btn(on_press=self.done, label="View Summary"),
                            focus_map='button_primary focus')))
        super().__init__(Padding.center_80(self.table.render()))
Beispiel #14
0
 def build_widget(self):
     return [
         Text("Select primary/external network, "
              "and datastore for this deployment:"),
         HR(),
         Columns([(29, Text('Primary Network', align="right")),
                  Color.string_input(self.vsphere_config['primary-network'],
                                     focus_map='string_input focus')],
                 dividechars=1),
         HR(),
         Columns(
             [(29, Text('External Network (optional)', align="right")),
              Color.string_input(self.vsphere_config['external-network'],
                                 focus_map='string_input focus')],
             dividechars=1),
         HR(),
         Columns([(29, Text('Datastore', align="right")),
                  Color.string_input(self.vsphere_config['datastore'],
                                     focus_map='string_input focus')],
                 dividechars=1)
     ]
    def build_widgets(self):
        self.description_w = Text("Description Loading…")
        self.readme_w = Text("README Loading…")
        self.scale_edit = IntegerEditor(default=self.service.num_units)
        connect_signal(self.scale_edit._edit, 'change',
                       self.handle_scale_changed)
        self.skip_rest_button = PlainButton(
            "Deploy all {} Remaining Applications with Bundle Defaults".format(
                self.n_remaining),
            self.do_skip_rest
        )
        col = Columns(
            [
                (6, Text('Units:', align='right')),
                (15,
                 Color.string_input(self.scale_edit,
                                    focus_map='string_input focus'))
            ], dividechars=1
        )

        if self.n_remaining == 0:
            buttons = [Padding.right_50(Color.button_primary(
                PlainButton("Deploy and Continue",
                            self.do_deploy),
                focus_map='button_primary focus'))]
        else:
            buttons = [
                Padding.right_50(Color.button_primary(
                    PlainButton(
                        "Deploy and Configure Next Application",
                        self.do_deploy),
                    focus_map='button_primary focus')),
                Padding.right_50(
                    Color.button_secondary(
                        self.skip_rest_button,
                        focus_map='button_secondary focus'))]

        ws = [Text("{} of {}: {}".format(self.idx+1, self.n_total,
                                         self.service.service_name.upper())),
              Padding.center(HR()),
              Padding.center(self.description_w, left=2),
              Padding.line_break(""),
              Padding.center(self.readme_w, left=2),
              Padding.center(HR())]

        if not self.service.subordinate:
            ws.append(Padding.left(col, left=1))

        ws.append(Padding.line_break(""))
        ws += buttons

        self.pile = Pile(ws)
        return Padding.center_90(Filler(self.pile, valign="top"))
    def build_widgets(self):
        self.description_w = Text("Description Loading…")
        self.readme_w = Text("README Loading…")
        self.scale_edit = IntegerEditor(default=self.service.num_units)
        connect_signal(self.scale_edit._edit, 'change',
                       self.handle_scale_changed)
        self.skip_rest_button = PlainButton(
            "Deploy all {} Remaining Applications with Bundle Defaults".format(
                self.n_remaining), self.do_skip_rest)
        col = Columns([(6, Text('Units:', align='right')),
                       (15,
                        Color.string_input(self.scale_edit,
                                           focus_map='string_input focus'))],
                      dividechars=1)

        if self.n_remaining == 0:
            buttons = [
                Padding.right_50(
                    Color.button_primary(PlainButton("Deploy and Continue",
                                                     self.do_deploy),
                                         focus_map='button_primary focus'))
            ]
        else:
            buttons = [
                Padding.right_50(
                    Color.button_primary(PlainButton(
                        "Deploy and Configure Next Application",
                        self.do_deploy),
                                         focus_map='button_primary focus')),
                Padding.right_50(
                    Color.button_secondary(self.skip_rest_button,
                                           focus_map='button_secondary focus'))
            ]

        ws = [
            Text("{} of {}: {}".format(self.idx + 1, self.n_total,
                                       self.service.service_name.upper())),
            Padding.center(HR()),
            Padding.center(self.description_w, left=2),
            Padding.line_break(""),
            Padding.center(self.readme_w, left=2),
            Padding.center(HR())
        ]

        if not self.service.subordinate:
            ws.append(Padding.left(col, left=1))

        ws.append(Padding.line_break(""))
        ws += buttons

        self.pile = Pile(ws)
        return Padding.center_90(Filler(self.pile, valign="top"))
Beispiel #17
0
    def _build_form_fields(self):
        """ Generates widgets for additional input fields.
        """
        form_fields = []
        self.fields = []
        for i in self.model.additional_input:
            label = i['label']
            key = i['key']
            if i['type'] not in self.INPUT_TYPES:
                self.app.log.error('Invalid input type "{}" in step {}; '
                                   'should be one of: {}'.format(
                                       i['type'], self.model.title,
                                       ', '.join(self.INPUT_TYPES.keys())))
                field = None
            else:
                input_type = self.INPUT_TYPES[i['type']]
                value = self.app.steps_data[self.model.name][key]
                if issubclass(input_type, RadioList):
                    select_w = input_type([choice for choice in i['choices']])
                    select_w.select_option(i['default'])
                    field = StepField(key, label, select_w, i['type'])
                else:
                    field = StepField(key, label, input_type(default=value),
                                      i['type'])
                self.fields.append(field)
            column_input = [('weight', 0.5,
                             Padding.left(field.label_widget, left=5))]
            if field:
                column_input.append(
                    ('weight', 1,
                     Color.string_input(field.input,
                                        focus_map='string_input focus')))

            form_fields.extend([
                Padding.line_break(""),
                Columns(column_input, dividechars=3),
            ])

        self.button = SubmitButton(label="Next", on_press=self.submit)
        self.requires_input = self.sudo_input or self.fields
        form_fields.extend([
            Padding.line_break(""),
            self.button if self.requires_input else Text(""),
            HR(),
        ])

        if self.requires_input:
            self.complete.clear()
        else:
            self.complete.set()

        return form_fields
Beispiel #18
0
    def build_fields(self):
        """ Generates widgets for additional input fields.
        """
        pile_opts = self.step_pile.options()
        self.fields = []
        for i in self.model.additional_input:
            label = i['label']
            key = i['key']
            if i['type'] not in self.INPUT_TYPES:
                self.app.log.error('Invalid input type "{}" in step {}; '
                                   'should be one of: {}'.format(
                                       i['type'], self.model.title,
                                       ', '.join(self.INPUT_TYPES.keys())))
                field = None
            else:
                input_type = self.INPUT_TYPES[i['type']]
                value = self.app.steps_data[self.model.name][key]
                if input_type == SelectorHorizontal:
                    select_w = input_type([choice for choice in i['choices']])
                    select_w.set_default(i['default'], True)
                    field = StepField(key, label, select_w, i['type'])
                else:
                    field = StepField(key, label, input_type(default=value),
                                      i['type'])
                self.fields.append(field)
            column_input = [('weight', 0.5,
                             Padding.left(field.label_widget, left=5))]
            if field:
                column_input.append(
                    ('weight', 1,
                     Color.string_input(field.input,
                                        focus_map='string_input focus')))

            self.step_pile.contents.extend([
                (Padding.line_break(""), pile_opts),
                (Columns(column_input, dividechars=3), pile_opts),
            ])

        self.button = submit_btn(label="Next", on_press=self.submit)
        self.step_pile.contents.extend([
            (Padding.line_break(""), pile_opts),
            (Text(""), pile_opts),
            (HR(), pile_opts),
        ])

        if self.sudo_input or self.fields:
            self.show_button()
            self.step_pile.focus_position = 4
        else:
            self.complete.set()
Beispiel #19
0
 def build_widget(self):
     total_items = []
     label_width = max(
         len(f.label or f.key) for f in app.provider.form.fields()) + 2
     for field in app.provider.form.fields():
         label = field.label or field.key
         total_items.extend([
             Columns([(label_width, Text(label, align='right')),
                      Color.string_input(field.widget,
                                         focus_map='string_input focus')],
                     dividechars=1),
             Columns([(label_width, Text("")),
                      Color.error_major(field.error)],
                     dividechars=1),
             Padding.line_break(""),
         ])
     return total_items
Beispiel #20
0
    def _gen_credentials(self):
        total_items = [
            Text("Enter your {} credentials:".format(
                app.current_cloud.upper()))
        ]
        total_items += [HR()]
        for field in self.input_items['fields']:
            label = field['key']
            if field['label'] is not None:
                label = field['label']

            col = Columns([('weight', 0.5, Text(label, align='right')),
                           Color.string_input(field['input'],
                                              focus_map='string_input focus')],
                          dividechars=1)
            total_items.append(col)
            total_items.append(Padding.line_break(""))
        return total_items
Beispiel #21
0
 def build_inputs(self):
     # FIXME: Skip this for now as we're shelling out to
     # dpkg-reconfigure lxd :\ yay and such.
     items = []
     for k in self.input_items.keys():
         widget, help_text = self.input_items[k]
         if isinstance(widget.value, bool):
             widget.set_default('Yes', True)
         if k.startswith('_'):
             # Don't treat 'private' keys as input
             continue
         col = Columns(
             [('weight', 0.5, Text(help_text, align='right')),
              Color.string_input(widget, focus_map='string_input focus')],
             dividechars=1)
         items.append(col)
         items.append(Padding.line_break(""))
     return Pile(items)
Beispiel #22
0
 def build_inputs(self):
     items = []
     for k in self.input_items.keys():
         display = k
         if k.startswith('_'):
             # Don't treat 'private' keys as input
             continue
         if k.startswith('@'):
             # Strip public, not storable attribute
             display = k[1:]
         col = Columns(
             [
                 ('weight', 0.5, Text(display, align='right')),
                 Color.string_input(self.input_items[k],
                                    focus_map='string_input focus')
             ], dividechars=1
         )
         items.append(col)
         items.append(Padding.line_break(""))
     return Pile(items)
Beispiel #23
0
 def build_inputs(self):
     # FIXME: Skip this for now as we're shelling out to
     # dpkg-reconfigure lxd :\ yay and such.
     items = []
     for k in self.input_items.keys():
         widget, help_text = self.input_items[k]
         if isinstance(widget.value, bool):
             widget.set_default('Yes', True)
         if k.startswith('_'):
             # Don't treat 'private' keys as input
             continue
         col = Columns(
             [
                 ('weight', 0.5, Text(help_text, align='right')),
                 Color.string_input(widget,
                                    focus_map='string_input focus')
             ], dividechars=1
         )
         items.append(col)
         items.append(Padding.line_break(""))
     return Pile(items)
Beispiel #24
0
    def _build_sudo_field(self):
        if not utils.is_linux() or not self.model.needs_sudo:
            return []

        rows = []
        if not self.app.sudo_pass:
            self.sudo_input = PasswordEditor()
        self.clear_sudo_error()
        columns = [
            ('weight', 0.5, Padding.left(self.sudo_label, left=5)),
        ]
        if self.sudo_input:
            columns.append(
                ('weight', 1,
                 Filler(Color.string_input(self.sudo_input,
                                           focus_map='string_input focus'),
                        valign='bottom')))
        rows.extend([
            Padding.line_break(""),
            Columns(columns, dividechars=3, box_columns=[1]),
        ])
        return rows
Beispiel #25
0
 def _build_widget(self):
     total_items = [
         Text("Enter your {} credentials:".format(self.cloud.upper()))
     ]
     total_items += [HR()]
     for k in self.input_items.keys():
         display = k
         if k.startswith('_'):
             # Don't treat 'private' keys as input
             continue
         if k.startswith('@'):
             # Strip public, not storable attribute
             display = k[1:]
         col = Columns([('weight', 0.5, Text(display, align='right')),
                        Color.string_input(self.input_items[k],
                                           focus_map='string_input focus')],
                       dividechars=1)
         total_items.append(col)
         total_items.append(Padding.line_break(""))
     total_items.append(Text(""))
     self.pile = Pile(total_items)
     return Padding.center_60(Filler(self.pile, valign="top"))
Beispiel #26
0
    def build_widget(self):
        total_items = []
        if self.header:
            total_items.extend([
                Text(self.header),
                HR(),
            ])
        for field in self.schema.fields():
            label = field.key
            if field.label is not None:
                label = field.label

            col = Columns([('weight', 0.5, Text(label, align='right')),
                           Color.string_input(field.widget,
                                              focus_map='string_input focus')],
                          dividechars=1)
            total_items.append(col)
            total_items.append(
                Columns([('weight', 0.5, Text("")),
                         Color.error_major(field.error)],
                        dividechars=1))
            total_items.append(Padding.line_break(""))
        return total_items
Beispiel #27
0
 def _build_widget(self):
     total_items = [Text(
         "Enter your {} credentials:".format(self.cloud.upper()))]
     total_items += [HR()]
     for k in self.input_items.keys():
         display = k
         if k.startswith('_'):
             # Don't treat 'private' keys as input
             continue
         if k.startswith('@'):
             # Strip public, not storable attribute
             display = k[1:]
         col = Columns(
             [
                 ('weight', 0.5, Text(display, align='right')),
                 Color.string_input(self.input_items[k],
                                    focus_map='string_input focus')
             ], dividechars=1
         )
         total_items.append(col)
         total_items.append(Padding.line_break(""))
     total_items.append(Text(""))
     self.pile = Pile(total_items)
     return Padding.center_60(Filler(self.pile, valign="top"))