Пример #1
0
def construct_ui(u: Declarative.DeclarativeUI) -> Declarative.UIDescription:
    all_cb = u.create_check_box(text="Enable All",
                                name="all_cb",
                                tristate=True,
                                check_state="partial",
                                on_check_state_changed="check_state_changed")
    gain_cb = u.create_check_box(text="Gain Normalize",
                                 name="gain_cb",
                                 checked="gain_enabled",
                                 on_checked_changed="checked")
    dark_cb = u.create_check_box(text="Dark Subtract",
                                 name="dark_cb",
                                 on_checked_changed="checked")
    extra_cb = u.create_check_box(text="Extra",
                                  checked="@binding(extra_model.value)")
    extra_extra_cb = u.create_check_box(text="Extra2", enabled=False)
    label = u.create_label(text="Label",
                           visible="@binding(extra_model.value)",
                           tool_tip="A tool tip.")
    cb_group = u.create_column(gain_cb,
                               dark_cb,
                               spacing=8,
                               enabled="@binding(extra_model.value)")
    cb_row = u.create_row(u.create_spacing(12), cb_group)
    all_group = u.create_column(all_cb,
                                cb_row,
                                extra_cb,
                                extra_extra_cb,
                                label,
                                spacing=8)
    return all_group
    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)