def layout_timing_group(self): self.timing_ui = {} with CollectUI(self.timing_ui): timing_group = group(label("N Points: {}".format(0), id="timing-label"), label="Timing") return timing_group
def layout(self): jog_controls = [] live_plots = [] if self.live_line_plottable: widget = pg.PlotWidget( axisItems={"bottom": TimeAxisItem(orientation="bottom")}) self.live_plot = widget.plot() widget.setTitle(self.id) live_plots = [widget] if self.live_image_plottable: logger.warning( "Not live plotting image: not currently supported. " "Complain at Conrad if this sufficiently upsets you.") write_controls = [] if not self.axis.readonly: write_controls = [ horizontal( "Write", line_edit("", id=f"{self.id}-edit"), button("Set", id=f"{self.id}-set", class_name="primary"), ), ] if self.joggable: jog_controls = [ horizontal( "Jog", button("<<-", id=f"{self.id}-jog_neg_fast"), button("<-", id=f"{self.id}-jog_neg_slow"), button("->", id=f"{self.id}-jog_pos_slow"), button("->>", id=f"{self.id}-jog_pos_fast"), ), horizontal( "Slow Jog Amt. (Fast = 5x)", line_edit("0", id=f"{self.id}-jog_speed"), ), ] return vertical( group( "Driver", horizontal( "Read", label("Last Value", id=f"{self.id}-last_value"), button("Read", id=f"{self.id}-read", class_name="primary"), ), *write_controls, *jog_controls, *live_plots, ), )
def layout(self): ui = {} with CollectUI(ui): vertical( label("Test"), horizontal( layout_dataclass(TestDataclass, prefix="a"), layout_dataclass(TestDataclass, prefix="b", submit="Submit"), ), tabs( ["A", label("A")], ["B", label("B")], ), button("Echo", id="echo"), widget=self, ) bind_dataclass(self.a, "a", ui) bind_dataclass(self.b, "b", ui) ui["echo"].subscribe(self.echo)
def layout(self): ui = {} with CollectUI(ui): vertical( label("Test"), table_view(id="table"), button("Add Row", id="submit"), widget=self, ) tx_add = ui["submit"].subject.pipe( ops.map(lambda x: Transaction.add(new_value=pr.v(1, 2, 3))) ) table_pattern = RxTablePattern(columns=["A", "B", "C"], add_row=tx_add) table_pattern.values_with_history.subscribe(print) model = table_pattern.bind_to_model() model.bind_to_ui(ui["table"])
def layout(self): ui = {} with CollectUI(ui): vertical( label("Test"), scroll_area(list_view(id="items")), text_edit(id="edit"), button("Submit", id="submit"), widget=self, ) add_note = submit("submit", ["edit"], ui).pipe(ops.map(lambda n: n["edit"])) tx_add = add_note.pipe(ops.map(lambda v: Transaction.add(new_value=v))) notes_pattern = RxListPattern(add=tx_add) notes_pattern.values_with_history.subscribe(print) model = notes_pattern.bind_to_model() model.bind_to_ui(ui["items"])
def layout(self): experiment = self.experiment self.experiment.ui = self scan_methods = experiment.scan_methods ui = {} with CollectUI(ui): vertical( horizontal( button("Start", id="start", class_name="primary"), button("Add to Q", id="enqueue", class_name="primary"), button("Pause", id="pause"), button("Stop", id="stop", class_name="warning"), label("Waiting...", id="status-box"), self.layout_timing_group(), min_height=120, class_name="experiment_header", spacing=20, content_margin=(20, 0, 0, 0), ), tabs(*[ [ "Scan", splitter( vertical( horizontal( "Use", combo_box( [s.__name__ for s in scan_methods], id="selected_scan_method", ), content_margin=20, class_name="which_scan", ), tabs( [ "Scans", tabs( *self.layout_scan_methods( scan_methods), ), ], *self.extra_panels, ), class_name="scans", ), vertical("[Data Streams]", id="dynamic-layout"), direction=splitter.Horizontal, size=[ self.LEFT_PANEL_SIZE, self.SIZE[0] - self.LEFT_PANEL_SIZE, ], ), ], ["Queue", self.layout_queue_content()], ]), widget=self, ) for scan_method in scan_methods: name = scan_method.__name__ bind_dataclass(experiment.scan_configurations[name], prefix=name, ui=ui) ui["start"].subject.subscribe(self.start) ui["enqueue"].subject.subscribe(self.add_to_queue) ui["stop"].subject.subscribe(self.stop) ui["pause"].subject.subscribe(self.pause) ui["selected_scan_method"].subject.on_next(experiment.use_method) ui["selected_scan_method"].subject.subscribe(self.set_scan_method) self.ui = ui self.dynamic_state_mounted = False
def widget_for_scan_config(self, item, index): def remove_this_item(*_): self.experiment.scan_deque.remove(item) self.update_queue_ui() def copy_this_item(*_): self.experiment.scan_deque.insert(index, copy(item)) self.update_queue_ui() def move_item_up(*_): if index > 0: self.experiment.scan_deque.remove(item) self.experiment.scan_deque.insert(index - 1, item) self.update_queue_ui() def move_item_down(*_): if index + 1 < len(self.experiment.scan_deque): self.experiment.scan_deque.remove(item) self.experiment.scan_deque.insert(index + 1, item) self.update_queue_ui() remove_button = button("Remove", class_name="warning") remove_button.subject.subscribe(remove_this_item) copy_button = button("Copy") copy_button.subject.subscribe(copy_this_item) up_button = button("↑") up_button.subject.subscribe(move_item_up) down_button = button("↓") down_button.subject.subscribe(move_item_down) rest = None try: fields = dataclasses.asdict(item) if len(fields) < 3: rest = vertical(*[ label(f"{f}: {str(getattr(item, f))}") for f, v in fields.items() ]) else: split = len(fields) // 2 rest = horizontal( vertical(*[ label(f"{f}: {str(getattr(item, f))}") for f, _ in list(fields.items())[:split] ]), vertical(*[ label(f"{f}: {str(getattr(item, f))}") for f, _ in list(fields.items())[split:] ]), ) except TypeError: rest = label(str(item)) return horizontal( group( label(type(item).__name__), rest, label=f"Queue Item {index + 1}", ), vertical(remove_button, copy_button), vertical(up_button, down_button), )