Ejemplo n.º 1
0
def construct_ui(ui: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    text_only_button = ui.create_push_button(text="Change Button Icon",
                                             on_clicked="click")
    icon_only_button = ui.create_push_button(icon="@binding(icon2)")
    text_and_icon_button = ui.create_push_button(text="Text",
                                                 icon="@binding(icon1)")
    image_button = ui.create_image(image="@binding(image_model.value)",
                                   height=16,
                                   width=16,
                                   on_clicked="image_click")

    hellos = ui.create_column(ui.create_row(text_only_button,
                                            ui.create_stretch()),
                              ui.create_row(icon_only_button,
                                            ui.create_stretch()),
                              ui.create_row(text_and_icon_button,
                                            ui.create_stretch()),
                              ui.create_row(
                                  ui.create_label(text="Image (click me):"),
                                  image_button,
                                  ui.create_stretch(),
                                  spacing=8),
                              ui.create_stretch(),
                              spacing=12)

    return hellos
    def __create_ui_view(self,
                         ui: Declarative.DeclarativeUI,
                         title: str = None,
                         **kwargs) -> dict:
        elabftw_text_field = ui.create_text_edit(editable=False,
                                                 text='elabftw_data',
                                                 width=400,
                                                 height=500)
        elabftw_tab = ui.create_tab(label='Elabftw',
                                    content=elabftw_text_field)

        nion_text_field = ui.create_text_edit(editable=False,
                                              text='nion_data',
                                              width=400,
                                              height=500)
        nion_tab = ui.create_tab(label='Nion Swift', content=nion_text_field)
        tabs = ui.create_tabs(elabftw_tab, nion_tab)

        overwrite_button = ui.create_push_button(
            text='Overwrite', on_clicked='on_overwrite_clicked')
        merge_button = ui.create_push_button(text='Merge',
                                             on_clicked='on_merge_clicked')
        buttons_row = ui.create_row(overwrite_button,
                                    merge_button,
                                    spacing=8,
                                    margin=4)
        content = ui.create_column(tabs,
                                   buttons_row,
                                   ui.create_stretch(),
                                   spacing=8,
                                   margin=4)
        return ui.create_modeless_dialog(content, title=title, margin=4)
    def __create_ui_view(self,
                         ui: Declarative.DeclarativeUI,
                         title: str = None,
                         **kwargs) -> dict:
        nion_text_field = ui.create_text_edit(editable=False,
                                              text='nion_text',
                                              name='nion_text_field',
                                              width=200,
                                              height=100)
        elabftw_text_field = ui.create_text_edit(editable=False,
                                                 text='elabftw_text',
                                                 name='elabftw_text_field',
                                                 width=200,
                                                 height=100)
        text_row = ui.create_row(nion_text_field,
                                 elabftw_text_field,
                                 spacing=8,
                                 margin=4)

        nion_button = ui.create_push_button(
            text='Keep Local', on_clicked='on_nion_button_clicked')
        elabftw_button = ui.create_push_button(
            text='Keep Elabftw', on_clicked='on_elabftw_button_clicked')
        button_row = ui.create_row(nion_button,
                                   elabftw_button,
                                   spacing=8,
                                   margin=4)

        content = ui.create_column(text_row,
                                   button_row,
                                   ui.create_stretch(),
                                   spacing=8,
                                   margin=4)

        return ui.create_modeless_dialog(content, title=title, margin=4)
Ejemplo n.º 4
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)
Ejemplo n.º 6
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    slider = u.create_slider(value="@binding(slider_value_model.value)")
    progress_bar = u.create_progress_bar(
        value="@binding(slider_value_model.value)")
    label = u.create_label(text="@binding(slider_value_model.value)")
    button = u.create_push_button(text="Reset to 50", on_clicked="reset")
    return u.create_column(progress_bar, slider, label, button, spacing=8)
