Пример #1
0
    def __init__(self, form, id_document):
        super().__init__(form.view, legend_text='New investor information', css_id='id_document_section')
        self.enable_refresh()
        self.use_layout(FormLayout())

        self.layout.add_input(SelectInput(form, id_document.fields.document_type,  refresh_widget=self))
        document_type = id_document.document_type
        if document_type == 'passport':
            self.layout.add_input(SelectInput(form, id_document.fields.country))
            self.layout.add_input(TextInput(form, id_document.fields.passport_number))
        elif document_type == 'id_card':
            self.layout.add_input(TextInput(form, id_document.fields.id_card_number))
        else:
            raise Exception(id_document.document_type)
Пример #2
0
    def __init__(self, view, event_channel_name):
        super().__init__(view, event_channel_name)
        self.use_layout(FormLayout())
        model_object = ModelObject()
        self.layout.add_input(
            TextInput(self, model_object.fields.text_input_field))
        self.layout.add_input(
            CheckboxInput(self, model_object.fields.boolean_field))
        self.layout.add_input(
            PasswordInput(self, model_object.fields.password_field))
        self.layout.add_input(
            TextArea(self,
                     model_object.fields.text_area_field,
                     rows=5,
                     columns=60))
        self.layout.add_input(
            SelectInput(self, model_object.fields.choice_field))
        self.layout.add_input(
            SelectInput(self, model_object.fields.multi_choice_field))
        self.layout.add_input(
            CheckboxInput(self,
                          model_object.fields.another_multi_choice_field))
        self.layout.add_input(
            RadioButtonSelectInput(self,
                                   model_object.fields.radio_choice_field,
                                   contents_layout=ChoicesLayout(inline=True)))
        self.layout.add_input(
            TextInput(self, model_object.fields.fuzzy_date_field, fuzzy=True))
        self.layout.add_input(TextInput(
            self,
            model_object.fields.text_input_without_label,
            placeholder=True),
                              hide_label=True)
        self.layout.add_input(
            CueInput(TextInput(self, model_object.fields.cue_field),
                     P(view, text='This is a cue')))
        self.define_event_handler(model_object.events.do_something)

        self.add_child(
            ButtonInput(self,
                        model_object.events.do_something,
                        style='primary'))
Пример #3
0
    def __init__(self, view):
        super().__init__(view, 'chartform')
        self.factor = 1
        self.use_layout(FormLayout())

        select_input = self.layout.add_input(
            SelectInput(
                self,
                self.fields.factor))  # Creating the input, sets self.factor
        chart = self.create_chart(self.factor)
        select_input.set_refresh_widget(chart.contents)
Пример #4
0
    def __init__(self, view, address_book):
        super().__init__(view, 'add_collaborator_form')

        grouped_inputs = self.add_child(FieldSet(view, legend_text='Add a collaborator'))
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(SelectInput(self, address_book.fields.chosen_collaborator))

        rights_inputs = grouped_inputs.add_child(FieldSet(view, legend_text='Rights'))
        rights_inputs.use_layout(FormLayout())
        rights_inputs.layout.add_input(CheckboxInput(self, address_book.fields.may_edit_address))
        rights_inputs.layout.add_input(CheckboxInput(self, address_book.fields.may_add_address))

        grouped_inputs.add_child(Button(self, address_book.events.add_collaborator.with_arguments(address_book_id=address_book.id), style='primary'))
Пример #5
0
    def add_inputs(self, controls):
        operand_a_input = TextInput(self,
                                    self.calculator.fields.operand_a,
                                    refresh_widget=self)
        controls.layout.add_input(operand_a_input, hide_label=True)

        operator_input = SelectInput(self,
                                     self.calculator.fields.operator,
                                     refresh_widget=self)
        controls.layout.add_input(operator_input, hide_label=True)

        operand_b_input = TextInput(self,
                                    self.calculator.fields.operand_b,
                                    refresh_widget=self)
        controls.layout.add_input(operand_b_input, hide_label=True)
Пример #6
0
    def __init__(self, view):
        super().__init__(view, 'my_cool_form')

        calculator = Calculator.for_current_session()
        self.enable_refresh(on_refresh=calculator.events.input_changed)

        grouped_inputs = self.add_child(
            FieldSet(view, legend_text='Calculator'))
        grouped_inputs.use_layout(InlineFormLayout())

        grouped_inputs.layout.add_input(
            TextInput(self, calculator.fields.operandA,
                      refresh_widget=self)).use_layout(
                          MarginLayout(2, right=True))
        grouped_inputs.layout.add_input(
            SelectInput(self, calculator.fields.operandB, refresh_widget=self))

        self.add_child(P(self.view, text='Sum: %s' % calculator.sum))