class CObjectCreateToolPanel(CDockableEditor): def __init__(self, parent=None): super().__init__(parent) self.stacked = QStackedLayout() label = QLabel() label.setText("CObjectCreateToolPanel") self.stacked.addWidget(label) self.stacked.setAlignment(label, Qt.AlignTop) self.setContent(self.stacked) def sizeHint(self): return QSize(300, 400)
def __init__(self, parent, title="Title", width=500, height=180): self.parent = parent self.dragPosition = None self.width = width self.height = height super().__init__(parent) self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground) self.gap = 10 self.center(self.width + self.gap, self.height + self.gap) self.setAcceptDrops(True) layout = QVBoxLayout() layout.setSpacing(0) layout.setAlignment(Qt.AlignTop) layout.setContentsMargins(0, 0, 0, 0) # Title title = QLabel(title) title.setObjectName('title') def trigger_close(_): self.close() close_btn = Builder().text('x').name('close_btn').click( trigger_close).build() header = QHBoxLayout() header.addWidget(title) header.addStretch(1) header.addWidget(close_btn) self.close_btn = close_btn dlgHeader = QFrame() dlgHeader.setObjectName('header') dlgHeader.setMaximumWidth(width) dlgHeader.setLayout(header) layout.addWidget(dlgHeader) widget = QWidget(self) self.main = self.ui(widget) widget.setObjectName('main') widget.setLayout(self.main) widget.setMaximumWidth(width) layout.addWidget(widget) _main = QWidget() _main.setContentsMargins(0, 0, 0, 10) _main.setLayout(layout) _main.setStyleSheet(self.style()) _main.setWindowOpacity(0.5) _main_layout = QStackedLayout() _main_layout.setContentsMargins(20, 20, 20, 20) _main_layout.setAlignment(Qt.AlignCenter) _main_layout.setStackingMode(QStackedLayout.StackAll) _backgound = QFrame() _backgound.setMinimumWidth(width) _backgound.setMinimumHeight(height) _backgound.setMaximumWidth(width) _backgound.setMaximumHeight(height) _backgound.setStyleSheet("background: #fafafa; border-radius:5px;") if not app.is_windows(): _main_layout.addWidget(_backgound) _main_layout.addWidget(_main) self.setLayout(_main_layout) self.effect = QGraphicsDropShadowEffect(_backgound) self.effect.setOffset(0, 0) self.effect.setBlurRadius(30) # self.effect.setEnabled(False) _backgound.setGraphicsEffect(self.effect)
class UdpPanel(QWidget): START_BUTTON_INDEX = 0 PAUSE_BUTTON_INDEX = 1 def __init__(self, parent): super().__init__(parent) self.initUI() def initUI(self): self.centralFrame = QFrame(self) self.centralFrame.setFrameShape(QFrame.NoFrame) self.centralFrame.setFrameShadow(QFrame.Raised) self.centralFrame.setContentsMargins(0, 0, 0, 0) self.centralFrame.setStyleSheet("background-color: rgb(27, 29, 35);" "border: none;") self.contentFrame = QFrame(self.centralFrame) self.contentFrame.setFrameShape(QFrame.NoFrame) self.contentFrame.setFrameShadow(QFrame.Raised) self.contentFrame.setContentsMargins(0, 0, 0, 0) self.contentFrame.setStyleSheet("border: none;") self.udpFrame = QFrame(self.contentFrame) self.udpFrame.setFrameShape(QFrame.NoFrame) self.udpFrame.setFrameShadow(QFrame.Raised) self.udpFrame.setContentsMargins(0, 0, 0, 0) self.measurementsFrame = QFrame(self.udpFrame) self.measurementsFrame.setFrameShape(QFrame.NoFrame) self.measurementsFrame.setFrameShadow(QFrame.Raised) self.measurementsFrame.setContentsMargins(0, 0, 0, 0) self.measurementsFrame.setStyleSheet("border: none;") self.measurementsPanel = MeasurementsPanel(self.measurementsFrame) self.activeMeasurements = self.measurementsPanel.activeMeasurements self.addBtn = self.measurementsPanel.addBtn self.removeBtn = self.measurementsPanel.removeBtn self.measurementsLayout = QVBoxLayout(self.measurementsFrame) self.measurementsLayout.addWidget(self.measurementsPanel) self.measurementsLayout.setContentsMargins(0, 0, 0, 0) self.configurationFrame = QFrame(self.udpFrame) self.configurationFrame.setFrameShape(QFrame.NoFrame) self.configurationFrame.setFrameShadow(QFrame.Raised) self.configurationFrame.setContentsMargins(0, 0, 0, 0) self.configurationFrame.setStyleSheet("background: rgb(15,15,15);" "border: 1px solid gray;" "border-radius: 5px;") self.networkingFrame = QFrame(self.contentFrame) self.networkingFrame.setFrameShape(QFrame.NoFrame) self.networkingFrame.setFrameShadow(QFrame.Raised) self.networkingFrame.setContentsMargins(0, 0, 0, 0) self.networkingFrame.setStyleSheet("border: none;") self.ipAddressFrame = QFrame(self.networkingFrame) self.ipAddressFrame.setFrameShape(QFrame.NoFrame) self.ipAddressFrame.setFrameShadow(QFrame.Raised) self.ipAddressFrame.setContentsMargins(0, 0, 0, 0) self.ipAddressFrame.setStyleSheet("border: none;") self.ipAddressField = LineEdit(self.ipAddressFrame) self.ipAddressField.setInputMask("000.000.000.000;_") self.ipAddressLabel = Label(self.ipAddressFrame) self.ipAddressLabel.setText("IP Address: ") self.ipAddressLayout = QHBoxLayout(self.ipAddressFrame) self.ipAddressLayout.addWidget(self.ipAddressLabel, alignment=Qt.AlignRight | Qt.AlignVCenter) self.ipAddressLayout.addWidget(self.ipAddressField, alignment=Qt.AlignLeft | Qt.AlignVCenter) self.ipAddressLayout.setContentsMargins(0, 0, 0, 0) self.portFrame = QFrame(self.networkingFrame) self.portFrame.setFrameShape(QFrame.NoFrame) self.portFrame.setFrameShadow(QFrame.Raised) self.portFrame.setContentsMargins(0, 0, 0, 0) self.portFrame.setStyleSheet("border: none;") self.portField = LineEdit(self.portFrame) self.portField.setStyleSheet("QLineEdit{ " "border-width: 1px; " "border-style: solid; " "border-color: none none white none;" "border-radius: none" "}") self.portLabel = Label(self.portFrame) self.portLabel.setText("Port: ") self.portLayout = QHBoxLayout(self.portFrame) self.portLayout.addWidget(self.portLabel, alignment=Qt.AlignRight | Qt.AlignVCenter) self.portLayout.addWidget(self.portField, alignment=Qt.AlignLeft | Qt.AlignVCenter) self.portLayout.setContentsMargins(0, 0, 0, 0) self.networkingLayout = QHBoxLayout(self.networkingFrame) self.networkingLayout.addWidget(self.ipAddressFrame) self.networkingLayout.addWidget(self.portFrame) self.networkingLayout.setContentsMargins(0, 0, 0, 0) self.networkingLayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.controlsFrame = QFrame(self.configurationFrame) self.controlsFrame.setFrameShape(QFrame.NoFrame) self.controlsFrame.setFrameShadow(QFrame.Raised) self.controlsFrame.setContentsMargins(0, 0, 0, 0) self.controlsFrame.setStyleSheet("border: none;") self.runBtnsFrame = QFrame(self.controlsFrame) self.runBtnsFrame.setFrameShape(QFrame.NoFrame) self.runBtnsFrame.setFrameShadow(QFrame.Raised) self.runBtnsFrame.setContentsMargins(0, 0, 0, 0) self.runBtnsFrame.setStyleSheet("border: none;") self.startBtn = PushButton(self.runBtnsFrame) self.startBtn.setIcon(QIcon(resource_path("icons/cil-media-play"))) self.pauseBtn = PushButton(self.runBtnsFrame) self.pauseBtn.setIcon(QIcon(resource_path("icons/cil-media-pause"))) self.runBtnsLayout = QStackedLayout(self.runBtnsFrame) self.runBtnsLayout.addWidget(self.startBtn) self.runBtnsLayout.addWidget(self.pauseBtn) self.runBtnsLayout.setContentsMargins(0, 0, 0, 0) self.runBtnsLayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.runBtnsLayout.setCurrentIndex(self.START_BUTTON_INDEX) self.stopBtnFrame = QFrame(self.controlsFrame) self.stopBtnFrame.setFrameShape(QFrame.NoFrame) self.stopBtnFrame.setFrameShadow(QFrame.Raised) self.stopBtnFrame.setContentsMargins(0, 0, 0, 0) self.stopBtnFrame.setStyleSheet("border: none;") self.stopBtn = PushButton(self.stopBtnFrame) self.stopBtn.setIcon(QIcon(resource_path("icons/cil-media-stop"))) self.stopBtnLayout = QStackedLayout(self.stopBtnFrame) self.stopBtnLayout.addWidget(self.stopBtn) self.stopBtnLayout.setContentsMargins(0, 0, 0, 0) self.stopBtnLayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.controlsLayout = QHBoxLayout(self.controlsFrame) self.controlsLayout.addWidget(self.runBtnsFrame, alignment=Qt.AlignRight) self.controlsLayout.addWidget(self.stopBtnFrame, alignment=Qt.AlignRight) self.controlsLayout.setContentsMargins(0, 0, 0, 0) self.controlsLayout.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.configurationLayout = QHBoxLayout(self.configurationFrame) self.configurationLayout.addWidget(self.networkingFrame, alignment=Qt.AlignLeft) self.configurationLayout.addWidget(self.controlsFrame, alignment=Qt.AlignRight) self.configurationLayout.setContentsMargins(10, 10, 10, 10) self.configurationLayout.setAlignment(Qt.AlignVCenter) self.udpLayout = QVBoxLayout(self.udpFrame) self.udpLayout.addWidget(self.measurementsFrame) self.udpLayout.addWidget(self.configurationFrame) self.udpLayout.setContentsMargins(10, 10, 10, 10) self.udpLayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.contentLayout = QVBoxLayout(self.contentFrame) self.contentLayout.addWidget(self.udpFrame, alignment=Qt.AlignTop) self.contentLayout.setContentsMargins(0, 0, 0, 0) self.contentLayout.setAlignment(Qt.AlignTop) self.centralLayout = QHBoxLayout(self.centralFrame) self.centralLayout.addWidget(self.contentFrame) self.centralLayout.setContentsMargins(0, 0, 0, 0) self.uiLayout = QHBoxLayout(self) self.uiLayout.addWidget(self.centralFrame) self.uiLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.uiLayout) self.setContentsMargins(0, 0, 0, 0)
class CSVPanel(QWidget): START_BUTTON_INDEX = 0 PAUSE_BUTTON_INDEX = 1 def __init__(self, parent): super().__init__(parent) self.initUI() def initUI(self): self.centralFrame = QFrame(self) self.centralFrame.setFrameShape(QFrame.NoFrame) self.centralFrame.setFrameShadow(QFrame.Raised) self.centralFrame.setContentsMargins(0, 0, 0, 0) self.centralFrame.setStyleSheet("background-color: rgb(27, 29, 35);" "border: none;") self.contentFrame = QFrame(self.centralFrame) self.contentFrame.setFrameShape(QFrame.NoFrame) self.contentFrame.setFrameShadow(QFrame.Raised) self.contentFrame.setContentsMargins(0, 0, 0, 0) self.contentFrame.setStyleSheet("border: none;") self.csvFrame = QFrame(self.contentFrame) self.csvFrame.setFrameShape(QFrame.NoFrame) self.csvFrame.setFrameShadow(QFrame.Raised) self.csvFrame.setContentsMargins(0, 0, 0, 0) self.measurementsFrame = QFrame(self.csvFrame) self.measurementsFrame.setFrameShape(QFrame.NoFrame) self.measurementsFrame.setFrameShadow(QFrame.Raised) self.measurementsFrame.setContentsMargins(0, 0, 0, 0) self.measurementsFrame.setStyleSheet("border: none;") self.measurementsPanel = MeasurementsPanel(self.measurementsFrame) self.activeMeasurements = self.measurementsPanel.activeMeasurements self.addBtn = self.measurementsPanel.addBtn self.removeBtn = self.measurementsPanel.removeBtn self.measurementsLayout = QVBoxLayout(self.measurementsFrame) self.measurementsLayout.addWidget(self.measurementsPanel) self.measurementsLayout.setContentsMargins(0, 0, 0, 0) self.configurationFrame = QFrame(self.csvFrame) self.configurationFrame.setFrameShape(QFrame.NoFrame) self.configurationFrame.setFrameShadow(QFrame.Raised) self.configurationFrame.setContentsMargins(0, 0, 0, 0) self.configurationFrame.setStyleSheet("background: rgb(15,15,15);" "border: 1px solid gray;" "border-radius: 5px;") self.saveFrame = QFrame(self.configurationFrame) self.saveFrame.setFrameShape(QFrame.NoFrame) self.saveFrame.setFrameShadow(QFrame.Raised) self.saveFrame.setContentsMargins(0, 0, 0, 0) self.saveFrame.setStyleSheet("border: none;") self.saveLabelFrame = QFrame(self.saveFrame) self.saveLabelFrame.setFrameShape(QFrame.NoFrame) self.saveLabelFrame.setFrameShadow(QFrame.Raised) self.saveLabelFrame.setContentsMargins(0, 0, 0, 0) self.saveLabel = Label(self.saveLabelFrame) self.saveLabel.setText("File: ") self.saveLabelLayout = QHBoxLayout(self.saveLabelFrame) self.saveLabelLayout.addWidget(self.saveLabel) self.saveLabelLayout.setContentsMargins(0, 0, 0, 0) self.saveFieldFrame = QFrame(self.saveFrame) self.saveFieldFrame.setFrameShape(QFrame.NoFrame) self.saveFieldFrame.setFrameShadow(QFrame.Raised) self.saveFieldFrame.setContentsMargins(0, 0, 0, 0) self.saveFieldFrame.setStyleSheet("border: none;") self.saveField = LineEdit(self.saveFieldFrame) self.saveFieldLayout = QHBoxLayout(self.saveFieldFrame) self.saveFieldLayout.addWidget(self.saveField) self.saveFieldLayout.setContentsMargins(0, 0, 0, 0) self.saveBtnFrame = QFrame(self.saveFrame) self.saveBtnFrame.setFrameShape(QFrame.NoFrame) self.saveBtnFrame.setFrameShadow(QFrame.Raised) self.saveBtnFrame.setContentsMargins(0, 0, 0, 0) self.saveBtnFrame.setStyleSheet("border: none;") self.saveBtn = PushButton(self.saveBtnFrame) self.saveBtn.setIcon(QIcon(resource_path("icons/ellipsis"))) self.saveBtn.setIconSize(QSize(20, 20)) self.saveBtnLayout = QHBoxLayout(self.saveBtnFrame) self.saveBtnLayout.addWidget(self.saveBtn) self.saveBtnLayout.setContentsMargins(0, 0, 0, 0) self.saveDialog = SaveDialog() self.saveLayout = QHBoxLayout(self.saveFrame) self.saveLayout.addWidget(self.saveLabelFrame) self.saveLayout.addWidget(self.saveFieldFrame) self.saveLayout.addWidget(self.saveBtnFrame) self.saveLayout.setContentsMargins(0, 0, 0, 0) self.controlsFrame = QFrame(self.configurationFrame) self.controlsFrame.setFrameShape(QFrame.NoFrame) self.controlsFrame.setFrameShadow(QFrame.Raised) self.controlsFrame.setContentsMargins(0, 0, 0, 0) self.controlsFrame.setStyleSheet("border: none;") self.runBtnsFrame = QFrame(self.controlsFrame) self.runBtnsFrame.setFrameShape(QFrame.NoFrame) self.runBtnsFrame.setFrameShadow(QFrame.Raised) self.runBtnsFrame.setContentsMargins(0, 0, 0, 0) self.runBtnsFrame.setStyleSheet("border: none;") self.startBtn = PushButton(self.runBtnsFrame) self.startBtn.setIcon(QIcon(resource_path("icons/cil-media-play"))) self.pauseBtn = PushButton(self.runBtnsFrame) self.pauseBtn.setIcon(QIcon(resource_path("icons/cil-media-pause"))) self.runBtnsLayout = QStackedLayout(self.runBtnsFrame) self.runBtnsLayout.addWidget(self.startBtn) self.runBtnsLayout.addWidget(self.pauseBtn) self.runBtnsLayout.setContentsMargins(0, 0, 0, 0) self.runBtnsLayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.runBtnsLayout.setCurrentIndex(self.START_BUTTON_INDEX) self.stopBtnFrame = QFrame(self.controlsFrame) self.stopBtnFrame.setFrameShape(QFrame.NoFrame) self.stopBtnFrame.setFrameShadow(QFrame.Raised) self.stopBtnFrame.setContentsMargins(0, 0, 0, 0) self.stopBtnFrame.setStyleSheet("border: none;") self.stopBtn = PushButton(self.stopBtnFrame) self.stopBtn.setIcon(QIcon(resource_path("icons/cil-media-stop"))) self.stopBtnLayout = QStackedLayout(self.stopBtnFrame) self.stopBtnLayout.addWidget(self.stopBtn) self.stopBtnLayout.setContentsMargins(0, 0, 0, 0) self.stopBtnLayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.controlsLayout = QHBoxLayout(self.controlsFrame) self.controlsLayout.addWidget(self.runBtnsFrame, alignment=Qt.AlignRight) self.controlsLayout.addWidget(self.stopBtnFrame, alignment=Qt.AlignRight) self.controlsLayout.setContentsMargins(0, 0, 0, 0) self.controlsLayout.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.configurationLayout = QHBoxLayout(self.configurationFrame) self.configurationLayout.addWidget(self.saveFrame, alignment=Qt.AlignLeft) self.configurationLayout.addWidget(self.controlsFrame, alignment=Qt.AlignRight) self.configurationLayout.setContentsMargins(10, 10, 10, 10) self.configurationLayout.setAlignment(Qt.AlignVCenter) self.csvLayout = QVBoxLayout(self.csvFrame) self.csvLayout.addWidget(self.measurementsFrame) self.csvLayout.addWidget(self.configurationFrame) self.csvLayout.setContentsMargins(10, 10, 10, 10) self.csvLayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.contentLayout = QVBoxLayout(self.contentFrame) self.contentLayout.addWidget(self.csvFrame, alignment=Qt.AlignTop) self.contentLayout.setContentsMargins(0, 0, 0, 0) self.contentLayout.setAlignment(Qt.AlignTop) self.centralLayout = QHBoxLayout(self.centralFrame) self.centralLayout.addWidget(self.contentFrame) self.centralLayout.setContentsMargins(0, 0, 0, 0) self.uiLayout = QHBoxLayout(self) self.uiLayout.addWidget(self.centralFrame) self.uiLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.uiLayout) self.setContentsMargins(0, 0, 0, 0)