Ejemplo n.º 7
0
def construct_ui(ui: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    text_only_button = ui.create_push_button(text="Change Button Icon",
                                             on_clicked="click")
    icon_only_button = ui.create_push_button(icon="@binding(icon2)")
    text_and_icon_button = ui.create_push_button(text="Text",
                                                 icon="@binding(icon1)")

    hellos = ui.create_column(ui.create_row(text_only_button,
                                            ui.create_stretch()),
                              ui.create_row(icon_only_button,
                                            ui.create_stretch()),
                              ui.create_row(text_and_icon_button,
                                            ui.create_stretch()),
                              ui.create_stretch(),
                              spacing=12)

    return hellos
Ejemplo n.º 8
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    slider = u.create_slider(value="@binding(slider_value_model.value)")
    slider2 = u.create_slider(name="slider2",
                              value="vv",
                              on_value_changed="value_changed",
                              on_slider_moved="slider_moved")
    label = u.create_label(text="@binding(slider_value_model.value)")
    button = u.create_push_button(text="Reset to 50", on_clicked="reset")
    return u.create_column(slider, slider2, label, button, spacing=8)
Ejemplo n.º 9
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    label = u.create_label(text="@binding(slider_value_model.value)")
    button = u.create_push_button(text="Reset to 50", on_clicked="reset")
    content = u.create_column(label, button, spacing=8)
    left = u.create_label(text="LEFT")
    right = u.create_label(text="RIGHT")
    group_row = u.create_row(left, u.create_stretch(), right, spacing=8)
    status_bar = u.create_group(group_row)
    return u.create_column(content, u.create_stretch(), status_bar, spacing=8)
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    radio0 = u.create_radio_button(
        text="One", value=1, group_value="@binding(radio_button_value.value)")
    radio1 = u.create_radio_button(
        text="Two", value=2, group_value="@binding(radio_button_value.value)")
    radio2 = u.create_radio_button(
        text="Three",
        value=3,
        group_value="@binding(radio_button_value.value)")
    label = u.create_label(text="@binding(radio_button_value.value)")
    button = u.create_push_button(text="Reset", on_clicked="reset_clicked")
    return u.create_column(radio0, radio1, radio2, label, button, spacing=8)
Ejemplo n.º 12
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
Ejemplo n.º 13
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    def create_tab_content(tab_label: str, text: str, check_text: str,
                           button_text: str) -> Declarative.UIDescription:
        label = u.create_label(text=text)
        check_box = u.create_check_box(text=check_text)
        button = u.create_push_button(text=button_text)
        return u.create_tab(
            tab_label,
            u.create_column(label, check_box, button, spacing=8, margin=4))

    tab0 = create_tab_content("First", "ONE", "Check 1", "Push ONE")
    tab1 = create_tab_content("Second", "TWO", "Check 2", "Push TWO")
    tab2 = create_tab_content("Third", "THREE", "Check 3", "Push THREE")
    tabs = u.create_tabs(tab0,
                         tab1,
                         tab2,
                         current_index="@binding(tab_index_model.value)")
    button = u.create_push_button(text="3", on_clicked="switch3")
    return u.create_column(tabs, button)
Ejemplo n.º 14
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:

    cb1 = u.create_combo_box(
        name="cb1",
        items=["Red", "Green", "Blue"],
        on_current_index_changed="cb1_current_index_changed")
    cb2 = u.create_combo_box(
        items=["Sheriff", "Astronaut", "Scientist"],
        current_index="@binding(cb2_current_index_model.value)")
    cb3 = u.create_combo_box(
        items_ref="numbers",
        current_index="@binding(cb2_current_index_model.value)")
    cb4 = u.create_combo_box(
        items_ref="@binding(numeros.value)",
        current_index="@binding(cb2_current_index_model.value)")
    button = u.create_push_button(text="Change Items",
                                  on_clicked="change_items")

    cb_group = u.create_column(cb1, cb2, cb3, cb4, button, spacing=12)

    return cb_group
Ejemplo n.º 15
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    field_width = u.create_component_instance("field", {"label": "Width", "value": "20"}, name="width_field", on_value_changed="width_changed")
    field_height = u.create_component_instance("field", {"label": "Height", "value": "30"}, name="height_field", on_value_changed="height_changed")
    reset_button = u.create_push_button(text="Reset", on_clicked="reset")
    return u.create_column(field_width, field_height, reset_button, spacing=8)