def __init__(self, transparent): super().__init__() layout = QVBoxLayout() self.label = QLabel("Secondary Window") self.label.setStyleSheet("background:transparent;") # create transparent layout layout.addWidget(self.label) self.setLayout(layout) # self.setStyleSheet("background:white;") if transparent: self.setAttribute(Qt.WA_TranslucentBackground) else: self.setStyleSheet("background:white;") # show the window on the second screen if QDesktopWidget.screenCount(QDesktopWidget()) > 1: monitor = QDesktopWidget().screenGeometry(1) self.move(monitor.left(), monitor.top()) self.showMaximized() self.setWindowFlags(Qt.FramelessWindowHint) # to get the screen size for displayNr in range(QDesktopWidget().screenCount()): self.screen = QDesktopWidget().screenGeometry(displayNr) self.secHeight = self.screen.height() - 40 self.secWidth = self.screen.width() - 40 self.setMinimumSize(self.secWidth, self.secHeight)
def getScreenGeomtry(): pos = QCursor().pos() qdt = QDesktopWidget() for i in range(qdt.screenCount()): sgm = qdt.screen(i).geometry() bwX = pos.x() >= sgm.left() and pos.x() <= sgm.right() bwY = pos.y() >= sgm.top() and pos.y() <= sgm.bottom() if bwX and bwY: return sgm return QRect(0, 0, 0, 0)
def __init__(self): """ Constructor for the main application class. Creates the GUI and sets up the initial state. """ super().__init__() self.player_thread = threading.Thread() self.output_screen_size = 32 # Center master window self.resize(400, 200) self.center_widget(self, 0) # Create widgets self.display_widget = DisplayWidget() self.media_preview_stack = QStackedWidget() open_button = QPushButton("Open") clear_button = QPushButton("Clear") next_button = QPushButton(QIcon("next.svg"), "") previous_button = QPushButton(QIcon("previous.svg"), "") preview_label = QLabel() self.nav_widget = QWidget() self.size_widget = QWidget() self.size_checkbox = QCheckBox("Autosize") size_lineedit = QLineEdit(str(self.output_screen_size)) # Configure preview_label.setScaledContents(True) preview_label.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) open_button.setToolTip("Choose a media file to display") clear_button.setToolTip( "Clear the current media and turn off the display") size_lineedit.setInputMask("D0 \\i\\n") self.nav_widget.setEnabled(False) self.media_preview_stack.addWidget(QSvgWidget("blank.svg")) self.media_preview_stack.addWidget(preview_label) self.display_widget.setScaledContents(True) self.display_widget.setStyleSheet("background-color: rgb(20, 20, 20);") self.display_widget.closed.connect(self.close) self.size_checkbox.setChecked(True) self.size_checkbox.setEnabled(False) self.size_checkbox.setToolTip( "Use automatic screen dimensions for drawing") # Set up connections open_button.clicked.connect(self.choose_media) clear_button.clicked.connect(self.clear_media) next_button.clicked.connect(lambda: self.advance_media(1)) previous_button.clicked.connect(lambda: self.advance_media(-1)) size_lineedit.editingFinished.connect(self.size_changed) self.size_checkbox.stateChanged.connect(self.set_dimensions_visibility) # Set shortcuts makeShortcut = lambda hotkey: QShortcut( QKeySequence(hotkey), self, context=Qt.ApplicationShortcut) open_shortcut = makeShortcut("O") clear_shortcut = makeShortcut("C") close_shortcut = makeShortcut("Ctrl+Q") self.next_shortcut = makeShortcut("N") self.previous_shortcut = makeShortcut("P") self.dimensions_shortcut = makeShortcut("A") self.next_shortcut.setEnabled(False) self.previous_shortcut.setEnabled(False) self.dimensions_shortcut.setEnabled(False) open_shortcut.activated.connect(self.choose_media) clear_shortcut.activated.connect(self.clear_media) close_shortcut.activated.connect(self.close) self.next_shortcut.activated.connect(lambda: self.advance_media(1)) self.previous_shortcut.activated.connect( lambda: self.advance_media(-1)) self.dimensions_shortcut.activated.connect(self.size_checkbox.toggle) # Pack layouts vbox = QVBoxLayout() hbox = QHBoxLayout() nav_hbox = QHBoxLayout() size_hbox = QHBoxLayout() nav_hbox.addWidget(previous_button) nav_hbox.addWidget(next_button) size_hbox.addWidget(QLabel("Size:")) size_hbox.addWidget(size_lineedit) vbox.addWidget(open_button) vbox.addWidget(clear_button) vbox.addWidget(self.nav_widget) vbox.addWidget(self.size_checkbox) vbox.addWidget(self.size_widget) vbox.addStretch() hbox.addLayout(vbox) hbox.addWidget(self.media_preview_stack) hbox.setSpacing(20) hbox.setContentsMargins(20, 20, 20, 20) vbox.setSpacing(10) nav_hbox.setContentsMargins(0, 0, 0, 0) size_hbox.setContentsMargins(0, 0, 0, 0) self.nav_widget.setLayout(nav_hbox) self.size_widget.setLayout(size_hbox) # Create slave window desktop_widget = QDesktopWidget() if desktop_widget.screenCount() != 2: QMessageBox.warning(self, "Warning", "Cannot find a second screen, " \ "display will be on primary screen.") self.display_widget.showMaximized() else: self.center_widget(self.display_widget, 1) self.display_widget.showFullScreen() # Set default values in the screen dimension widgets display_geometry = desktop_widget.screenGeometry(self.display_widget) self.size_widget.hide() self.display_widget.setWindowTitle("Polo - Display") self.setLayout(hbox) self.setWindowTitle("Polo") self.show()
def initUI(self): self.setWindowTitle('DeepListen SEG-Y Converter') # Adjust screen size dw = QDesktopWidget() scrCount = dw.screenCount() if (scrCount > 1): self.iWidth = dw.width() / 2 else: self.iWidth = dw.width() self.iHeight = dw.height() self.inButton = QPushButton(u' Input Directory...', parent=self) self.inLineEdit = QLineEdit(parent=self) self.outButton = QPushButton(u'Output Directory...', parent=self) self.outLineEdit = QLineEdit(parent=self) # add line self.line = QFrame() self.line.setFrameShape(QFrame().HLine) self.line.setFrameShadow(QFrame().Sunken) self.progressLabel = QLabel( 'Converting progress' ) # progerssbar label showing which process is running self.progressBar = QProgressBar(self) # Create ButtonBox for OK and Cancel self.buttonBox = QDialogButtonBox(parent=self) self.buttonBox.setOrientation(Qt.Horizontal) # horizontal self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("Convert")) self.buttonBox.button(QDialogButtonBox.Cancel).setText( self.tr("Cancel")) grid = QGridLayout() grid.addWidget(self.inButton, 0, 0, 1, 1, Qt.AlignRight) grid.addWidget(self.inLineEdit, 0, 1, 1, 3) grid.addWidget(self.outButton, 1, 0, 1, 1, Qt.AlignRight) grid.addWidget(self.outLineEdit, 1, 1, 1, 3) vbox1 = QVBoxLayout() vbox1.addWidget(self.progressLabel) vbox1.addWidget(self.progressBar) vbox = QVBoxLayout() vbox.addLayout(grid) vbox.addWidget(self.line) vbox.addLayout(vbox1) vbox.addWidget(self.buttonBox) self.main = QWidget() self.setCentralWidget(self.main) self.main.setLayout(vbox) self.createActions() self.createMenus() self.createToolBars() self.createStatusBar() self.resize(400, 180) # Connect all necessary signals and slots. self._connect_signals_and_slots()
def initUI(self): self.setWindowTitle('DeepListen SEG-Y Converter') # Adjust screen size dw = QDesktopWidget() scrCount = dw.screenCount() if (scrCount > 1): self.iWidth = dw.width() / 2 else: self.iWidth = dw.width() self.iHeight = dw.height() self.inButton = QPushButton(u' Input Directory...', parent=self) self.inLineEdit = QLineEdit(parent=self) self.outButton = QPushButton(u'Output Directory...', parent=self) self.outLineEdit = QLineEdit(parent=self) self.headerLabel = QLabel('Header Size [Byte]') self.headerSpinBox = QSpinBox() self.headerSpinBox.setAccelerated(True) self.headerSpinBox.setCorrectionMode( QAbstractSpinBox.CorrectToNearestValue) self.headerSpinBox.setMinimum(0) self.headerSpinBox.setMaximum(1000000000) self.headerSpinBox.setSingleStep(1) self.headerSpinBox.setValue(512) self.dsfLabel = QLabel('Sample Format') self.dsfComboBox = QComboBox() self.dsfComboBox.addItems(['int32']) self.dtLabel = QLabel('Sampling Rate [us]') self.dtSpinBox = QSpinBox() self.dtSpinBox.setAccelerated(True) self.dtSpinBox.setCorrectionMode( QAbstractSpinBox.CorrectToNearestValue) self.dtSpinBox.setMinimum(1) self.dtSpinBox.setMaximum(100000000) self.dtSpinBox.setSingleStep(1) self.dtSpinBox.setValue(1000) self.rcvLabel = QLabel('Receiver Info.') self.rcvComboBox = QComboBox() self.rcvComboBox.addItems(['Inline3D']) self.numLabel = QLabel('Receiver Numbering') self.numSpinBox = QSpinBox() self.numSpinBox.setAccelerated(True) self.numSpinBox.setCorrectionMode( QAbstractSpinBox.CorrectToNearestValue) self.numSpinBox.setMinimum(1) self.numSpinBox.setMaximum(100000000) self.numSpinBox.setSingleStep(1) self.numSpinBox.setValue(4) # add line line1 = QFrame() line1.setFrameShape(QFrame().HLine) line1.setFrameShadow(QFrame().Sunken) # add line line2 = QFrame() line2.setFrameShape(QFrame().HLine) line2.setFrameShadow(QFrame().Sunken) self.progressLabel = QLabel( 'Converting progress' ) # progerssbar label showing which process is running self.progressBar = QProgressBar(self) # Create ButtonBox for OK and Cancel self.buttonBox = QDialogButtonBox(parent=self) self.buttonBox.setOrientation(Qt.Horizontal) # horizontal self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("Convert")) self.buttonBox.button(QDialogButtonBox.Cancel).setText( self.tr("Cancel")) grid1 = QGridLayout() grid1.addWidget(self.inButton, 0, 0, 1, 1, Qt.AlignRight) grid1.addWidget(self.inLineEdit, 0, 1, 1, 3) grid1.addWidget(self.outButton, 1, 0, 1, 1, Qt.AlignRight) grid1.addWidget(self.outLineEdit, 1, 1, 1, 3) grid2 = QGridLayout() grid2.addWidget(self.headerLabel, 0, 0, 1, 1, Qt.AlignRight) grid2.addWidget(self.headerSpinBox, 0, 1, 1, 2) grid2.addWidget(self.dsfLabel, 1, 0, 1, 1, Qt.AlignRight) grid2.addWidget(self.dsfComboBox, 1, 1, 1, 2) grid2.addWidget(self.dtLabel, 2, 0, 1, 1, Qt.AlignRight) grid2.addWidget(self.dtSpinBox, 2, 1, 1, 2) grid2.addWidget(self.rcvLabel, 3, 0, 1, 1, Qt.AlignRight) grid2.addWidget(self.rcvComboBox, 3, 1, 1, 2) grid2.addWidget(self.numLabel, 4, 0, 1, 1, Qt.AlignRight) grid2.addWidget(self.numSpinBox, 4, 1, 1, 2) vbox1 = QVBoxLayout() vbox1.addWidget(self.progressLabel) vbox1.addWidget(self.progressBar) vbox = QVBoxLayout() vbox.addLayout(grid1) vbox.addWidget(line1) vbox.addLayout(grid2) vbox.addWidget(line2) vbox.addLayout(vbox1) vbox.addWidget(self.buttonBox) self.main = QWidget() self.setCentralWidget(self.main) self.main.setLayout(vbox) self.createActions() self.createMenus() self.createToolBars() self.createStatusBar() self.resize(400, 300) # Connect all necessary signals and slots. self._connect_signals_and_slots() self._add_handlers_for_config()