示例#1
0
    def add_controls(self):
        specification = self.calculate_control_specification()

        ui = {}
        with CollectUI(ui):
            controls = tabs([
                'Controls',
                horizontal(*[
                    vertical(*[
                        vertical(label(s[0]), self.build_control_for(*s))
                        for s in pair
                    ]) for pair in group_by(2, specification)
                ])
            ], )

        def update_argument(arg_name, arg_type):
            def updater(value):
                self.current_arguments[arg_name] = arg_type(value)
                self.update_data()

            return updater

        for arg_name, arg_type, _ in specification:
            ui[f'{arg_name}-control'].subject.subscribe(
                update_argument(arg_name, arg_type))

        controls.setFixedHeight(qt_info.inches_to_px(1.4))
        self.main_layout.addWidget(controls, 1, 0)
示例#2
0
    def add_contextual_widgets(self):
        axes_tab, self.axis_info_widgets = self.construct_axes_tab()
        binning_tab, self.binning_info_widgets = self.construct_binning_tab()
        kspace_tab, self.kspace_info_widgets = self.construct_kspace_tab()

        self.tabs = tabs(
            [
                'Info',
                horizontal(),
            ],
            [
                'Axes',
                axes_tab,
            ],
            [
                'Binning',
                binning_tab,
            ],
            [
                'K-Space',
                kspace_tab,
            ],
        )
        self.tabs.setFixedHeight(qt_info.inches_to_px(1))

        self.main_layout.addLayout(self.content_layout, 0, 0)
        self.main_layout.addWidget(self.tabs, 1, 0)
示例#3
0
    def __init__(self, shortcuts=None):
        super().__init__()

        if shortcuts is None:
            shortcuts = []

        self.layout = QtWidgets.QVBoxLayout()

        keyboard_shortcuts_info = QtWidgets.QGroupBox(
            title='Keyboard Shortcuts')
        keyboard_shortcuts_layout = QtWidgets.QGridLayout()
        for i, shortcut in enumerate(shortcuts):
            keyboard_shortcuts_layout.addWidget(
                label(', '.join(PRETTY_KEYS[k] for k in shortcut.chord),
                      wordWrap=True), i, 0)
            keyboard_shortcuts_layout.addWidget(label(shortcut.label), i, 1)

        keyboard_shortcuts_info.setLayout(keyboard_shortcuts_layout)

        aboutInfo = QtWidgets.QGroupBox(title='About')
        aboutLayout = vertical(
            label(
                'QtTool is the work of Conrad Stansbury, with much inspiration '
                'and thanks to the authors of ImageTool. QtTool is distributed '
                'as part of the PyARPES data analysis framework.',
                wordWrap=True),
            label(
                'Complaints and feature requests should be directed to [email protected].',
                wordWrap=True),
        )

        from arpes.utilities.qt import qt_info  # circular dependency
        aboutInfo.setFixedHeight(qt_info.inches_to_px(1))

        self.layout.addWidget(keyboard_shortcuts_info)
        self.layout.addWidget(aboutInfo)
        self.setLayout(self.layout)

        self.setWindowTitle(f'Interactive Utility Help')
        self.setFixedSize(*qt_info.inches_to_px([2, 4]))
示例#4
0
    def add_contextual_widgets(self):
        convert_dims = ['theta', 'beta', 'phi', 'psi']
        if 'eV' not in self.data.dims:
            convert_dims += ['chi']
        if 'hv' in self.data.dims:
            convert_dims += ['hv']

        ui = {}
        with CollectUI(ui):
            controls = tabs([
                'Controls',
                horizontal(*[
                    vertical(*[
                        vertical(
                            label(p),
                            numeric_input(self.data.attrs.get(
                                f'{p}_offset', 0.),
                                          input_type=float,
                                          id=f'control-{p}'),
                        ) for p in pair
                    ]) for pair in group_by(2, convert_dims)
                ])
            ])

        def update_dimension_name(dim_name):
            def updater(value):
                self.update_offsets(dict([[dim_name, float(value)]]))

            return updater

        for dim in convert_dims:
            ui[f'control-{dim}'].subject.subscribe(update_dimension_name(dim))

        controls.setFixedHeight(qt_info.inches_to_px(1.75))

        self.main_layout.addLayout(self.content_layout, 0, 0)
        self.main_layout.addWidget(controls, 1, 0)
示例#5
0
    def start(self):
        app = QtGui.QApplication([])

        from arpes.utilities.qt import qt_info
        qt_info.init_from_app(app)

        self.window = self.WINDOW_CLS()
        self.window.resize(*qt_info.inches_to_px(self.WINDOW_SIZE))
        self.window.setWindowTitle(self.TITLE)

        cw = QtGui.QWidget()
        self.window.setCentralWidget(cw)
        self.window.app = self

        self._layout = self.layout()
        self.before_show()
        if self.DEFAULT_COLORMAP is not None:
            self.set_colormap(self.DEFAULT_COLORMAP)

        cw.setLayout(self._layout)
        self.window.show()
        self.after_show()

        QtGui.QApplication.instance().exec()