예제 #1
0
파일: Bindings.py 프로젝트: icbicket/nionui
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:

    hello1_line_edit = u.create_line_edit(placeholder_text="Enter Text",
                                          on_editing_finished="hello1_updated")
    hello1_label = u.create_label(name="hello1_label", text="Hello World One")
    hello1 = u.create_column(hello1_label, hello1_line_edit)

    hello2_line_edit = u.create_line_edit(placeholder_text="Enter Text",
                                          text="@binding(hello2_text)")
    hello2_label = u.create_label(name="hello2_label",
                                  text="@binding(hello2_text)")
    hello2 = u.create_column(hello2_label, hello2_line_edit)

    hello3_line_edit = u.create_line_edit(placeholder_text="Enter Text",
                                          text="@binding(hello3_model.value)")
    hello3_label = u.create_label(text="@binding(hello3_model.value)")
    hello3 = u.create_column(hello3_label, hello3_line_edit)

    hello4_line_edit = u.create_line_edit(placeholder_text="Enter Text",
                                          text="@binding(hello3_model.value)")
    hello4_label = u.create_label(text="@binding(hello4_text)")
    hello4 = u.create_column(hello4_label, hello4_line_edit)

    hellos = u.create_column(hello1, hello2, hello3, hello4, spacing=12)

    return hellos
예제 #2
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    title_field = u.create_line_edit(text="@binding(title_model.value)")
    add_button = u.create_push_button(text="Add", on_clicked="add_mode")
    modes_menu = u.create_combo_box(name="modes_menu", items_ref="@binding(mode_titles_model.value)", current_index="@binding(model.mode_index)")
    modes_stack = u.create_stack(items="model.modes", item_component_id="mode", current_index="@binding(model.mode_index)")
    modes_group = u.create_group(modes_stack)
    return u.create_column(title_field, add_button, modes_menu, modes_group, spacing=8, margin=12)
    def __create_ui_view(self,
                         ui: Declarative.DeclarativeUI,
                         title: str = None,
                         file_ext: str = 'hdf5',
                         params: dict = None,
                         **kwargs) -> dict:
        ui_objects = []
        for i, param in enumerate(params):
            converter = ''
            if param.get('converter'):
                converter = ', converter=' + param['converter']
            if (param['type'] == 'text_box'):
                ui_objects.append(ui.create_label(text=param['text']))
                ui_objects.append(
                    ui.create_line_edit(
                        text=f'@binding(params_{i}{converter})'))
            elif (param['type'] == 'check_box'):
                ui_objects.append(
                    ui.create_check_box(
                        text=param['text'],
                        checked=f'@binding(params_{i}{converter})'))

        ui_objects.append(
            ui.create_row(
                ui.create_push_button(text='Load', on_clicked='on_load'),
                ui.create_stretch()))
        content = ui.create_column(*ui_objects,
                                   ui.create_stretch(),
                                   spacing=8,
                                   margin=4)

        return ui.create_modeless_dialog(content,
                                         title=title + ' - ' +
                                         file_ext.title(),
                                         margin=4)
예제 #4
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    field_label = u.create_label(text="Favorite Color?")
    field_line_edit = u.create_line_edit(placeholder_text="Color",
                                         name="color_line_edit",
                                         on_editing_finished="color_updated",
                                         on_return_pressed="return_pressed",
                                         on_key_pressed="key_pressed")
    field_line_edit2 = u.create_line_edit(text="@binding(model.value)")
    return u.create_column(
        u.create_row(field_label, field_line_edit, spacing=8),
        u.create_row(u.create_label(text="Another Color?"),
                     field_line_edit2,
                     u.create_stretch(),
                     spacing=8),
        u.create_stretch(),
        spacing=8,
    )
예제 #5
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    hello3_line_edit = u.create_line_edit(
        placeholder_text="Enter Text",
        text="@binding(hello3_model.value, converter=hello3_converter)")
    hello3_label = u.create_label(
        text="@binding(hello3_model.value, converter=hello3_converter)")
    hello3 = u.create_column(hello3_label, hello3_line_edit, spacing=8)
    return hello3
예제 #6
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    title_field = u.create_line_edit(text="@binding(title_model.value)")
    add_button = u.create_push_button(text="Add", on_clicked="add")
    sections_column = u.create_column(items="sections",
                                      item_component_id="section",
                                      spacing=8)
    return u.create_column(title_field,
                           add_button,
                           sections_column,
                           spacing=8,
                           margin=12)
예제 #7
0
    def __create_ui_view(self, ui: Declarative.DeclarativeUI) -> dict:
        open_button = ui.create_push_button(text='Open',
                                            on_clicked='open_button_clicked')
        file_path_field = ui.create_line_edit(name='file_path_field')
        open_row = ui.create_row(file_path_field,
                                 open_button,
                                 ui.create_stretch(),
                                 spacing=8,
                                 margin=4)
        content = ui.create_column(open_row,
                                   ui.create_stretch(),
                                   spacing=8,
                                   margin=4)

        return content