def __init__(self, serial_ports_usb, serial_ports_serial, urls_in_use=list(), url=None, do_connect_default=True, autoconnect_default=True, title="Add MRC", parent=None): super(AddMRCDialog, self).__init__(parent) self.urls_in_use = urls_in_use self.ui = util.loadUi(":/ui/connect_dialog.ui") layout = QtWidgets.QHBoxLayout(self) layout.addWidget(self.ui) self.setWindowTitle(title) self.ui.buttonBox.button( QtWidgets.QDialogButtonBox.Ok).setEnabled(False) self.ui.accepted.connect(self.accept) self.ui.rejected.connect(self.reject) for combo in (self.ui.combo_serial_port_usb, self.ui.combo_serial_port_serial): combo.setValidator( QtGui.QRegExpValidator(QtCore.QRegExp('.+'), None)) self.ui.le_tcp_host.setValidator( QtGui.QRegExpValidator(QtCore.QRegExp('.+'), None)) self.ui.le_mesycontrol_host.setValidator( QtGui.QRegExpValidator(QtCore.QRegExp('.+'), None)) self.ui.le_tcp_host.setText('localhost') self.ui.le_mesycontrol_host.setText('localhost') self.ui.cb_connect.setChecked(do_connect_default) self.ui.cb_autoconnect.setChecked(autoconnect_default) for port in serial_ports_usb: self.ui.combo_serial_port_usb.addItem(port) for port in serial_ports_serial: self.ui.combo_serial_port_serial.addItem(port) for le in self.ui.findChildren(QtWidgets.QLineEdit): le.textChanged.connect(self._validate_inputs) for combo in self.ui.findChildren(QtWidgets.QComboBox): combo.currentIndexChanged.connect(self._validate_inputs) combo.editTextChanged.connect(self._validate_inputs) for spin in self.ui.findChildren(QtWidgets.QSpinBox): spin.valueChanged.connect(self._validate_inputs) self.ui.stacked_widget.currentChanged.connect(self._validate_inputs) self._validate_inputs() self._result = None if url is not None: self._set_url(url)
def __init__(self, orientation=Qt.Horizontal, parent=None): super(SimpleToolBar, self).__init__(parent) self.orientation = orientation if orientation == Qt.Horizontal: self.setLayout(QtWidgets.QHBoxLayout()) else: self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setSpacing(2) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().addStretch(1)
def __init__(self, title=str(), parent=None): super(SubProgressDialog, self).__init__(parent) self.log = util.make_logging_source_adapter(__name__, self) self.ui = util.loadUi(":/ui/subprogress_widget.ui") self.setWindowTitle(title) self.setWindowIcon(util.make_icon(":/window-icon.png")) l = QtWidgets.QHBoxLayout(self) l.setContentsMargins(0, 0, 0, 0) l.setSpacing(0) l.addWidget(self.ui) self.resize(300, 100) self.ui.cancel_button.clicked.connect(self.cancel) self._reset()
def make_apply_common_button_layout(input_spinbox, tooltip, on_clicked): # Wrapper to invoke the clicked handler without the boolean arg that's # passed from QPushButton.clicked(). def _on_clicked(): on_clicked() button = QtWidgets.QPushButton(clicked=_on_clicked) button.setIcon(QtGui.QIcon(":/arrow-bottom.png")) button.setMaximumHeight(input_spinbox.sizeHint().height()) button.setMaximumWidth(16) button.setToolTip(tooltip) layout = QtWidgets.QHBoxLayout() layout.addWidget(input_spinbox) layout.addWidget(button) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(1) return (layout, button)
def __init__(self, device, parent=None): super(DeviceNotesWidget, self).__init__(parent) self.device = device device.read_mode_changed.connect(self._on_device_read_mode_changed) device.write_mode_changed.connect(self._on_device_write_mode_changed) device.extension_changed.connect(self._on_device_extension_changed) self.text_edit = NotesTextEdit() self.text_edit.setReadOnly(True) self.text_edit.modificationChanged.connect( self._on_text_edit_modification_changed) fm = self.text_edit.fontMetrics() rh = fm.lineSpacing() + DeviceNotesWidget.ADD_PIXELS_PER_ROW self.text_edit.setFixedHeight(DeviceNotesWidget.DISPLAY_ROWS * rh) layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self.text_edit) self.edit_button = QtWidgets.QPushButton(util.make_icon(":/edit.png"), str(), clicked=self._on_edit_button_clicked) self.edit_button.setToolTip("Edit Device Notes") self.edit_button.setStatusTip(self.edit_button.toolTip()) button_layout = QtWidgets.QVBoxLayout() button_layout.setContentsMargins(0, 0, 0, 0) button_layout.addWidget(self.edit_button, 0, Qt.AlignHCenter) button_layout.addStretch(1) layout.addLayout(button_layout) self._populate()
def on_actionAbout_triggered(self): try: from . import mc_version version = mc_version.version except ImportError: version = "devel version" d = QtWidgets.QDialog(self) d.setWindowTitle("About mesycontrol") license = QtWidgets.QTextBrowser(parent=d) license.setWindowFlags(Qt.Window) license.setWindowTitle("mesycontrol license") license.setText("") try: f = QtCore.QFile(":/gpl-notice.txt") if not f.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text): return license.setPlainText(str(f.readAll(), 'utf-8')) finally: f.close() l = QtWidgets.QVBoxLayout(d) logo = QtWidgets.QLabel() logo.setPixmap( QtGui.QPixmap(":/mesytec-logo.png").scaledToWidth( 300, Qt.SmoothTransformation)) l.addWidget(logo) t = "mesycontrol - %s" % version label = QtWidgets.QLabel(t) font = label.font() font.setPointSize(15) font.setBold(True) label.setFont(font) l.addWidget(label) l.addWidget(QtWidgets.QLabel("Remote control for mesytec devices.")) l.addWidget(QtWidgets.QLabel("© 2014-2022 mesytec GmbH & Co. KG")) t = '<a href="mailto:[email protected]">[email protected]</a> - <a href="http://www.mesytec.com">www.mesytec.com</a>' label = QtWidgets.QLabel(t) label.setOpenExternalLinks(True) l.addWidget(label) t = 'Running on Python %s using PySide2 %s with Qt %s.' % ( platform.python_version(), PySide2.__version__, PySide2.QtCore.__version__) l.addWidget(QtWidgets.QLabel(t)) l.addSpacing(20) bl = QtWidgets.QHBoxLayout() def license_button_clicked(): sz = license.size() sz = sz.expandedTo(QtCore.QSize(500, 300)) license.resize(sz) license.show() license.raise_() b = QtWidgets.QPushButton("&License", clicked=license_button_clicked) bl.addWidget(b) b = QtWidgets.QPushButton("&Close", clicked=d.close) b.setAutoDefault(True) b.setDefault(True) bl.addWidget(b) l.addLayout(bl) for item in (l.itemAt(i) for i in range(l.count())): item.setAlignment(Qt.AlignHCenter) w = item.widget() if isinstance(w, QtWidgets.QLabel): w.setTextInteractionFlags(Qt.TextBrowserInteraction) d.exec_()