def test_remove_limit(self): dmin, dmax = min(getx(self.data)), max(getx(self.data)) self.test_add_limit() # if there are three entries, remove one element second = list(layout_widgets(self.editor.ranges_box))[1] button = list(layout_widgets(second))[1] button.click() self.widget.apply() p = self.get_preprocessor() self.assertEqual(p.zero_points, [dmin, (dmin + dmax) / 2]) # if there are two entries, remove both second = list(layout_widgets(self.editor.ranges_box))[1] button = list(layout_widgets(second))[1] button.click() self.widget.apply() p = self.get_preprocessor() self.assertEqual(p.zero_points, None)
def delete_range(self, box): removed = [box] self.ranges_box.layout().removeWidget(box) # if only 1 widget stayed that would be invalid if len(list(layout_widgets(self.ranges_box))) == 1: also_remove = next(layout_widgets(self.ranges_box)) self.ranges_box.layout().removeWidget(also_remove) removed.append(also_remove) self._set_button_text() # remove selection lines curveplot = self.parent_widget.curveplot for r in removed: for w in self._extract_pair(r): if curveplot.in_markings(w.line): curveplot.remove_marking(w.line) self.edited.emit()
def _range_widgets(self): for b in layout_widgets(self.ranges_box): yield self._extract_all(b)
def _extract_all(self, container): return list(layout_widgets(container))
def _extract_pair(self, container): return list(layout_widgets(container))[:1]