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)
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)
def construct_binning_tab(self): binning_options = QtWidgets.QLabel('Options') inner_items = [ BinningInfoWidget(axis_index=i, root=self) for i in range(len(self.data.dims)) ] return horizontal(binning_options, *inner_items), inner_items
def construct_coordinate_info_tab(self): needed_coordinates = ['phi', 'psi', 'alpha', 'theta', 'beta', 'chi'] inner_items = [CoordinateOffsetWidget(coordinate_name=coordinate, root=self) for coordinate in needed_coordinates] self.coordinate_widgets = dict(zip(needed_coordinates, inner_items)) for widget in inner_items: pass return horizontal(*inner_items)
def construct_sample_info_tab(self): material_choice = combo_box( sorted(SURFACE_ZONE_DEFINITIONS.keys()), name='Material Specification', ) self.material_choice_widget = material_choice self.material_choice_widget.currentTextChanged.connect(self.on_change_material) #self.photon_energy_widget = inner_items = [material_choice] return horizontal(*inner_items)
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)
def construct_general_settings_tab(self): inner_items = [] return horizontal(*inner_items)
def construct_detector_info_tab(self): inner_items = [] return horizontal(*inner_items)
def construct_kspace_tab(self): inner_items = [] return horizontal(*inner_items), inner_items
def construct_axes_tab(self): inner_items = [ AxisInfoWidget(axis_index=i, root=self) for i in range(len(self.data.dims)) ] return horizontal(*inner_items), inner_items