def __init__(self, argument): LayoutWidget.__init__(self) self.argument = argument self.stack = QtGui.QStackedWidget() self.addWidget(self.stack, 1, 0, colspan=4) procdesc = argument["desc"] state = argument["state"] self.widgets = OrderedDict() self.widgets["NoScan"] = _NoScan(procdesc, state["NoScan"]) self.widgets["LinearScan"] = _Range(procdesc, state["LinearScan"]) self.widgets["RandomScan"] = _Range(procdesc, state["RandomScan"]) self.widgets["ExplicitScan"] = _Explicit(state["ExplicitScan"]) for widget in self.widgets.values(): self.stack.addWidget(widget) self.radiobuttons = OrderedDict() self.radiobuttons["NoScan"] = QtGui.QRadioButton("No scan") self.radiobuttons["LinearScan"] = QtGui.QRadioButton("Linear") self.radiobuttons["RandomScan"] = QtGui.QRadioButton("Random") self.radiobuttons["ExplicitScan"] = QtGui.QRadioButton("Explicit") scan_type = QtGui.QButtonGroup() for n, b in enumerate(self.radiobuttons.values()): self.addWidget(b, 0, n) scan_type.addButton(b) b.toggled.connect(self._scan_type_toggled) selected = argument["state"]["selected"] self.radiobuttons[selected].setChecked(True)
def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] self.value = QtGui.QDoubleSpinBox() disable_scroll_wheel(self.value) self.value.setDecimals(procdesc["ndecimals"]) if procdesc["global_min"] is not None: self.value.setMinimum(procdesc["global_min"]/scale) else: self.value.setMinimum(float("-inf")) if procdesc["global_max"] is not None: self.value.setMaximum(procdesc["global_max"]/scale) else: self.value.setMaximum(float("inf")) self.value.setSingleStep(procdesc["global_step"]/scale) if procdesc["unit"]: self.value.setSuffix(" " + procdesc["unit"]) self.addWidget(QtGui.QLabel("Value:"), 0, 0) self.addWidget(self.value, 0, 1) self.value.setValue(state["value"]/scale) def update(value): state["value"] = value*scale self.value.valueChanged.connect(update)
def __init__(self, global_min, global_max, global_step, unit, ndecimals): LayoutWidget.__init__(self) def apply_properties(spinbox): spinbox.setDecimals(ndecimals) if global_min is not None: spinbox.setMinimum(global_min) else: spinbox.setMinimum(float("-inf")) if global_max is not None: spinbox.setMaximum(global_max) else: spinbox.setMaximum(float("inf")) if global_step is not None: spinbox.setSingleStep(global_step) if unit: spinbox.setSuffix(" " + unit) self.addWidget(QtGui.QLabel("Min:"), 0, 0) self.min = QtGui.QDoubleSpinBox() apply_properties(self.min) self.addWidget(self.min, 0, 1) self.addWidget(QtGui.QLabel("Max:"), 0, 2) self.max = QtGui.QDoubleSpinBox() apply_properties(self.max) self.addWidget(self.max, 0, 3) self.addWidget(QtGui.QLabel("#Points:"), 0, 4) self.npoints = QtGui.QSpinBox() self.npoints.setMinimum(2) self.npoints.setValue(10) self.addWidget(self.npoints, 0, 5)
def __init__(self, dialog_parent, dock_area): dockarea.Dock.__init__(self, "Results", size=(1500, 500)) self.dialog_parent = dialog_parent self.dock_area = dock_area grid = LayoutWidget() self.addWidget(grid) self.table = QtGui.QTableView() self.table.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.table.horizontalHeader().setResizeMode( QtGui.QHeaderView.ResizeToContents) grid.addWidget(self.table, 0, 0) add_display_box = QtGui.QGroupBox("Add display") grid.addWidget(add_display_box, 0, 1) display_grid = QtGui.QGridLayout() add_display_box.setLayout(display_grid) for n, name in enumerate(display_types.keys()): btn = QtGui.QPushButton(name) display_grid.addWidget(btn, n, 0) btn.clicked.connect(partial(self.create_dialog, name)) self.displays = dict()
def __init__(self, global_min, global_max, global_step, unit, scale, ndecimals): LayoutWidget.__init__(self) self.scale = scale def apply_properties(spinbox): spinbox.setDecimals(ndecimals) if global_min is not None: spinbox.setMinimum(global_min / self.scale) else: spinbox.setMinimum(float("-inf")) if global_max is not None: spinbox.setMaximum(global_max / self.scale) else: spinbox.setMaximum(float("inf")) if global_step is not None: spinbox.setSingleStep(global_step / self.scale) if unit: spinbox.setSuffix(" " + unit) self.addWidget(QtGui.QLabel("Min:"), 0, 0) self.min = QtGui.QDoubleSpinBox() apply_properties(self.min) self.addWidget(self.min, 0, 1) self.addWidget(QtGui.QLabel("Max:"), 1, 0) self.max = QtGui.QDoubleSpinBox() apply_properties(self.max) self.addWidget(self.max, 1, 1) self.addWidget(QtGui.QLabel("#Points:"), 2, 0) self.npoints = QtGui.QSpinBox() self.npoints.setMinimum(2) self.npoints.setValue(10) self.addWidget(self.npoints, 2, 1)
def __init__(self, procdesc): LayoutWidget.__init__(self) self.stack = QtGui.QStackedWidget() self.addWidget(self.stack, 1, 0, colspan=4) self.scale = procdesc["scale"] gmin, gmax = procdesc["global_min"], procdesc["global_max"] gstep = procdesc["global_step"] unit = procdesc["unit"] ndecimals = procdesc["ndecimals"] self.v_noscan = QtGui.QDoubleSpinBox() self.v_noscan.setDecimals(ndecimals) if gmin is not None: self.v_noscan.setMinimum(gmin/self.scale) else: self.v_noscan.setMinimum(float("-inf")) if gmax is not None: self.v_noscan.setMaximum(gmax/self.scale) else: self.v_noscan.setMaximum(float("inf")) self.v_noscan.setSingleStep(gstep/self.scale) if unit: self.v_noscan.setSuffix(" " + unit) self.v_noscan_gr = LayoutWidget() self.v_noscan_gr.addWidget(QtGui.QLabel("Value:"), 0, 0) self.v_noscan_gr.addWidget(self.v_noscan, 0, 1) self.stack.addWidget(self.v_noscan_gr) self.v_linear = _Range(gmin, gmax, gstep, unit, self.scale, ndecimals) self.stack.addWidget(self.v_linear) self.v_random = _Range(gmin, gmax, gstep, unit, self.scale, ndecimals) self.stack.addWidget(self.v_random) self.v_explicit = QtGui.QLineEdit() self.v_explicit_gr = LayoutWidget() self.v_explicit_gr.addWidget(QtGui.QLabel("Sequence:"), 0, 0) self.v_explicit_gr.addWidget(self.v_explicit, 0, 1) self.stack.addWidget(self.v_explicit_gr) self.noscan = QtGui.QRadioButton("No scan") self.linear = QtGui.QRadioButton("Linear") self.random = QtGui.QRadioButton("Random") self.explicit = QtGui.QRadioButton("Explicit") radiobuttons = QtGui.QButtonGroup() for n, b in enumerate([self.noscan, self.linear, self.random, self.explicit]): self.addWidget(b, 0, n) radiobuttons.addButton(b) b.toggled.connect(self.select_page) if "default" in procdesc: self.set_argument_value(procdesc["default"]) else: self.noscan.setChecked(True)
def initiate(self, dcontrols, lamb_po, phas, rh, jalph, jbet): self.dcontrols = dcontrols self.layout = LayoutWidget() self.ws = [] self.ws += [Slider(0, 1, "\u03b1")] self.ws += [Slider(0, 1, "\u03b2")] # be careful, the label below affects creation of slide(int or float) self.ws += [Slider(1, 10, "\u2113")] print(self.ws[2].x) for i in range(3): self.layout.addWidget(self.ws[i], row=0, col=i) self.dcontrols.addWidget(self.layout) # ========================================================================= self.ws[0].slider.setMaximum(glo_var.slid_precision) self.ws[0].x = glo_var.alpha self.ws[0].setLabelValue(self.ws[0].x * glo_var.slid_precision) self.ws[0].slider.setValue(glo_var.alpha * glo_var.slid_precision) self.ws[0].slider.valueChanged.connect(self.ws[0].setLabelValue) self.ws[1].slider.setMaximum(glo_var.slid_precision) self.ws[1].x = glo_var.beta self.ws[1].setLabelValue(self.ws[1].x * glo_var.slid_precision) self.ws[1].slider.setValue(glo_var.beta * glo_var.slid_precision) self.ws[1].slider.valueChanged.connect(self.ws[1].setLabelValue) self.ws[2].x = glo_var.l self.ws[2].slider.setPageStep(1) self.ws[2].intsetLabelValue(self.ws[2].x) self.ws[2].slider.setValue(glo_var.l) self.ws[2].slider.valueChanged.connect(self.ws[2].intsetLabelValue) self.ws[2].slider.setMaximum(20) self.ws[2].slider.setMinimum(1) # ===================================================================================================================================== self.update_alpha_slid(self.ws[0]) self.update_beta_slid(self.ws[1]) self.update_l_slid(self.ws[2]) [ self.ws[i].slider.valueChanged.connect(self.update_ab_rh) for i in range(2) ] self.ws[2].slider.valueChanged.connect(self.update_lamb_l) self.phas = phas self.rh = rh self.jalph = jalph self.jbet = jbet self.lamb_po = lamb_po self.phas.receive(self) self.update_ab_rh()
def __init__(self, dialog_parent, dock_area): dockarea.Dock.__init__(self, "Datasets", size=(1500, 500)) self.dialog_parent = dialog_parent self.dock_area = dock_area grid = LayoutWidget() self.addWidget(grid) self.search = QtGui.QLineEdit() self.search.setPlaceholderText("search...") self.search.editingFinished.connect(self._search_datasets) grid.addWidget( self.search, 0, ) self.table = QtGui.QTableView() self.table.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.table.horizontalHeader().setResizeMode( QtGui.QHeaderView.ResizeToContents) grid.addWidget(self.table, 1, 0) add_display_box = QtGui.QGroupBox("Add display") grid.addWidget(add_display_box, 1, 1) display_grid = QtGui.QGridLayout() add_display_box.setLayout(display_grid) for n, name in enumerate(display_types.keys()): btn = QtGui.QPushButton(name) display_grid.addWidget(btn, n, 0) btn.clicked.connect(partial(self.create_dialog, name)) self.displays = dict()
def __init__(self): dockarea.Dock.__init__(self, "Log", size=(1000, 300)) grid = LayoutWidget() self.addWidget(grid) grid.addWidget(QtGui.QLabel("Minimum level: "), 0, 0) grid.layout.setColumnStretch(0, 0) grid.layout.setColumnStretch(1, 0) grid.layout.setColumnStretch(2, 1) self.filterbox = QtGui.QComboBox() for item in "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL": self.filterbox.addItem(item) self.filterbox.setToolTip("Display entries at or above this level") grid.addWidget(self.filterbox, 0, 1) self.filterbox.currentIndexChanged.connect(self.filter_changed) self.log = QtGui.QTableView() self.log.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.log.horizontalHeader().setResizeMode( QtGui.QHeaderView.ResizeToContents) self.log.setHorizontalScrollMode( QtGui.QAbstractItemView.ScrollPerPixel) self.log.setShowGrid(False) self.log.setTextElideMode(QtCore.Qt.ElideNone) grid.addWidget(self.log, 1, 0, colspan=3) self.scroll_at_bottom = False
def __init__(self, procdesc, state): LayoutWidget.__init__(self) scale = procdesc["scale"] def apply_properties(spinbox): spinbox.setDecimals(procdesc["ndecimals"]) if procdesc["global_min"] is not None: spinbox.setMinimum(procdesc["global_min"]/scale) else: spinbox.setMinimum(float("-inf")) if procdesc["global_max"] is not None: spinbox.setMaximum(procdesc["global_max"]/scale) else: spinbox.setMaximum(float("inf")) if procdesc["global_step"] is not None: spinbox.setSingleStep(procdesc["global_step"]/scale) if procdesc["unit"]: spinbox.setSuffix(" " + procdesc["unit"]) self.addWidget(QtGui.QLabel("Min:"), 0, 0) self.min = QtGui.QDoubleSpinBox() disable_scroll_wheel(self.min) apply_properties(self.min) self.addWidget(self.min, 0, 1) self.addWidget(QtGui.QLabel("Max:"), 1, 0) self.max = QtGui.QDoubleSpinBox() disable_scroll_wheel(self.max) apply_properties(self.max) self.addWidget(self.max, 1, 1) self.addWidget(QtGui.QLabel("#Points:"), 2, 0) self.npoints = QtGui.QSpinBox() disable_scroll_wheel(self.npoints) self.npoints.setMinimum(2) self.npoints.setValue(10) self.addWidget(self.npoints, 2, 1) self.min.setValue(state["min"]/scale) self.max.setValue(state["max"]/scale) self.npoints.setValue(state["npoints"]) def update_min(value): state["min"] = value*scale def update_max(value): state["min"] = value*scale def update_npoints(value): state["npoints"] = value self.min.valueChanged.connect(update_min) self.max.valueChanged.connect(update_max) self.npoints.valueChanged.connect(update_npoints)
def __init__(self, state): LayoutWidget.__init__(self) self.value = QtGui.QLineEdit() self.addWidget(QtGui.QLabel("Sequence:"), 0, 0) self.addWidget(self.value, 0, 1) float_regexp = "[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?" regexp = "(float)?( +float)* *".replace("float", float_regexp) self.value.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(regexp), self.value)) self.value.setText(" ".join([str(x) for x in state["sequence"]])) def update(text): state["sequence"] = [float(x) for x in text.split()] self.value.textEdited.connect(update)
def __init__(self, dialog_parent, dock_area, datasets_sub): dockarea.Dock.__init__(self, "Datasets") self.dialog_parent = dialog_parent self.dock_area = dock_area grid = LayoutWidget() self.addWidget(grid) self.search = QtGui.QLineEdit() self.search.setPlaceholderText("search...") self.search.editingFinished.connect(self._search_datasets) grid.addWidget(self.search, 0, 0) self.table = QtGui.QTreeView() self.table.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.table.header().setResizeMode(QtGui.QHeaderView.ResizeToContents) grid.addWidget(self.table, 1, 0) self.table_model = Model(dict()) datasets_sub.add_setmodel_callback(self.set_model) datasets_sub.notify_cbs.append(self.on_mod) add_display_box = QtGui.QGroupBox("Add display") grid.addWidget(add_display_box, 1, 1) display_grid = QtGui.QGridLayout() add_display_box.setLayout(display_grid) for n, name in enumerate(display_types.keys()): btn = QtGui.QPushButton(name) display_grid.addWidget(btn, n, 0) btn.clicked.connect(partial(self.create_dialog, name)) self.displays = dict()
def __init__(self, procdesc): LayoutWidget.__init__(self) self.stack = QtGui.QStackedWidget() self.addWidget(self.stack, 1, 0, colspan=4) self.scale = procdesc["scale"] gmin, gmax = procdesc["global_min"], procdesc["global_max"] gstep = procdesc["global_step"] unit = procdesc["unit"] ndecimals = procdesc["ndecimals"] self.v_noscan = QtGui.QDoubleSpinBox() self.v_noscan.setDecimals(ndecimals) if gmin is not None: self.v_noscan.setMinimum(gmin / self.scale) else: self.v_noscan.setMinimum(float("-inf")) if gmax is not None: self.v_noscan.setMaximum(gmax / self.scale) else: self.v_noscan.setMaximum(float("inf")) self.v_noscan.setSingleStep(gstep / self.scale) if unit: self.v_noscan.setSuffix(" " + unit) self.v_noscan_gr = LayoutWidget() self.v_noscan_gr.addWidget(QtGui.QLabel("Value:"), 0, 0) self.v_noscan_gr.addWidget(self.v_noscan, 0, 1) self.stack.addWidget(self.v_noscan_gr) self.v_linear = _Range(gmin, gmax, gstep, unit, self.scale, ndecimals) self.stack.addWidget(self.v_linear) self.v_random = _Range(gmin, gmax, gstep, unit, self.scale, ndecimals) self.stack.addWidget(self.v_random) self.v_explicit = QtGui.QLineEdit() self.v_explicit_gr = LayoutWidget() self.v_explicit_gr.addWidget(QtGui.QLabel("Sequence:"), 0, 0) self.v_explicit_gr.addWidget(self.v_explicit, 0, 1) self.stack.addWidget(self.v_explicit_gr) self.noscan = QtGui.QRadioButton("No scan") self.linear = QtGui.QRadioButton("Linear") self.random = QtGui.QRadioButton("Random") self.explicit = QtGui.QRadioButton("Explicit") radiobuttons = QtGui.QButtonGroup() for n, b in enumerate( [self.noscan, self.linear, self.random, self.explicit]): self.addWidget(b, 0, n) radiobuttons.addButton(b) b.toggled.connect(self.select_page) if "default" in procdesc: self.set_argument_value(procdesc["default"]) else: self.noscan.setChecked(True)
def __init__(self, manager, dock, expurl): self.manager = manager self.expurl = expurl QtGui.QTreeWidget.__init__(self) self.setColumnCount(3) self.header().setStretchLastSection(False) if hasattr(self.header(), "setSectionResizeMode"): set_resize_mode = self.header().setSectionResizeMode else: set_resize_mode = self.header().setResizeMode set_resize_mode(0, QtGui.QHeaderView.ResizeToContents) set_resize_mode(1, QtGui.QHeaderView.Stretch) set_resize_mode(2, QtGui.QHeaderView.ResizeToContents) self.header().setVisible(False) self.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.setHorizontalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel) self.setVerticalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel) self._groups = dict() self._arg_to_entry_widgetitem = dict() arguments = self.manager.get_submission_arguments(self.expurl) if not arguments: self.addTopLevelItem(QtGui.QTreeWidgetItem(["No arguments"])) for name, argument in arguments.items(): entry = _argty_to_entry[argument["desc"]["ty"]](argument) widget_item = QtGui.QTreeWidgetItem([name]) self._arg_to_entry_widgetitem[name] = entry, widget_item if argument["group"] is None: self.addTopLevelItem(widget_item) else: self._get_group(argument["group"]).addChild(widget_item) self.setItemWidget(widget_item, 1, entry) recompute_argument = QtGui.QToolButton() recompute_argument.setToolTip("Re-run the experiment's build " "method and take the default value") recompute_argument.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_BrowserReload)) recompute_argument.clicked.connect(partial(self._recompute_argument_clicked, name)) fix_layout = LayoutWidget() fix_layout.addWidget(recompute_argument) self.setItemWidget(widget_item, 2, fix_layout) widget_item = QtGui.QTreeWidgetItem() self.addTopLevelItem(widget_item) recompute_arguments = QtGui.QPushButton("Recompute all arguments") recompute_arguments.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_BrowserReload)) recompute_arguments.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) recompute_arguments.clicked.connect(dock._recompute_arguments_clicked) fix_layout = LayoutWidget() fix_layout.addWidget(recompute_arguments) self.setItemWidget(widget_item, 1, fix_layout)
def __init__(self, manager, name, log_sub): dockarea.Dock.__init__(self, name, label="Log", size=(1000, 300)) grid = LayoutWidget() self.addWidget(grid) grid.addWidget(QtGui.QLabel("Minimum level: "), 0, 0) self.filter_level = QtGui.QComboBox() self.filter_level.addItems(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]) self.filter_level.setToolTip("Display entries at or above this level") grid.addWidget(self.filter_level, 0, 1) self.filter_level.currentIndexChanged.connect( self.filter_level_changed) self.filter_freetext = QtGui.QLineEdit() self.filter_freetext.setPlaceholderText("freetext filter...") self.filter_freetext.editingFinished.connect( self.filter_freetext_changed) grid.addWidget(self.filter_freetext, 0, 2) self.log = QtGui.QTableView() self.log.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.log.horizontalHeader().setResizeMode( QtGui.QHeaderView.ResizeToContents) self.log.setHorizontalScrollMode( QtGui.QAbstractItemView.ScrollPerPixel) self.log.setShowGrid(False) self.log.setTextElideMode(QtCore.Qt.ElideNone) grid.addWidget(self.log, 1, 0, colspan=4) self.scroll_at_bottom = False self.scroll_value = 0 self.log.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) newlog_action = QtGui.QAction("Create new log dock", self.log) # note the lambda, the default parameter is overriden otherwise newlog_action.triggered.connect(lambda: manager.create_new_dock()) self.log.addAction(newlog_action) log_sub.add_setmodel_callback(self.set_model)
def __init__(self): dockarea.Dock.__init__(self, "Parameters", size=(400, 300)) grid = LayoutWidget() self.addWidget(grid) self.search = QtGui.QLineEdit() self.search.setPlaceholderText("search...") self.search.editingFinished.connect(self._search_parameters) grid.addWidget(self.search, 0, 0) self.table = QtGui.QTableView() self.table.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.table.horizontalHeader().setResizeMode( QtGui.QHeaderView.ResizeToContents) grid.addWidget(self.table, 1, 0)
class ScanController(LayoutWidget): def __init__(self, procdesc): LayoutWidget.__init__(self) self.stack = QtGui.QStackedWidget() self.addWidget(self.stack, 1, 0, colspan=4) self.scale = procdesc["scale"] gmin, gmax = procdesc["global_min"], procdesc["global_max"] gstep = procdesc["global_step"] unit = procdesc["unit"] ndecimals = procdesc["ndecimals"] self.v_noscan = QtGui.QDoubleSpinBox() self.v_noscan.setDecimals(ndecimals) if gmin is not None: self.v_noscan.setMinimum(gmin / self.scale) else: self.v_noscan.setMinimum(float("-inf")) if gmax is not None: self.v_noscan.setMaximum(gmax / self.scale) else: self.v_noscan.setMaximum(float("inf")) self.v_noscan.setSingleStep(gstep / self.scale) if unit: self.v_noscan.setSuffix(" " + unit) self.v_noscan_gr = LayoutWidget() self.v_noscan_gr.addWidget(QtGui.QLabel("Value:"), 0, 0) self.v_noscan_gr.addWidget(self.v_noscan, 0, 1) self.stack.addWidget(self.v_noscan_gr) self.v_linear = _Range(gmin, gmax, gstep, unit, self.scale, ndecimals) self.stack.addWidget(self.v_linear) self.v_random = _Range(gmin, gmax, gstep, unit, self.scale, ndecimals) self.stack.addWidget(self.v_random) self.v_explicit = QtGui.QLineEdit() self.v_explicit_gr = LayoutWidget() self.v_explicit_gr.addWidget(QtGui.QLabel("Sequence:"), 0, 0) self.v_explicit_gr.addWidget(self.v_explicit, 0, 1) self.stack.addWidget(self.v_explicit_gr) self.noscan = QtGui.QRadioButton("No scan") self.linear = QtGui.QRadioButton("Linear") self.random = QtGui.QRadioButton("Random") self.explicit = QtGui.QRadioButton("Explicit") radiobuttons = QtGui.QButtonGroup() for n, b in enumerate([self.noscan, self.linear, self.random, self.explicit]): self.addWidget(b, 0, n) radiobuttons.addButton(b) b.toggled.connect(self.select_page) if "default" in procdesc: self.set_argument_value(procdesc["default"]) else: self.noscan.setChecked(True) def select_page(self): if self.noscan.isChecked(): self.stack.setCurrentWidget(self.v_noscan_gr) elif self.linear.isChecked(): self.stack.setCurrentWidget(self.v_linear) elif self.random.isChecked(): self.stack.setCurrentWidget(self.v_random) elif self.explicit.isChecked(): self.stack.setCurrentWidget(self.v_explicit_gr) def get_argument_value(self): if self.noscan.isChecked(): return {"ty": "NoScan", "value": self.v_noscan.value() * self.scale} elif self.linear.isChecked(): d = {"ty": "LinearScan"} d.update(self.v_linear.get_values()) return d elif self.random.isChecked(): d = {"ty": "RandomScan"} d.update(self.v_random.get_values()) return d elif self.explicit.isChecked(): sequence = [float(x) for x in self.v_explicit.text().split()] return {"ty": "ExplicitScan", "sequence": sequence} def set_argument_value(self, d): if d["ty"] == "NoScan": self.noscan.setChecked(True) self.v_noscan.setValue(d["value"] / self.scale) elif d["ty"] == "LinearScan": self.linear.setChecked(True) self.v_linear.set_values(d["min"], d["max"], d["npoints"]) elif d["ty"] == "RandomScan": self.random.setChecked(True) self.v_random.set_values(d["min"], d["max"], d["npoints"]) elif d["ty"] == "ExplicitScan": self.explicit.setChecked(True) self.v_explicit.insert(" ".join([str(x) for x in d["sequence"]])) else: raise ValueError("Unknown scan type '{}'".format(d["ty"]))
class Widget(QtGui.QWidget): def __init__(self, dcontrols, lamb_po, phas, rh, jalph, jbet, parent=None): super(Widget, self).__init__(parent=parent) self.initiate(dcontrols, lamb_po, phas, rh, jalph, jbet) def initiate(self, dcontrols, lamb_po, phas, rh, jalph, jbet): self.dcontrols = dcontrols self.layout = LayoutWidget() self.ws = [] self.ws += [Slider(0, 1, "\u03b1")] self.ws += [Slider(0, 1, "\u03b2")] # be careful, the label below affects creation of slide(int or float) self.ws += [Slider(1, 10, "\u2113")] print(self.ws[2].x) for i in range(3): self.layout.addWidget(self.ws[i], row=0, col=i) self.dcontrols.addWidget(self.layout) # ========================================================================= self.ws[0].slider.setMaximum(glo_var.slid_precision) self.ws[0].x = glo_var.alpha self.ws[0].setLabelValue(self.ws[0].x * glo_var.slid_precision) self.ws[0].slider.setValue(glo_var.alpha * glo_var.slid_precision) self.ws[0].slider.valueChanged.connect(self.ws[0].setLabelValue) self.ws[1].slider.setMaximum(glo_var.slid_precision) self.ws[1].x = glo_var.beta self.ws[1].setLabelValue(self.ws[1].x * glo_var.slid_precision) self.ws[1].slider.setValue(glo_var.beta * glo_var.slid_precision) self.ws[1].slider.valueChanged.connect(self.ws[1].setLabelValue) self.ws[2].x = glo_var.l self.ws[2].slider.setPageStep(1) self.ws[2].intsetLabelValue(self.ws[2].x) self.ws[2].slider.setValue(glo_var.l) self.ws[2].slider.valueChanged.connect(self.ws[2].intsetLabelValue) self.ws[2].slider.setMaximum(20) self.ws[2].slider.setMinimum(1) # ===================================================================================================================================== self.update_alpha_slid(self.ws[0]) self.update_beta_slid(self.ws[1]) self.update_l_slid(self.ws[2]) [ self.ws[i].slider.valueChanged.connect(self.update_ab_rh) for i in range(2) ] self.ws[2].slider.valueChanged.connect(self.update_lamb_l) self.phas = phas self.rh = rh self.jalph = jalph self.jbet = jbet self.lamb_po = lamb_po self.phas.receive(self) self.update_ab_rh() # Updates def update_lamb_rh(self, index, y, remove): glo_var.alpha = self.ws[0].x glo_var.beta = self.ws[1].x glo_var.l = self.ws[2].x if remove == 0: glo_var.lambdas[index][1] = y self.lamb_po.update() self.rh.update() self.update_alpha_slid(self.ws[0]) self.update_beta_slid(self.ws[1]) self.phas.update() self.jalph.update() self.jbet.update() def update_lamb_l(self): glo_var.alpha = self.ws[0].x glo_var.beta = self.ws[1].x glo_var.l = self.ws[2].x self.update_alpha_slid(self.ws[0]) self.update_beta_slid(self.ws[1]) # self.lamb_po.update() self.rh.update() self.phas.update() self.jalph.update() self.jbet.update() def update_phas(self, a, b): glo_var.alpha = a glo_var.beta = b self.rh.update() self.update_alpha_slid(self.ws[0]) self.update_beta_slid(self.ws[1]) self.phas.update() self.jalph.update() self.jbet.update() def update_ab_rh(self): glo_var.alpha = self.ws[0].x glo_var.beta = self.ws[1].x self.rh.update() self.phas.update() self.jalph.update() self.jbet.update() def update_l_slid(self, slid): slid.x = glo_var.l slid.spin.setValue(slid.x) slid.intsetLabelValue(slid.x) slid.slider.setValue(glo_var.l) def update_alpha_slid(self, slid): slid.slider.setMaximum(2 * glo_var.alpha_star * glo_var.slid_precision) slid.spin.setRange(0, 2 * glo_var.alpha_star) slid.x = glo_var.alpha temp = glo_var.beta slid.spin.setValue(slid.x) glo_var.beta = temp slid.setLabelValue(slid.x * glo_var.slid_precision) slid.slider.setValue(glo_var.alpha * glo_var.slid_precision) def update_beta_slid(self, slid): slid.slider.setMaximum(2 * glo_var.beta_star * glo_var.slid_precision) slid.spin.setRange(0, 2 * glo_var.beta_star) slid.x = glo_var.beta temp = glo_var.beta slid.spin.setValue(slid.x) glo_var.beta = temp slid.setLabelValue(slid.x * glo_var.slid_precision) slid.slider.setValue(glo_var.beta * glo_var.slid_precision)
class ScanController(LayoutWidget): def __init__(self, procdesc): LayoutWidget.__init__(self) self.stack = QtGui.QStackedWidget() self.addWidget(self.stack, 1, 0, colspan=4) gmin, gmax = procdesc["global_min"], procdesc["global_max"] gstep = procdesc["global_step"] unit = procdesc["unit"] ndecimals = procdesc["ndecimals"] self.v_noscan = QtGui.QDoubleSpinBox() self.v_noscan.setDecimals(ndecimals) if gmin is not None: self.v_noscan.setMinimum(gmin) else: self.v_noscan.setMinimum(float("-inf")) if gmax is not None: self.v_noscan.setMaximum(gmax) else: self.v_noscan.setMaximum(float("inf")) if gstep is not None: self.v_noscan.setSingleStep(gstep) if unit: self.v_noscan.setSuffix(" " + unit) self.v_noscan_gr = LayoutWidget() self.v_noscan_gr.addWidget(QtGui.QLabel("Value:"), 0, 0) self.v_noscan_gr.addWidget(self.v_noscan, 0, 1) self.stack.addWidget(self.v_noscan_gr) self.v_linear = _Range(gmin, gmax, gstep, unit, ndecimals) self.stack.addWidget(self.v_linear) self.v_random = _Range(gmin, gmax, gstep, unit, ndecimals) self.stack.addWidget(self.v_random) self.v_explicit = QtGui.QLineEdit() self.v_explicit_gr = LayoutWidget() self.v_explicit_gr.addWidget(QtGui.QLabel("Sequence:"), 0, 0) self.v_explicit_gr.addWidget(self.v_explicit, 0, 1) self.stack.addWidget(self.v_explicit_gr) self.noscan = QtGui.QRadioButton("No scan") self.linear = QtGui.QRadioButton("Linear") self.random = QtGui.QRadioButton("Random") self.explicit = QtGui.QRadioButton("Explicit") radiobuttons = QtGui.QButtonGroup() for n, b in enumerate( [self.noscan, self.linear, self.random, self.explicit]): self.addWidget(b, 0, n) radiobuttons.addButton(b) b.toggled.connect(self.select_page) if "default" in procdesc: self.set_argument_value(procdesc["default"]) else: self.noscan.setChecked(True) def select_page(self): if self.noscan.isChecked(): self.stack.setCurrentWidget(self.v_noscan_gr) elif self.linear.isChecked(): self.stack.setCurrentWidget(self.v_linear) elif self.random.isChecked(): self.stack.setCurrentWidget(self.v_random) elif self.explicit.isChecked(): self.stack.setCurrentWidget(self.v_explicit_gr) def get_argument_value(self): if self.noscan.isChecked(): return {"ty": "NoScan", "value": self.v_noscan.value()} elif self.linear.isChecked(): d = {"ty": "LinearScan"} d.update(self.v_linear.get_values()) return d elif self.random.isChecked(): d = {"ty": "RandomScan"} d.update(self.v_random.get_values()) return d elif self.explicit.isChecked(): sequence = [float(x) for x in self.v_explicit.text().split()] return {"ty": "ExplicitScan", "sequence": sequence} def set_argument_value(self, d): if d["ty"] == "NoScan": self.noscan.setChecked(True) self.v_noscan.setValue(d["value"]) elif d["ty"] == "LinearScan": self.linear.setChecked(True) self.v_linear.set_values(d["min"], d["max"], d["npoints"]) elif d["ty"] == "RandomScan": self.random.setChecked(True) self.v_random.set_values(d["min"], d["max"], d["npoints"]) elif d["ty"] == "ExplicitScan": self.explicit.setChecked(True) self.v_explicit.insert(" ".join([str(x) for x in d["sequence"]])) else: raise ValueError("Unknown scan type '{}'".format(d["ty"]))
def __init__(self, dialog_parent, status_bar, schedule_ctl): dockarea.Dock.__init__(self, "Explorer", size=(1500, 500)) self.dialog_parent = dialog_parent self.status_bar = status_bar self.schedule_ctl = schedule_ctl self.splitter = QtGui.QSplitter(QtCore.Qt.Horizontal) self.addWidget(self.splitter) grid = LayoutWidget() self.splitter.addWidget(grid) self.el = QtGui.QListView() self.el.selectionChanged = self._selection_changed self.selected_key = None grid.addWidget(self.el, 0, 0, colspan=4) self.datetime = QtGui.QDateTimeEdit() self.datetime.setDisplayFormat("MMM d yyyy hh:mm:ss") self.datetime.setDate(QtCore.QDate.currentDate()) self.datetime.dateTimeChanged.connect(self.enable_duedate) self.datetime_en = QtGui.QCheckBox("Due date:") grid.addWidget(self.datetime_en, 1, 0, colspan=2) grid.addWidget(self.datetime, 1, 2, colspan=2) self.pipeline = QtGui.QLineEdit() self.pipeline.setText("main") grid.addWidget(QtGui.QLabel("Pipeline:"), 2, 0, colspan=2) grid.addWidget(self.pipeline, 2, 2, colspan=2) self.priority = QtGui.QSpinBox() self.priority.setRange(-99, 99) grid.addWidget(QtGui.QLabel("Priority:"), 3, 0) grid.addWidget(self.priority, 3, 1) self.flush = QtGui.QCheckBox("Flush") self.flush.setToolTip( "Flush the pipeline before starting the experiment") grid.addWidget(self.flush, 3, 2) self.log_level = QtGui.QComboBox() for item in "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL": self.log_level.addItem(item) self.log_level.setCurrentIndex(1) self.log_level.setToolTip("Minimum level for log entry production") grid.addWidget(self.log_level, 3, 3) submit = QtGui.QPushButton("Submit") submit.setShortcut("CTRL+RETURN") submit.setToolTip("Schedule the selected experiment (CTRL+ENTER)") grid.addWidget(submit, 4, 0, colspan=4) submit.clicked.connect(self.submit_clicked) self.argeditor = _ArgumentEditor(self.dialog_parent) self.splitter.addWidget(self.argeditor) self.splitter.setSizes([grid.minimumSizeHint().width(), 1000]) self.state = dict()
def __init__(self, dialog_parent, status_bar, schedule_ctl): dockarea.Dock.__init__(self, "Explorer", size=(1500, 500)) self.dialog_parent = dialog_parent self.status_bar = status_bar self.schedule_ctl = schedule_ctl self.splitter = QtGui.QSplitter(QtCore.Qt.Horizontal) self.addWidget(self.splitter) grid = LayoutWidget() self.splitter.addWidget(grid) self.el = QtGui.QListView() self.el.selectionChanged = self._selection_changed self.selected_key = None grid.addWidget(self.el, 0, 0, colspan=4) self.datetime = QtGui.QDateTimeEdit() self.datetime.setDisplayFormat("MMM d yyyy hh:mm:ss") self.datetime.setCalendarPopup(True) self.datetime.setDate(QtCore.QDate.currentDate()) self.datetime.dateTimeChanged.connect(self.enable_duedate) self.datetime_en = QtGui.QCheckBox("Due date:") grid.addWidget(self.datetime_en, 1, 0) grid.addWidget(self.datetime, 1, 1) self.priority = QtGui.QSpinBox() self.priority.setRange(-99, 99) grid.addWidget(QtGui.QLabel("Priority:"), 1, 2) grid.addWidget(self.priority, 1, 3) self.pipeline = QtGui.QLineEdit() self.pipeline.setText("main") grid.addWidget(QtGui.QLabel("Pipeline:"), 2, 0) grid.addWidget(self.pipeline, 2, 1) self.flush = QtGui.QCheckBox("Flush") grid.addWidget(self.flush, 2, 2, colspan=2) submit = QtGui.QPushButton("Submit") grid.addWidget(submit, 3, 0, colspan=4) submit.clicked.connect(self.submit_clicked) self.argeditor = _ArgumentEditor(self.dialog_parent) self.splitter.addWidget(self.argeditor) self.splitter.setSizes([grid.minimumSizeHint().width(), 1000]) self.state = dict()
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(800, 480) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( MainWindow.sizePolicy().hasHeightForWidth()) MainWindow.setSizePolicy(sizePolicy) MainWindow.setMinimumSize(QtCore.QSize(800, 480)) MainWindow.setMaximumSize(QtCore.QSize(800, 480)) MainWindow.setLocale( QtCore.QLocale(QtCore.QLocale.Spanish, QtCore.QLocale.Chile)) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setMinimumSize(QtCore.QSize(800, 480)) self.centralwidget.setMaximumSize(QtCore.QSize(800, 480)) font = QtGui.QFont() font.setPointSize(9) self.centralwidget.setFont(font) self.centralwidget.setObjectName("centralwidget") self.verticalLayout_9 = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout_9.setObjectName("verticalLayout_9") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(1, 1, 1, 1) self.horizontalLayout.setSpacing(2) self.horizontalLayout.setObjectName("horizontalLayout") self.frm_cpmax = QtWidgets.QFrame(self.centralwidget) self.frm_cpmax.setFrameShape(QtWidgets.QFrame.Panel) self.frm_cpmax.setFrameShadow(QtWidgets.QFrame.Plain) self.frm_cpmax.setLineWidth(1) self.frm_cpmax.setObjectName("frm_cpmax") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frm_cpmax) self.verticalLayout_2.setContentsMargins(2, 2, 2, 2) self.verticalLayout_2.setObjectName("verticalLayout_2") self.label = QtWidgets.QLabel(self.frm_cpmax) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label.sizePolicy().hasHeightForWidth()) self.label.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(12) self.label.setFont(font) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.verticalLayout_2.addWidget(self.label) self.lbl_cpmax = QtWidgets.QLabel(self.frm_cpmax) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_cpmax.sizePolicy().hasHeightForWidth()) self.lbl_cpmax.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(16) font.setBold(True) font.setWeight(75) self.lbl_cpmax.setFont(font) self.lbl_cpmax.setAlignment(QtCore.Qt.AlignCenter) self.lbl_cpmax.setObjectName("lbl_cpmax") self.verticalLayout_2.addWidget(self.lbl_cpmax) self.lbl_mp = QtWidgets.QLabel(self.frm_cpmax) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_mp.sizePolicy().hasHeightForWidth()) self.lbl_mp.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(9) self.lbl_mp.setFont(font) self.lbl_mp.setAlignment(QtCore.Qt.AlignCenter) self.lbl_mp.setObjectName("lbl_mp") self.verticalLayout_2.addWidget(self.lbl_mp) self.horizontalLayout.addWidget(self.frm_cpmax) self.frm_cpavg = QtWidgets.QFrame(self.centralwidget) self.frm_cpavg.setFrameShape(QtWidgets.QFrame.Panel) self.frm_cpavg.setFrameShadow(QtWidgets.QFrame.Plain) self.frm_cpavg.setLineWidth(1) self.frm_cpavg.setObjectName("frm_cpavg") self.verticalLayout_11 = QtWidgets.QVBoxLayout(self.frm_cpavg) self.verticalLayout_11.setContentsMargins(1, 1, 1, 1) self.verticalLayout_11.setSpacing(2) self.verticalLayout_11.setObjectName("verticalLayout_11") self.label_3 = QtWidgets.QLabel(self.frm_cpavg) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_3.sizePolicy().hasHeightForWidth()) self.label_3.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(12) self.label_3.setFont(font) self.label_3.setAlignment(QtCore.Qt.AlignCenter) self.label_3.setObjectName("label_3") self.verticalLayout_11.addWidget(self.label_3) self.lbl_cpavg = QtWidgets.QLabel(self.frm_cpavg) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_cpavg.sizePolicy().hasHeightForWidth()) self.lbl_cpavg.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) font.setWeight(75) self.lbl_cpavg.setFont(font) self.lbl_cpavg.setAlignment(QtCore.Qt.AlignCenter) self.lbl_cpavg.setObjectName("lbl_cpavg") self.verticalLayout_11.addWidget(self.lbl_cpavg) self.label_4 = QtWidgets.QLabel(self.frm_cpavg) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_4.sizePolicy().hasHeightForWidth()) self.label_4.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(9) self.label_4.setFont(font) self.label_4.setObjectName("label_4") self.verticalLayout_11.addWidget(self.label_4) self.horizontalLayout.addWidget(self.frm_cpavg) self.frm_peep = QtWidgets.QFrame(self.centralwidget) self.frm_peep.setFrameShape(QtWidgets.QFrame.Panel) self.frm_peep.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_peep.setLineWidth(2) self.frm_peep.setObjectName("frm_peep") self.verticalLayout_10 = QtWidgets.QVBoxLayout(self.frm_peep) self.verticalLayout_10.setContentsMargins(1, 1, 1, 1) self.verticalLayout_10.setSpacing(2) self.verticalLayout_10.setObjectName("verticalLayout_10") self.label_5 = QtWidgets.QLabel(self.frm_peep) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_5.sizePolicy().hasHeightForWidth()) self.label_5.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(12) self.label_5.setFont(font) self.label_5.setAlignment(QtCore.Qt.AlignCenter) self.label_5.setObjectName("label_5") self.verticalLayout_10.addWidget(self.label_5) self.lbl_current_peep = QtWidgets.QLabel(self.frm_peep) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_current_peep.sizePolicy().hasHeightForWidth()) self.lbl_current_peep.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) font.setWeight(75) self.lbl_current_peep.setFont(font) self.lbl_current_peep.setAlignment(QtCore.Qt.AlignCenter) self.lbl_current_peep.setObjectName("lbl_current_peep") self.verticalLayout_10.addWidget(self.lbl_current_peep) self.lbl_peep = QtWidgets.QLabel(self.frm_peep) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_peep.sizePolicy().hasHeightForWidth()) self.lbl_peep.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(9) self.lbl_peep.setFont(font) self.lbl_peep.setAlignment(QtCore.Qt.AlignCenter) self.lbl_peep.setObjectName("lbl_peep") self.verticalLayout_10.addWidget(self.lbl_peep) self.horizontalLayout.addWidget(self.frm_peep) self.frm_ratioie = QtWidgets.QFrame(self.centralwidget) self.frm_ratioie.setFrameShape(QtWidgets.QFrame.Panel) self.frm_ratioie.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_ratioie.setLineWidth(2) self.frm_ratioie.setObjectName("frm_ratioie") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.frm_ratioie) self.verticalLayout_3.setContentsMargins(1, 1, 1, 1) self.verticalLayout_3.setSpacing(2) self.verticalLayout_3.setObjectName("verticalLayout_3") self.label_7 = QtWidgets.QLabel(self.frm_ratioie) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_7.sizePolicy().hasHeightForWidth()) self.label_7.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(12) self.label_7.setFont(font) self.label_7.setAlignment(QtCore.Qt.AlignCenter) self.label_7.setObjectName("label_7") self.verticalLayout_3.addWidget(self.label_7) self.lbl_ier = QtWidgets.QLabel(self.frm_ratioie) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_ier.sizePolicy().hasHeightForWidth()) self.lbl_ier.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) font.setWeight(75) self.lbl_ier.setFont(font) self.lbl_ier.setAlignment(QtCore.Qt.AlignCenter) self.lbl_ier.setObjectName("lbl_ier") self.verticalLayout_3.addWidget(self.lbl_ier) self.lbl_mp1 = QtWidgets.QLabel(self.frm_ratioie) self.lbl_mp1.setText("") self.lbl_mp1.setObjectName("lbl_mp1") self.verticalLayout_3.addWidget(self.lbl_mp1) self.horizontalLayout.addWidget(self.frm_ratioie) self.frm_rpm = QtWidgets.QFrame(self.centralwidget) self.frm_rpm.setFrameShape(QtWidgets.QFrame.Panel) self.frm_rpm.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_rpm.setLineWidth(2) self.frm_rpm.setObjectName("frm_rpm") self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.frm_rpm) self.verticalLayout_4.setContentsMargins(1, 1, 1, 1) self.verticalLayout_4.setSpacing(2) self.verticalLayout_4.setObjectName("verticalLayout_4") self.label_9 = QtWidgets.QLabel(self.frm_rpm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_9.sizePolicy().hasHeightForWidth()) self.label_9.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(12) self.label_9.setFont(font) self.label_9.setAlignment(QtCore.Qt.AlignCenter) self.label_9.setObjectName("label_9") self.verticalLayout_4.addWidget(self.label_9) self.lbl_brpm = QtWidgets.QLabel(self.frm_rpm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_brpm.sizePolicy().hasHeightForWidth()) self.lbl_brpm.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) font.setWeight(75) self.lbl_brpm.setFont(font) self.lbl_brpm.setAlignment(QtCore.Qt.AlignCenter) self.lbl_brpm.setObjectName("lbl_brpm") self.verticalLayout_4.addWidget(self.lbl_brpm) self.lbl_mp3 = QtWidgets.QLabel(self.frm_rpm) self.lbl_mp3.setText("") self.lbl_mp3.setObjectName("lbl_mp3") self.verticalLayout_4.addWidget(self.lbl_mp3) self.horizontalLayout.addWidget(self.frm_rpm) self.frm_mf = QtWidgets.QFrame(self.centralwidget) self.frm_mf.setFrameShape(QtWidgets.QFrame.Panel) self.frm_mf.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_mf.setLineWidth(2) self.frm_mf.setObjectName("frm_mf") self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.frm_mf) self.verticalLayout_6.setContentsMargins(1, 1, 1, 1) self.verticalLayout_6.setSpacing(2) self.verticalLayout_6.setObjectName("verticalLayout_6") self.label_13 = QtWidgets.QLabel(self.frm_mf) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_13.sizePolicy().hasHeightForWidth()) self.label_13.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(12) self.label_13.setFont(font) self.label_13.setAlignment(QtCore.Qt.AlignCenter) self.label_13.setObjectName("label_13") self.verticalLayout_6.addWidget(self.label_13) self.lbl_current_fl = QtWidgets.QLabel(self.frm_mf) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_current_fl.sizePolicy().hasHeightForWidth()) self.lbl_current_fl.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) font.setWeight(75) self.lbl_current_fl.setFont(font) self.lbl_current_fl.setAlignment(QtCore.Qt.AlignCenter) self.lbl_current_fl.setObjectName("lbl_current_fl") self.verticalLayout_6.addWidget(self.lbl_current_fl) self.lbl_mf = QtWidgets.QLabel(self.frm_mf) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_mf.sizePolicy().hasHeightForWidth()) self.lbl_mf.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(9) self.lbl_mf.setFont(font) self.lbl_mf.setAlignment(QtCore.Qt.AlignCenter) self.lbl_mf.setObjectName("lbl_mf") self.verticalLayout_6.addWidget(self.lbl_mf) self.horizontalLayout.addWidget(self.frm_mf) self.frm_fio2 = QtWidgets.QFrame(self.centralwidget) self.frm_fio2.setFrameShape(QtWidgets.QFrame.Panel) self.frm_fio2.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_fio2.setLineWidth(2) self.frm_fio2.setObjectName("frm_fio2") self.verticalLayout_7 = QtWidgets.QVBoxLayout(self.frm_fio2) self.verticalLayout_7.setContentsMargins(1, 1, 1, 1) self.verticalLayout_7.setSpacing(2) self.verticalLayout_7.setObjectName("verticalLayout_7") self.label_15 = QtWidgets.QLabel(self.frm_fio2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_15.sizePolicy().hasHeightForWidth()) self.label_15.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(12) self.label_15.setFont(font) self.label_15.setAlignment(QtCore.Qt.AlignCenter) self.label_15.setObjectName("label_15") self.verticalLayout_7.addWidget(self.label_15) self.lbl_current_fio2 = QtWidgets.QLabel(self.frm_fio2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_current_fio2.sizePolicy().hasHeightForWidth()) self.lbl_current_fio2.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) font.setWeight(75) self.lbl_current_fio2.setFont(font) self.lbl_current_fio2.setAlignment(QtCore.Qt.AlignCenter) self.lbl_current_fio2.setObjectName("lbl_current_fio2") self.verticalLayout_7.addWidget(self.lbl_current_fio2) self.lbl_fio2 = QtWidgets.QLabel(self.frm_fio2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_fio2.sizePolicy().hasHeightForWidth()) self.lbl_fio2.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(9) self.lbl_fio2.setFont(font) self.lbl_fio2.setAlignment(QtCore.Qt.AlignCenter) self.lbl_fio2.setObjectName("lbl_fio2") self.verticalLayout_7.addWidget(self.lbl_fio2) self.horizontalLayout.addWidget(self.frm_fio2) self.frm_tvm = QtWidgets.QFrame(self.centralwidget) self.frm_tvm.setFrameShape(QtWidgets.QFrame.Panel) self.frm_tvm.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_tvm.setLineWidth(2) self.frm_tvm.setObjectName("frm_tvm") self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.frm_tvm) self.verticalLayout_5.setContentsMargins(1, 1, 1, 1) self.verticalLayout_5.setSpacing(2) self.verticalLayout_5.setObjectName("verticalLayout_5") self.label_11 = QtWidgets.QLabel(self.frm_tvm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_11.sizePolicy().hasHeightForWidth()) self.label_11.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(12) self.label_11.setFont(font) self.label_11.setAlignment(QtCore.Qt.AlignCenter) self.label_11.setObjectName("label_11") self.verticalLayout_5.addWidget(self.label_11) self.lbl_current_tvm = QtWidgets.QLabel(self.frm_tvm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_current_tvm.sizePolicy().hasHeightForWidth()) self.lbl_current_tvm.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) font.setWeight(75) self.lbl_current_tvm.setFont(font) self.lbl_current_tvm.setAlignment(QtCore.Qt.AlignCenter) self.lbl_current_tvm.setObjectName("lbl_current_tvm") self.verticalLayout_5.addWidget(self.lbl_current_tvm) self.lbl_tvm = QtWidgets.QLabel(self.frm_tvm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_tvm.sizePolicy().hasHeightForWidth()) self.lbl_tvm.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(9) self.lbl_tvm.setFont(font) self.lbl_tvm.setAlignment(QtCore.Qt.AlignCenter) self.lbl_tvm.setObjectName("lbl_tvm") self.verticalLayout_5.addWidget(self.lbl_tvm) self.horizontalLayout.addWidget(self.frm_tvm) self.verticalLayout_9.addLayout(self.horizontalLayout) self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.layout_flow = QtWidgets.QHBoxLayout() self.layout_flow.setSpacing(0) self.layout_flow.setObjectName("layout_flow") self.lbl_plot_bottom_title = VerticalLabel(self.centralwidget) self.lbl_plot_bottom_title.setMaximumSize(QtCore.QSize(15, 16777215)) font = QtGui.QFont() font.setPointSize(9) font.setBold(True) font.setWeight(75) self.lbl_plot_bottom_title.setFont(font) self.lbl_plot_bottom_title.setFrameShape(QtWidgets.QFrame.NoFrame) self.lbl_plot_bottom_title.setAlignment(QtCore.Qt.AlignCenter) self.lbl_plot_bottom_title.setObjectName("lbl_plot_bottom_title") self.layout_flow.addWidget(self.lbl_plot_bottom_title) self.f_widget = LayoutWidget(self.centralwidget) font = QtGui.QFont() font.setPointSize(9) self.f_widget.setFont(font) self.f_widget.setObjectName("f_widget") self.layout_flow.addWidget(self.f_widget) self.gridLayout.addLayout(self.layout_flow, 1, 0, 1, 1) self.layout_pressure = QtWidgets.QHBoxLayout() self.layout_pressure.setSpacing(0) self.layout_pressure.setObjectName("layout_pressure") self.lbl_plot_top_title = VerticalLabel(self.centralwidget) self.lbl_plot_top_title.setMaximumSize(QtCore.QSize(15, 16777215)) font = QtGui.QFont() font.setPointSize(9) font.setBold(True) font.setWeight(75) self.lbl_plot_top_title.setFont(font) self.lbl_plot_top_title.setAlignment(QtCore.Qt.AlignCenter) self.lbl_plot_top_title.setObjectName("lbl_plot_top_title") self.layout_pressure.addWidget(self.lbl_plot_top_title) self.p_widget = LayoutWidget(self.centralwidget) font = QtGui.QFont() font.setPointSize(9) self.p_widget.setFont(font) self.p_widget.setObjectName("p_widget") self.layout_pressure.addWidget(self.p_widget) self.gridLayout.addLayout(self.layout_pressure, 0, 0, 1, 1) self.verticalLayout_9.addLayout(self.gridLayout) spacerItem = QtWidgets.QSpacerItem(20, 5, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) self.verticalLayout_9.addItem(spacerItem) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.frm_gscale = QtWidgets.QFrame(self.centralwidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frm_gscale.sizePolicy().hasHeightForWidth()) self.frm_gscale.setSizePolicy(sizePolicy) self.frm_gscale.setMinimumSize(QtCore.QSize(135, 0)) font = QtGui.QFont() font.setPointSize(12) self.frm_gscale.setFont(font) self.frm_gscale.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frm_gscale.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_gscale.setObjectName("frm_gscale") self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.frm_gscale) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.label_19 = QtWidgets.QLabel(self.frm_gscale) font = QtGui.QFont() font.setPointSize(14) self.label_19.setFont(font) self.label_19.setObjectName("label_19") self.horizontalLayout_4.addWidget(self.label_19) self.lbl_gscale = QtWidgets.QLabel(self.frm_gscale) font = QtGui.QFont() font.setPointSize(14) self.lbl_gscale.setFont(font) self.lbl_gscale.setTextFormat(QtCore.Qt.PlainText) self.lbl_gscale.setObjectName("lbl_gscale") self.horizontalLayout_4.addWidget(self.lbl_gscale) self.horizontalLayout_2.addWidget(self.frm_gscale) self.frm_op_mode = QtWidgets.QFrame(self.centralwidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frm_op_mode.sizePolicy().hasHeightForWidth()) self.frm_op_mode.setSizePolicy(sizePolicy) self.frm_op_mode.setMinimumSize(QtCore.QSize(20, 0)) self.frm_op_mode.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frm_op_mode.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_op_mode.setObjectName("frm_op_mode") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.frm_op_mode) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.lbl_mp0 = QtWidgets.QLabel(self.frm_op_mode) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_mp0.sizePolicy().hasHeightForWidth()) self.lbl_mp0.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(14) self.lbl_mp0.setFont(font) self.lbl_mp0.setObjectName("lbl_mp0") self.horizontalLayout_3.addWidget(self.lbl_mp0) self.lbl_op_mode = QtWidgets.QLabel(self.frm_op_mode) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lbl_op_mode.sizePolicy().hasHeightForWidth()) self.lbl_op_mode.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(14) self.lbl_op_mode.setFont(font) self.lbl_op_mode.setObjectName("lbl_op_mode") self.horizontalLayout_3.addWidget(self.lbl_op_mode) self.horizontalLayout_2.addWidget(self.frm_op_mode) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem1) self.frm_start_stop = QtWidgets.QFrame(self.centralwidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frm_start_stop.sizePolicy().hasHeightForWidth()) self.frm_start_stop.setSizePolicy(sizePolicy) self.frm_start_stop.setMinimumSize(QtCore.QSize(120, 0)) self.frm_start_stop.setMaximumSize(QtCore.QSize(120, 16777215)) self.frm_start_stop.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frm_start_stop.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_start_stop.setObjectName("frm_start_stop") self.verticalLayout = QtWidgets.QVBoxLayout(self.frm_start_stop) self.verticalLayout.setObjectName("verticalLayout") self.label_6 = QtWidgets.QLabel(self.frm_start_stop) font = QtGui.QFont() font.setPointSize(14) self.label_6.setFont(font) self.label_6.setAlignment(QtCore.Qt.AlignCenter) self.label_6.setObjectName("label_6") self.verticalLayout.addWidget(self.label_6) self.horizontalLayout_2.addWidget(self.frm_start_stop) spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem2) self.frm_pant_bloq = QtWidgets.QFrame(self.centralwidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frm_pant_bloq.sizePolicy().hasHeightForWidth()) self.frm_pant_bloq.setSizePolicy(sizePolicy) self.frm_pant_bloq.setMinimumSize(QtCore.QSize(50, 0)) self.frm_pant_bloq.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frm_pant_bloq.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_pant_bloq.setObjectName("frm_pant_bloq") self.verticalLayout_14 = QtWidgets.QVBoxLayout(self.frm_pant_bloq) self.verticalLayout_14.setObjectName("verticalLayout_14") self.lbl_mp5 = QtWidgets.QLabel(self.frm_pant_bloq) font = QtGui.QFont() font.setPointSize(14) font.setItalic(False) self.lbl_mp5.setFont(font) self.lbl_mp5.setObjectName("lbl_mp5") self.verticalLayout_14.addWidget(self.lbl_mp5) self.horizontalLayout_2.addWidget(self.frm_pant_bloq) spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem3) self.frm_config = QtWidgets.QFrame(self.centralwidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frm_config.sizePolicy().hasHeightForWidth()) self.frm_config.setSizePolicy(sizePolicy) self.frm_config.setMinimumSize(QtCore.QSize(50, 0)) self.frm_config.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frm_config.setFrameShadow(QtWidgets.QFrame.Raised) self.frm_config.setObjectName("frm_config") self.verticalLayout_15 = QtWidgets.QVBoxLayout(self.frm_config) self.verticalLayout_15.setObjectName("verticalLayout_15") self.lbl_config = QtWidgets.QLabel(self.frm_config) font = QtGui.QFont() font.setPointSize(14) font.setItalic(False) self.lbl_config.setFont(font) self.lbl_config.setObjectName("lbl_config") self.verticalLayout_15.addWidget(self.lbl_config) self.horizontalLayout_2.addWidget(self.frm_config) self.verticalLayout_9.addLayout(self.horizontalLayout_2) MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self, manager, name, log_sub): dockarea.Dock.__init__(self, name, label="Log") self.setMinimumSize(QtCore.QSize(720, 250)) grid = LayoutWidget() self.addWidget(grid) grid.addWidget(QtGui.QLabel("Minimum level: "), 0, 0) self.filter_level = QtGui.QComboBox() self.filter_level.addItems(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]) self.filter_level.setToolTip("Display entries at or above this level") grid.addWidget(self.filter_level, 0, 1) self.filter_level.currentIndexChanged.connect(self.filter_level_changed) self.filter_freetext = QtGui.QLineEdit() self.filter_freetext.setPlaceholderText("freetext filter...") self.filter_freetext.editingFinished.connect(self.filter_freetext_changed) grid.addWidget(self.filter_freetext, 0, 2) scrollbottom = QtGui.QToolButton() scrollbottom.setToolTip("Scroll to bottom") scrollbottom.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_ArrowDown)) grid.addWidget(scrollbottom, 0, 3) scrollbottom.clicked.connect(self.scroll_to_bottom) newdock = QtGui.QToolButton() newdock.setToolTip("Create new log dock") newdock.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_FileDialogNewFolder)) # note the lambda, the default parameter is overriden otherwise newdock.clicked.connect(lambda: manager.create_new_dock()) grid.addWidget(newdock, 0, 4) grid.layout.setColumnStretch(2, 1) self.log = QtGui.QTableView() self.log.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.log.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) self.log.horizontalHeader().setStretchLastSection(True) self.log.verticalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents) self.log.verticalHeader().hide() self.log.setHorizontalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel) self.log.setVerticalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel) self.log.setShowGrid(False) self.log.setTextElideMode(QtCore.Qt.ElideNone) grid.addWidget(self.log, 1, 0, colspan=5) self.scroll_at_bottom = False self.scroll_value = 0 log_sub.add_setmodel_callback(self.set_model)
def load_flash_file(): """Load a FLASH file for preview """ loader = FileLoader() if loader.load_flash(): model_content = open(loader.file, "r") model = literal_eval(model_content.read()) model_content.close() PREVIEWER.model = model PREVIEWER.generate_model(0) PREVIEWER.generate_model(1) #Layout for file options FILE_OPT_LAYOUT = LayoutWidget() FILE_OPT_GEN_BUTTON = QtGui.QPushButton('Generate FLASH Model') FILE_OPT_LOAD_BUTTON = QtGui.QPushButton('Load FLASH Model') FILE_OPT_GEN_LABEL = QtGui.QLabel() FILE_OPT_GEN_LABEL.setText( "Creates a FLASH file from an text-based instruction file.\n\n\n") FILE_OPT_LOAD_LABEL = QtGui.QLabel() FILE_OPT_LOAD_LABEL.setText( "Load a FLASH file to be displayed in the preview windows.\n\n\n") FILE_OPT_GEN_BUTTON.clicked.connect(generate_flash_file) FILE_OPT_LOAD_BUTTON.clicked.connect(load_flash_file) FILE_OPT_LAYOUT.addWidget(FILE_OPT_GEN_BUTTON, row=0, col=0) FILE_OPT_LAYOUT.addWidget(FILE_OPT_GEN_LABEL, row=1, col=0) FILE_OPT_LAYOUT.addWidget(FILE_OPT_LOAD_BUTTON, row=2, col=0)
def __init__(self, main_window, status_bar, explist_sub, schedule_sub, schedule_ctl, repository_ctl): dockarea.Dock.__init__(self, "Explorer", size=(1500, 500)) self.main_window = main_window self.status_bar = status_bar self.schedule_sub = schedule_sub self.schedule_ctl = schedule_ctl self.splitter = QtGui.QSplitter(QtCore.Qt.Horizontal) self.addWidget(self.splitter) grid = LayoutWidget() self.splitter.addWidget(grid) self.el = QtGui.QTreeView() self.el.setHeaderHidden(True) self.el.setSelectionBehavior(QtGui.QAbstractItemView.SelectItems) self.el.selectionChanged = self._selection_changed self.selected_key = None grid.addWidget(self.el, 0, 0, colspan=4) self.datetime = QtGui.QDateTimeEdit() self.datetime.setDisplayFormat("MMM d yyyy hh:mm:ss") self.datetime.setDate(QtCore.QDate.currentDate()) self.datetime.dateTimeChanged.connect(self.enable_duedate) self.datetime_en = QtGui.QCheckBox("Due date:") grid.addWidget(self.datetime_en, 1, 0, colspan=2) grid.addWidget(self.datetime, 1, 2, colspan=2) self.pipeline = QtGui.QLineEdit() self.pipeline.setText("main") grid.addWidget(QtGui.QLabel("Pipeline:"), 2, 0, colspan=2) grid.addWidget(self.pipeline, 2, 2, colspan=2) self.priority = QtGui.QSpinBox() self.priority.setRange(-99, 99) grid.addWidget(QtGui.QLabel("Priority:"), 3, 0) grid.addWidget(self.priority, 3, 1) self.flush = QtGui.QCheckBox("Flush") self.flush.setToolTip("Flush the pipeline before starting the experiment") grid.addWidget(self.flush, 3, 2) self.log_level = QtGui.QComboBox() self.log_level.addItems(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]) self.log_level.setCurrentIndex(1) self.log_level.setToolTip("Minimum level for log entry production") grid.addWidget(self.log_level, 3, 3) submit = QtGui.QPushButton("Submit") submit.setToolTip("Schedule the selected experiment (Ctrl+Return)") grid.addWidget(submit, 4, 0, colspan=4) submit.clicked.connect(self.submit_clicked) self.argeditor = _ArgumentEditor(self.main_window) self.splitter.addWidget(self.argeditor) self.splitter.setSizes([grid.minimumSizeHint().width(), 1000]) self.argeditor_states = dict() self.explist_model = Model(dict()) explist_sub.add_setmodel_callback(self.set_model) self.shortcuts = ShortcutManager(self.main_window, self) self.el.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) submit_action = QtGui.QAction("Submit", self.el) submit_action.triggered.connect(self.submit_clicked) submit_action.setShortcut("CTRL+RETURN") self.el.addAction(submit_action) reqterm_action = QtGui.QAction("Request termination of instances", self.el) reqterm_action.triggered.connect(self.request_inst_term) reqterm_action.setShortcut("CTRL+BACKSPACE") self.el.addAction(reqterm_action) sep = QtGui.QAction(self.el) sep.setSeparator(True) self.el.addAction(sep) edit_shortcuts_action = QtGui.QAction("Edit shortcuts", self.el) edit_shortcuts_action.triggered.connect(self.edit_shortcuts) self.el.addAction(edit_shortcuts_action) scan_repository_action = QtGui.QAction("(Re)scan repository HEAD", self.el) def scan_repository(): asyncio.ensure_future(repository_ctl.scan_async()) self.status_bar.showMessage("Requested repository scan") scan_repository_action.triggered.connect(scan_repository) self.el.addAction(scan_repository_action)
def __init__(self, dialog_parent, status_bar, schedule_ctl): dockarea.Dock.__init__(self, "Explorer", size=(1500, 500)) self.dialog_parent = dialog_parent self.status_bar = status_bar self.schedule_ctl = schedule_ctl self.splitter = QtGui.QSplitter(QtCore.Qt.Horizontal) self.addWidget(self.splitter) grid = LayoutWidget() self.splitter.addWidget(grid) self.el = QtGui.QListView() self.el.selectionChanged = self._selection_changed self.selected_key = None grid.addWidget(self.el, 0, 0, colspan=4) self.datetime = QtGui.QDateTimeEdit() self.datetime.setDisplayFormat("MMM d yyyy hh:mm:ss") self.datetime.setDate(QtCore.QDate.currentDate()) self.datetime.dateTimeChanged.connect(self.enable_duedate) self.datetime_en = QtGui.QCheckBox("Due date:") grid.addWidget(self.datetime_en, 1, 0, colspan=2) grid.addWidget(self.datetime, 1, 2, colspan=2) self.pipeline = QtGui.QLineEdit() self.pipeline.setText("main") grid.addWidget(QtGui.QLabel("Pipeline:"), 2, 0, colspan=2) grid.addWidget(self.pipeline, 2, 2, colspan=2) self.priority = QtGui.QSpinBox() self.priority.setRange(-99, 99) grid.addWidget(QtGui.QLabel("Priority:"), 3, 0) grid.addWidget(self.priority, 3, 1) self.flush = QtGui.QCheckBox("Flush") self.flush.setToolTip("Flush the pipeline before starting the experiment") grid.addWidget(self.flush, 3, 2) self.log_level = QtGui.QComboBox() for item in "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL": self.log_level.addItem(item) self.log_level.setCurrentIndex(1) self.log_level.setToolTip("Minimum level for log entry production") grid.addWidget(self.log_level, 3, 3) submit = QtGui.QPushButton("Submit") submit.setShortcut("CTRL+RETURN") submit.setToolTip("Schedule the selected experiment (CTRL+ENTER)") grid.addWidget(submit, 4, 0, colspan=4) submit.clicked.connect(self.submit_clicked) self.argeditor = _ArgumentEditor(self.dialog_parent) self.splitter.addWidget(self.argeditor) self.splitter.setSizes([grid.minimumSizeHint().width(), 1000]) self.state = dict()