我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtCore.QRect()。
def setupUi(self, Window): Window.setObjectName("Window") Window.resize(800, 600) self.centralwidget = QtWidgets.QWidget(Window) self.centralwidget.setObjectName("centralwidget") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout_2.setContentsMargins(-1, 4, -1, 4) self.verticalLayout_2.setObjectName("verticalLayout_2") self.webView = QtWebKitWidgets.QWebView(self.centralwidget) self.webView.setUrl(QtCore.QUrl("http://qt.nokia.com/")) self.webView.setObjectName("webView") self.verticalLayout_2.addWidget(self.webView) Window.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(Window) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 27)) self.menubar.setObjectName("menubar") Window.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(Window) self.statusbar.setObjectName("statusbar") Window.setStatusBar(self.statusbar) self.dockWidget = QtWidgets.QDockWidget(Window) self.dockWidget.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) self.dockWidget.setObjectName("dockWidget") self.dockWidgetContents = QtWidgets.QWidget() self.dockWidgetContents.setObjectName("dockWidgetContents") self.verticalLayout = QtWidgets.QVBoxLayout(self.dockWidgetContents) self.verticalLayout.setContentsMargins(4, 4, 4, 4) self.verticalLayout.setObjectName("verticalLayout") self.treeWidget = QtWidgets.QTreeWidget(self.dockWidgetContents) self.treeWidget.setObjectName("treeWidget") self.treeWidget.headerItem().setText(0, "1") self.treeWidget.header().setVisible(False) self.verticalLayout.addWidget(self.treeWidget) self.dockWidget.setWidget(self.dockWidgetContents) Window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidget) self.retranslateUi(Window) QtCore.QMetaObject.connectSlotsByName(Window)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(564, 270) self.centralWidget = QtWidgets.QWidget(MainWindow) self.centralWidget.setObjectName("centralWidget") self.pushButton = QtWidgets.QPushButton(self.centralWidget) self.pushButton.setGeometry(QtCore.QRect(320, 60, 93, 28)) self.pushButton.setObjectName("pushButton") self.textEdit = QtWidgets.QTextEdit(self.centralWidget) self.textEdit.setGeometry(QtCore.QRect(60, 60, 151, 31)) self.textEdit.setObjectName("textEdit") self.pushButton_2 = QtWidgets.QPushButton(self.centralWidget) self.pushButton_2.setGeometry(QtCore.QRect(320, 150, 111, 28)) self.pushButton_2.setObjectName("pushButton_2") self.label = QtWidgets.QLabel(self.centralWidget) self.label.setGeometry(QtCore.QRect(60, 30, 151, 16)) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(self.centralWidget) self.label_2.setGeometry(QtCore.QRect(60, 110, 151, 41)) self.label_2.setObjectName("label_2") self.comboBox = QtWidgets.QComboBox(self.centralWidget) self.comboBox.setGeometry(QtCore.QRect(60, 160, 87, 22)) self.comboBox.setObjectName("comboBox") MainWindow.setCentralWidget(self.centralWidget) self.menuBar = QtWidgets.QMenuBar(MainWindow) self.menuBar.setGeometry(QtCore.QRect(0, 0, 564, 26)) self.menuBar.setObjectName("menuBar") MainWindow.setMenuBar(self.menuBar) self.mainToolBar = QtWidgets.QToolBar(MainWindow) self.mainToolBar.setObjectName("mainToolBar") MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar) self.statusBar = QtWidgets.QStatusBar(MainWindow) self.statusBar.setObjectName("statusBar") MainWindow.setStatusBar(self.statusBar) self.comboBox.addItems(["%s" % x for x in range(1, 100)]) self.pushButton.clicked.connect(self.start) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(391, 242) MainWindow.setMinimumSize(QtCore.QSize(391, 242)) MainWindow.setMaximumSize(QtCore.QSize(391, 242)) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.textEdit = QtWidgets.QTextEdit(self.centralwidget) self.textEdit.setGeometry(QtCore.QRect(0, 0, 391, 241)) self.textEdit.setMinimumSize(QtCore.QSize(391, 0)) self.textEdit.setLineWrapMode(QtWidgets.QTextEdit.WidgetWidth) self.textEdit.setReadOnly(False) self.textEdit.setCursorWidth(1) self.textEdit.setObjectName("textEdit") MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def getDetailInfo(self): """??????????: ???????????""" self.shortInfo.hide() self.detailInfo.show() self.showDetail = QPropertyAnimation(self, b"geometry") x = self.pos().x() y = self.pos().y() self.showDetail.setStartValue(QRect(x, y, self.width(), self.height())) # ??????????? self.showDetail.setEndValue(QRect(0, self.grandparent.header.height()+3, self.grandparent.width(), self.grandparent.mainContent.height())) self.showDetail.setDuration(300) self.showDetail.setEasingCurve(QEasingCurve.InBack) self.showDetail.start(QAbstractAnimation.DeleteWhenStopped) # ?????????????????????? self.raise_() self.setDetailInfo()
def getShortInfo(self): """????????????""" self.detailInfo.hide() self.showShort = QPropertyAnimation(self, b"geometry") x = self.pos().x() y = self.pos().y() self.showShort.setStartValue(QRect(0, self.grandparent.header.height(), self.grandparent.width(), self.grandparent.mainContent.height())) self.showShort.setEndValue(QRect(0, self.grandparent.height()-64-self.parent.height(), self.grandparent.navigation.width(), 64)) self.showShort.setDuration(300) self.showShort.setEasingCurve(QEasingCurve.InBack) self.showShort.start(QAbstractAnimation.DeleteWhenStopped) self.shortInfo.show() self.raise_()
def setupUi(self, About): About.setObjectName("About") About.resize(401, 117) About.setMinimumSize(QtCore.QSize(401, 117)) About.setMaximumSize(QtCore.QSize(401, 117)) self.buttonBox = QtWidgets.QDialogButtonBox(About) self.buttonBox.setGeometry(QtCore.QRect(10, 80, 381, 32)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(True) self.buttonBox.setObjectName("buttonBox") self.label = QtWidgets.QLabel(About) self.label.setGeometry(QtCore.QRect(0, 20, 401, 21)) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(About) self.label_2.setGeometry(QtCore.QRect(0, 40, 401, 20)) self.label_2.setAlignment(QtCore.Qt.AlignCenter) self.label_2.setObjectName("label_2") self.retranslateUi(About) self.buttonBox.clicked['QAbstractButton*'].connect(About.close) QtCore.QMetaObject.connectSlotsByName(About)
def setupUi(self, Form): Form.setObjectName("Form") Form.setGeometry(50,50,500,360) self.calendarWidget = QtWidgets.QCalendarWidget(Form) self.calendarWidget.setGridVisible(True) self.calendarWidget.setGeometry(QtCore.QRect(50, 50, 400, 250)) self.calendarWidget.setObjectName("calendarWidget") self.label = QtWidgets.QLabel(Form) date = self.calendarWidget.selectedDate() self.label.setText(date.toString()) self.label.setGeometry(QtCore.QRect(190, 200, 350, 270)) self.label.setObjectName("label") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Help): Help.setObjectName("Help") Help.resize(300, 400) Help.setMinimumSize(QtCore.QSize(300, 400)) Help.setMaximumSize(QtCore.QSize(300, 400)) self.plainTextEdit = QtWidgets.QPlainTextEdit(Help) self.plainTextEdit.setGeometry(QtCore.QRect(0, 0, 301, 341)) self.plainTextEdit.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) self.plainTextEdit.setObjectName("plainTextEdit") self.pushButton = QtWidgets.QPushButton(Help) self.pushButton.setGeometry(QtCore.QRect(100, 360, 99, 27)) self.pushButton.setObjectName("pushButton") self.retranslateUi(Help) self.pushButton.clicked.connect(Help.close) QtCore.QMetaObject.connectSlotsByName(Help)
def setupUi(self, Login): Login.setObjectName("Login") Login.resize(300, 400) Login.setMinimumSize(QtCore.QSize(300, 400)) Login.setMaximumSize(QtCore.QSize(300, 400)) self.pushButton = QtWidgets.QPushButton(Login) self.pushButton.setGeometry(QtCore.QRect(100, 320, 99, 27)) self.pushButton.setObjectName("pushButton") self.label_2 = QtWidgets.QLabel(Login) self.label_2.setGeometry(QtCore.QRect(28, 190, 68, 17)) self.label_2.setObjectName("label_2") self.lineEdit_2 = QtWidgets.QLineEdit(Login) self.lineEdit_2.setGeometry(QtCore.QRect(120, 190, 151, 27)) self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password) self.lineEdit_2.setObjectName("lineEdit_2") self.label = QtWidgets.QLabel(Login) self.label.setGeometry(QtCore.QRect(28, 120, 68, 17)) self.label.setObjectName("label") self.lineEdit = QtWidgets.QLineEdit(Login) self.lineEdit.setGeometry(QtCore.QRect(120, 120, 151, 27)) self.lineEdit.setObjectName("lineEdit") self.retranslateUi(Login) QtCore.QMetaObject.connectSlotsByName(Login)
def draw_progress_bar(plex_item, pixmap, height=6): """draw a progress indicator on the bottom of pixmap with height pixels""" if not hasattr(plex_item, 'in_progress'): return if not plex_item.in_progress: return progress_color = QtGui.QColor(204, 123, 25) progress = plex_item.view_offset / max(1, plex_item.duration) p = QtGui.QPainter(pixmap) rect = p.window() progress_rect = QtCore.QRect(rect.bottomLeft() - QtCore.QPoint(0, height), rect.bottomRight()) progress_fill = QtCore.QRect(progress_rect) progress_fill.setWidth(rect.width() * progress) p.fillRect(progress_rect, QtGui.QBrush(QtCore.Qt.black)) p.fillRect(progress_fill, QtGui.QBrush(progress_color))
def __init__(self, parent=None): """ Initialisation of the View Object. This is called by the gui created with the QTDesigner. @param parent: Main is passed as a pointer for reference. """ super(MyGraphicsView, self).__init__(parent) self.currentItem = None self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setResizeAnchor(QGraphicsView.AnchorViewCenter) # self.setDragMode(QGraphicsView.RubberBandDrag ) self.setDragMode(QGraphicsView.NoDrag) self.parent = parent self.mppos = None self.rubberBand = QRubberBand(QRubberBand.Rectangle, self) self.prvRectRubberBand = QtCore.QRect()
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(984, 658) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.pushbutton = QtWidgets.QPushButton('Test') self.verticalLayout.addWidget(self.pushbutton) self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 984, 21)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def mousePressEvent(self, event): if event.button() == Qt.LeftButton: for recordIndex, rect in self._optionsRects.items(): if QRect(*rect).contains(event.pos()): self._clickedIndex = recordIndex self._oldSelection = self._selection self._selection = {recordIndex} if self._selectionMode > 1 and QApplication.keyboardModifiers( ) & Qt.ShiftModifier: shiftSelection = self._selection ^ self._oldSelection if shiftSelection: self._selection = shiftSelection else: self._selection |= self._oldSelection break self.update() else: super().mousePressEvent(event)
def mouseReleaseEvent(self, event): if event.button() == Qt.LeftButton: clickedRect = self._optionsRects[self._clickedIndex] if QRect(*clickedRect).contains(event.pos()): self._selection = {self._clickedIndex} if self._selectionMode > 1 and QApplication.keyboardModifiers( ) & Qt.ShiftModifier: shiftSelection = self._selection ^ self._oldSelection if shiftSelection: self._selection = shiftSelection self.clicked.emit() else: self._selection = self._oldSelection self.update() del self._clickedIndex del self._oldSelection else: super().mouseReleaseEvent(event)
def qt_rect_to_rect(qt_rect, unit=None): """Create a Rect from a QRect or QRectF Args: qt_rect (QRect or QRectF): The source rect unit (Unit): An optional unit to convert values to in the output `Rect`. If omitted, values in the output `Rect` will be plain `int` or `float` values. Returns: Rect """ if unit: return Rect(qt_rect.x(), qt_rect.y(), qt_rect.width(), qt_rect.height()).to_unit(unit) else: return Rect(qt_rect.x(), qt_rect.y(), qt_rect.width(), qt_rect.height())
def __init__(self, map_tab_widget): # set object name map_tab_widget.setObjectName("mapTab") # create plot widget self.plot_widget = QWidget(map_tab_widget) self.plot_widget.setGeometry(QRect(10, 10, 600, 350)) self.plot_widget.setObjectName("plotWidget") # create toolbar widget self.toolbar_widget = QWidget(map_tab_widget) self.toolbar_widget.setGeometry(QRect(10, 350, 450, 80)) self.toolbar_widget.setObjectName("toolbarWidget") # data selection box self.data_selection_combo_box = QComboBox(map_tab_widget) self.data_selection_combo_box.setGeometry(QRect(460, 360, 150, 30))
def __init__(self, colormap_dialog): # set window title, object name and window size colormap_dialog.setWindowTitle("Choose Colormap") colormap_dialog.setObjectName("ColormapDialog") colormap_dialog.setFixedWidth(455) colormap_dialog.setFixedHeight(100) # button box self.button_box = QDialogButtonBox(colormap_dialog) self.button_box.setEnabled(True) self.button_box.setGeometry(QRect(10, 60, 435, 30)) self.button_box.setOrientation(Qt.Horizontal) self.button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.button_box.setObjectName("button_box") # colormap selector self.colormap_combobox = QComboBox(colormap_dialog) self.colormap_combobox.setGeometry(QRect(10, 10, 435, 30)) self.colormap_combobox.setIconSize(QSize(435, 20)) # connect accept and reject self.button_box.accepted.connect(colormap_dialog.accept) self.button_box.rejected.connect(colormap_dialog.reject)
def doLayout(self, rect, testOnly): x = rect.x() y = rect.y() lineHeight = 0 for item in self.itemList: wid = item.widget() spaceX = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Horizontal) spaceY = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Vertical) nextX = x + item.sizeHint().width() + spaceX if nextX - spaceX > rect.right() and lineHeight > 0: x = rect.x() y = y + lineHeight + spaceY nextX = x + item.sizeHint().width() + spaceX lineHeight = 0 if not testOnly: item.setGeometry(QRect(QPoint(x, y), item.sizeHint())) x = nextX lineHeight = max(lineHeight, item.sizeHint().height()) return y + lineHeight - rect.y()
def paintEvent(self, event): painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing, self.antialiased) painter.translate(self.width() / 2, self.height() / 2) for diameter in range(0, 256, 9): delta = abs((self.frameNo % 128) - diameter / 2) alpha = 255 - (delta * delta) / 4 - diameter if alpha > 0: painter.setPen(QPen(QColor(0, diameter / 2, 127, alpha), 3)) if self.floatBased: painter.drawEllipse(QRectF(-diameter / 2.0, -diameter / 2.0, diameter, diameter)) else: painter.drawEllipse(QRect(-diameter / 2, -diameter / 2, diameter, diameter))
def paint(self, painter, event, elapsed): painter.fillRect(event.rect(), self.background) painter.translate(100, 100) painter.save() painter.setBrush(self.circleBrush) painter.setPen(self.circlePen) painter.rotate(elapsed * 0.030) r = elapsed / 1000.0 n = 30 for i in range(n): painter.rotate(30) radius = 0 + 120.0*((i+r)/n) circleRadius = 1 + ((i+r)/n)*20 painter.drawEllipse(QRectF(radius, -circleRadius, circleRadius*2, circleRadius*2)) painter.restore() painter.setPen(self.textPen) painter.setFont(self.textFont) painter.drawText(QRect(-50, -50, 100, 100), Qt.AlignCenter, "Qt")
def createImage(self, transform): scaledRect = transform.mapRect(QRect(0, 0, ScanItem.ITEM_WIDTH, ScanItem.ITEM_HEIGHT)) image = QImage(scaledRect.width(), scaledRect.height(), QImage.Format_ARGB32_Premultiplied) image.fill(QColor(0, 0, 0, 0).rgba()) painter = QPainter(image) painter.setRenderHint(QPainter.Antialiasing) if Colors.useEightBitPalette: painter.setPen(QPen(QColor(100, 100, 100), 2)) painter.setBrush(QColor(206, 246, 117)) painter.drawEllipse(1, 1, scaledRect.width() - 2, scaledRect.height() - 2) else: painter.setPen(QPen(QColor(0, 0, 0, 15), 1)) painter.setBrush(QColor(0, 0, 0, 15)) painter.drawEllipse(1, 1, scaledRect.width() - 2, scaledRect.height() - 2) return image
def setupWidget(self): desktop = QApplication.desktop() screenRect = desktop.screenGeometry(desktop.primaryScreen()) windowRect = QRect(0, 0, 800, 600) if screenRect.width() < 800: windowRect.setWidth(screenRect.width()) if screenRect.height() < 600: windowRect.setHeight(screenRect.height()) windowRect.moveCenter(screenRect.center()) self.setGeometry(windowRect) self.setMinimumSize(80, 60) self.setWindowTitle("PyQt Examples") self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setFrameStyle(QFrame.NoFrame) self.setRenderingSystem() self.updateTimer.timeout.connect(self.tick)
def setupUi3(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(415, 296) self.dialogButtonBox = QtWidgets.QDialogButtonBox(Dialog) self.dialogButtonBox.setGeometry(QtCore.QRect(190, 240, 181, 32)) self.dialogButtonBox.setOrientation(QtCore.Qt.Horizontal) self.dialogButtonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) self.dialogButtonBox.setObjectName("dialogButtonBox") self.author = QtWidgets.QLabel(Dialog) self.author.setGeometry(QtCore.QRect(10, 30, 191, 17)) self.author.setObjectName("author") self.email = QtWidgets.QLabel(Dialog) self.email.setGeometry(QtCore.QRect(10, 60, 271, 17)) self.email.setObjectName("email") self.github = QtWidgets.QLabel(Dialog) self.github.setGeometry(QtCore.QRect(10, 90, 371, 17)) self.github.setObjectName("github") self.GPL = QtWidgets.QLabel(Dialog) self.GPL.setGeometry(QtCore.QRect(10, 120, 161, 17)) self.GPL.setObjectName("GPL") self.retranslateUi(Dialog) self.dialogButtonBox.accepted.connect(Dialog.accept) self.dialogButtonBox.rejected.connect(Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(504, 254) Form.setStyleSheet("font-family: \"Sans Serif\";\n" "font-size: 9pt;") self.label = QtWidgets.QLabel(Form) self.label.setGeometry(QtCore.QRect(12, 10, 120, 90)) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(Form) self.label_2.setGeometry(QtCore.QRect(160, 10, 331, 201)) self.label_2.setTextFormat(QtCore.Qt.RichText) self.label_2.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.label_2.setOpenExternalLinks(True) self.label_2.setObjectName("label_2") self.label_5 = QtWidgets.QLabel(Form) self.label_5.setGeometry(QtCore.QRect(10, 110, 141, 16)) self.label_5.setTextFormat(QtCore.Qt.RichText) self.label_5.setOpenExternalLinks(True) self.label_5.setObjectName("label_5") self.Ok = QtWidgets.QPushButton(Form) self.Ok.setGeometry(QtCore.QRect(210, 220, 91, 24)) self.Ok.setObjectName("Ok") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(400, 239) Dialog.setMinimumSize(QtCore.QSize(400, 239)) Dialog.setMaximumSize(QtCore.QSize(400, 239)) self.manuel_button = QtWidgets.QPushButton(Dialog) self.manuel_button.setGeometry(QtCore.QRect(230, 190, 85, 30)) self.manuel_button.setObjectName("manuel_button") self.splitter = QtWidgets.QSplitter(Dialog) self.splitter.setGeometry(QtCore.QRect(20, 20, 361, 161)) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.setObjectName("splitter") self.label_2 = QtWidgets.QLabel(self.splitter) self.label_2.setObjectName("label_2") self.label = QtWidgets.QLabel(self.splitter) self.label.setObjectName("label") self.retranslateUi(Dialog) self.manuel_button.clicked.connect(Dialog.close) QtCore.QMetaObject.connectSlotsByName(Dialog)
def test_risk_matrix_etc_remember_geometry(self): oldgeometry1 = QtCore.QRect(100, 100, 500, 500) self.aw.riskmatrix.parent().setGeometry(oldgeometry1) oldgeometry2 = QtCore.QRect(200, 150, 505, 508) self.aw.networkmap.parent().setGeometry(oldgeometry2) oldgeometry3 = QtCore.QRect(300, 200, 509, 510) self.aw.get_wlc_windows()[0].parent().setGeometry(oldgeometry3) oldgeometry4 = QtCore.QRect(100, 300, 511, 512) self.aw.datawindow.parent().setGeometry(oldgeometry4) self.aw.show() # now start a new session. self.app.closeAllWindows() self.app.exit() self.app = None time.sleep(1) self.app = QApplication([]) self.aw = MainWindow() self.assertEqual(oldgeometry1, self.aw.riskmatrix.parent().geometry()) self.assertEqual(oldgeometry2, self.aw.networkmap.parent().geometry()) self.assertEqual(oldgeometry3, self.aw.get_wlc_windows()[0].parent().geometry()) self.assertEqual(oldgeometry4, self.aw.datawindow.parent().geometry())
def setupUi(self, mainWindow): mainWindow.setObjectName("mainWindow") mainWindow.resize(604, 100) mainWindow.setMinimumSize(QtCore.QSize(604, 100)) mainWindow.setMaximumSize(QtCore.QSize(604, 100)) self.lineEdit = QtWidgets.QLineEdit(mainWindow) self.lineEdit.setGeometry(QtCore.QRect(0, 0, 601, 101)) self.lineEdit.setMinimumSize(QtCore.QSize(601, 101)) self.lineEdit.setMaximumSize(QtCore.QSize(601, 101)) font = QtGui.QFont() font.setPointSize(28) self.lineEdit.setFont(font) self.lineEdit.setObjectName("lineEdit") self.retranslateUi(mainWindow) QtCore.QMetaObject.connectSlotsByName(mainWindow)
def _lodeconfig(self): '''????????????''' self.mainWindow.resize(self.windowW, self.windowH) self.mainWindow.setMinimumSize( QtCore.QSize(self.windowW, self.windowH)) self.mainWindow.setMaximumSize( QtCore.QSize(self.windowW, self.windowH)) self.ui.lineEdit.setGeometry( QtCore.QRect(0, 0, self.windowW, self.windowH)) self.ui.lineEdit.setMinimumSize( QtCore.QSize(self.windowW, self.windowH)) self.ui.lineEdit.setMaximumSize( QtCore.QSize(self.windowW, self.windowH)) font = QtGui.QFont() font.setPointSize(self.font_size) self.ui.lineEdit.setFont(font) self.mainWindow.setWindowOpacity(self.windowOpacity) self.ui.lineEdit.setStyleSheet( "background:{};color:{};".format(self.background, self.font_color)) self.ui2.ch_font_color.setStyleSheet("background:{}".format(self.font_color)) self.ui2.ch_backcolor.setStyleSheet("background:{};".format(self.background))
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(376, 68) Form.setMinimumSize(QtCore.QSize(376, 68)) Form.setMaximumSize(QtCore.QSize(376, 68)) self.lineEdit = QtWidgets.QLineEdit(Form) self.lineEdit.setGeometry(QtCore.QRect(0, 0, 381, 71)) self.lineEdit.setMinimumSize(QtCore.QSize(381, 71)) self.lineEdit.setMaximumSize(QtCore.QSize(381, 71)) font = QtGui.QFont() font.setPointSize(20) self.lineEdit.setFont(font) self.lineEdit.setObjectName("lineEdit") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self): self.setObjectName("Dialog") self.resize(355, 76) self.buttonBox = QtWidgets.QDialogButtonBox(self) self.buttonBox.setGeometry(QtCore.QRect(0, 40, 341, 32)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.lineEdit_basepath = QtWidgets.QLineEdit(self) self.lineEdit_basepath.setGeometry(QtCore.QRect(100, 10, 221, 20)) self.lineEdit_basepath.setObjectName("lineEdit_basepath") self.select_base_Btn = QtWidgets.QPushButton(self) self.select_base_Btn.setGeometry(QtCore.QRect(320, 10, 21, 20)) self.select_base_Btn.setObjectName("select_base_Btn") self.label = QtWidgets.QLabel(self) self.label.setGeometry(QtCore.QRect(10, 10, 71, 16)) self.label.setObjectName("label") # self.create_Btn = QtWidgets.QPushButton(self) # self.create_Btn.setGeometry(QtCore.QRect(10, 60, 91, 31)) # self.create_Btn.setObjectName("create_Btn") self.create_Btn = self.buttonBox.addButton('Create new base',QtWidgets.QDialogButtonBox.ApplyRole) self.lineEdit_basepath.setText(self.filename[0]) self.retranslateUi() #button clicks events self.create_Btn.clicked.connect(self.createBtnclicked) self.select_base_Btn.clicked.connect(self.select_baseBtnclicked) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) QtCore.QMetaObject.connectSlotsByName(self)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(529, 329) self.selInfoWidget = QtWidgets.QWidget(Form) self.selInfoWidget.setGeometry(QtCore.QRect(260, 10, 264, 222)) self.selInfoWidget.setObjectName("selInfoWidget") self.gridLayout = QtWidgets.QGridLayout(self.selInfoWidget) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setObjectName("gridLayout") self.selDescLabel = QtWidgets.QLabel(self.selInfoWidget) self.selDescLabel.setText("") self.selDescLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.selDescLabel.setWordWrap(True) self.selDescLabel.setObjectName("selDescLabel") self.gridLayout.addWidget(self.selDescLabel, 0, 0, 1, 1) self.selNameLabel = QtWidgets.QLabel(self.selInfoWidget) font = QtGui.QFont() font.setBold(True) font.setWeight(75) self.selNameLabel.setFont(font) self.selNameLabel.setText("") self.selNameLabel.setObjectName("selNameLabel") self.gridLayout.addWidget(self.selNameLabel, 0, 1, 1, 1) self.selectedTree = DataTreeWidget(self.selInfoWidget) self.selectedTree.setObjectName("selectedTree") self.selectedTree.headerItem().setText(0, "1") self.gridLayout.addWidget(self.selectedTree, 1, 0, 1, 2) self.hoverText = QtWidgets.QTextEdit(Form) self.hoverText.setGeometry(QtCore.QRect(0, 240, 521, 81)) self.hoverText.setObjectName("hoverText") self.view = FlowchartGraphicsView(Form) self.view.setGeometry(QtCore.QRect(0, 0, 256, 192)) self.view.setObjectName("view") self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, DownloaderDlg): DownloaderDlg.setObjectName("DownloaderDlg") DownloaderDlg.resize(524, 443) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(DownloaderDlg.sizePolicy().hasHeightForWidth()) DownloaderDlg.setSizePolicy(sizePolicy) self.downloads_buttonBox = QtWidgets.QDialogButtonBox(DownloaderDlg) self.downloads_buttonBox.setGeometry(QtCore.QRect(350, 400, 161, 32)) self.downloads_buttonBox.setOrientation(QtCore.Qt.Horizontal) self.downloads_buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close | QtWidgets.QDialogButtonBox.Ok) self.downloads_buttonBox.setCenterButtons(False) self.downloads_buttonBox.setObjectName("downloads_buttonBox") self.downloads_treeWidget = QtWidgets.QTreeWidget(DownloaderDlg) self.downloads_treeWidget.setGeometry(QtCore.QRect(10, 10, 501, 381)) self.downloads_treeWidget.setObjectName("downloads_treeWidget") self.downloads_treeWidget.headerItem().setText(0, "1") self.statusLabel = QtWidgets.QLabel(DownloaderDlg) self.statusLabel.setGeometry(QtCore.QRect(20, 400, 321, 31)) self.statusLabel.setText("") self.statusLabel.setObjectName("statusLabel") self.retranslateUi(DownloaderDlg) self.downloads_buttonBox.accepted.connect(DownloaderDlg.accept) self.downloads_buttonBox.rejected.connect(DownloaderDlg.reject) QtCore.QMetaObject.connectSlotsByName(DownloaderDlg)
def drawIndicatorIcon(palette, style): pix = QPixmap(14, 14) pix.fill(Qt.transparent) branchOption = QStyleOption() #r = QRect(QPoint(0, 0), pix.size()) branchOption.rect = QRect(2, 2, 9, 9) ## ### hardcoded in qcommonstyle.cpp branchOption.palette = palette branchOption.state = QStyle.State_Children p = QPainter() ## Draw closed state p.begin(pix) style.drawPrimitive(QStyle.PE_IndicatorBranch, branchOption, p) p.end() rc = QIcon(pix) rc.addPixmap(pix, QIcon.Selected, QIcon.Off) ## Draw opened state branchOption.state |= QStyle.State_Open pix.fill(Qt.transparent) p.begin(pix) style.drawPrimitive(QStyle.PE_IndicatorBranch, branchOption, p) p.end() rc.addPixmap(pix, QIcon.Normal, QIcon.On) rc.addPixmap(pix, QIcon.Selected, QIcon.On) return rc
def insertRow(self, layout, row): itemToPos = QMap() idx = 0 while (idx < len(layout)): r, c, rs, cs = layout.getItemPosition(idx) if (r >= row): itemToPos[layout.takeAt(idx)] = QRect(r + 1, c, rs, cs) else: idx += 1 for k in itemToPos.keys(): r = itemToPos[k] layout.addItem(k, r.x(), r.y(), r.width(), r.height())
def removeRow(self, layout, row): itemToPos = QMap() idx = 0 while (idx < len(layout)): r, c, rs, cs = layout.getItemPosition(idx) if (r > row): itemToPos[layout.takeAt(idx)] = QRect(r - 1, c, rs, cs) else: idx += 1 for k in itemToPos.keys(): r = itemToPos[k] layout.addItem(k, r.x(), r.y(), r.width(), r.height())
def insertRow(self, layout, row): itemToPos = QMap() idx = 0 while (idx < layout.count()): r, c, rs, cs = layout.getItemPosition(idx) if (r >= row): itemToPos[layout.takeAt(idx)] = QRect(r + 1, c, rs, cs) else: idx += 1 for it in itemToPos.keys(): r = itemToPos[it] layout.addItem(it, r.x(), r.y(), r.width(), r.height())
def removeRow(self, layout, row): itemToPos = QMap() idx = 0 while (idx < layout.count()): r, c, rs, cs = layout.getItemPosition(idx) if (r > row): itemToPos[layout.takeAt(idx)] = QRect(r - 1, c, rs, cs) else: idx += 1 for it in itemToPos.keys(): r = itemToPos[it] layout.addItem(it, r.x(), r.y(), r.width(), r.height())
def setupUi(self, corpusManager): corpusManager.setObjectName("corpusManager") corpusManager.resize(800, 600) self.verticalLayout = QtWidgets.QVBoxLayout(corpusManager) self.verticalLayout.setObjectName("verticalLayout") self.list_corpora = QtWidgets.QScrollArea(corpusManager) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.list_corpora.sizePolicy().hasHeightForWidth()) self.list_corpora.setSizePolicy(sizePolicy) self.list_corpora.setFrameShape(QtWidgets.QFrame.NoFrame) self.list_corpora.setWidgetResizable(True) self.list_corpora.setObjectName("list_corpora") self.list_content = QtWidgets.QWidget() self.list_content.setGeometry(QtCore.QRect(0, 0, 792, 592)) self.list_content.setObjectName("list_content") self.list_layout = QtWidgets.QVBoxLayout(self.list_content) self.list_layout.setContentsMargins(0, 0, 0, 0) self.list_layout.setSpacing(0) self.list_layout.setObjectName("list_layout") self.list_corpora.setWidget(self.list_content) self.verticalLayout.addWidget(self.list_corpora) self.retranslateUi(corpusManager) QtCore.QMetaObject.connectSlotsByName(corpusManager)