Python PyQt5.QtCore.QRect() Examples
The following are 30
code examples of PyQt5.QtCore.QRect().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5.QtCore
, or try the search function
.
Example #1
Source File: screenshot.py From screenshot with GNU General Public License v3.0 | 20 votes |
def saveScreenshot(self, clipboard=False, fileName='screenshot.png', picType='png'): fullWindow = QRect(0, 0, self.width() - 1, self.height() - 1) selected = QRect(self.selected_area) if selected.left() < 0: selected.setLeft(0) if selected.right() >= self.width(): selected.setRight(self.width() - 1) if selected.top() < 0: selected.setTop(0) if selected.bottom() >= self.height(): selected.setBottom(self.height() - 1) source = (fullWindow & selected) source.setTopLeft(QPoint(source.topLeft().x() * self.scale, source.topLeft().y() * self.scale)) source.setBottomRight(QPoint(source.bottomRight().x() * self.scale, source.bottomRight().y() * self.scale)) image = self.screenPixel.copy(source) if clipboard: QGuiApplication.clipboard().setImage(QImage(image), QClipboard.Clipboard) else: image.save(fileName, picType, 10) self.target_img = image self.screen_shot_grabed.emit(QImage(image))
Example #2
Source File: screenshot.py From screenshot with GNU General Public License v3.0 | 8 votes |
def drawSizeInfo(self): sizeInfoAreaWidth = 200 sizeInfoAreaHeight = 30 spacing = 5 rect = self.selected_area.normalized() sizeInfoArea = QRect(rect.left(), rect.top() - spacing - sizeInfoAreaHeight, sizeInfoAreaWidth, sizeInfoAreaHeight) if sizeInfoArea.top() < 0: sizeInfoArea.moveTopLeft(rect.topLeft() + QPoint(spacing, spacing)) if sizeInfoArea.right() >= self.screenPixel.width(): sizeInfoArea.moveTopLeft(rect.topLeft() - QPoint(spacing, spacing) - QPoint(sizeInfoAreaWidth, 0)) if sizeInfoArea.left() < spacing: sizeInfoArea.moveLeft(spacing) if sizeInfoArea.top() < spacing: sizeInfoArea.moveTop(spacing) self.items_to_remove.append(self.graphics_scene.addRect(QRectF(sizeInfoArea), Qt.white, QBrush(Qt.black))) sizeInfo = self.graphics_scene.addSimpleText( ' {0} x {1}'.format(rect.width() * self.scale, rect.height() * self.scale)) sizeInfo.setPos(sizeInfoArea.topLeft() + QPoint(0, 2)) sizeInfo.setPen(QPen(QColor(255, 255, 255), 2)) self.items_to_remove.append(sizeInfo)
Example #3
Source File: scorewidnow.py From Python-GUI with MIT License | 8 votes |
def setupUi(self, ScoreWindow): ScoreWindow.setObjectName("ScoreWindow") ScoreWindow.resize(471, 386) self.centralwidget = QtWidgets.QWidget(ScoreWindow) self.centralwidget.setObjectName("centralwidget") self.Score = QtWidgets.QLineEdit(self.centralwidget) self.Score.setGeometry(QtCore.QRect(180, 180, 113, 22)) self.Score.setObjectName("Score") self.teamscore = QtWidgets.QLabel(self.centralwidget) self.teamscore.setGeometry(QtCore.QRect(180, 130, 151, 20)) font = QtGui.QFont() font.setBold(True) font.setWeight(75) self.teamscore.setFont(font) self.teamscore.setObjectName("teamscore") ScoreWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(ScoreWindow) self.statusbar.setObjectName("statusbar") ScoreWindow.setStatusBar(self.statusbar) self.retranslateUi(ScoreWindow) QtCore.QMetaObject.connectSlotsByName(ScoreWindow)
Example #4
Source File: ui_qhangupsconversations.py From qhangups with GNU General Public License v3.0 | 6 votes |
def setupUi(self, QHangupsConversations): QHangupsConversations.setObjectName("QHangupsConversations") QHangupsConversations.resize(500, 350) self.centralwidget = QtWidgets.QWidget(QHangupsConversations) self.centralwidget.setObjectName("centralwidget") self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.conversationsTabWidget = QtWidgets.QTabWidget(self.centralwidget) self.conversationsTabWidget.setElideMode(QtCore.Qt.ElideRight) self.conversationsTabWidget.setTabsClosable(True) self.conversationsTabWidget.setMovable(True) self.conversationsTabWidget.setObjectName("conversationsTabWidget") self.gridLayout.addWidget(self.conversationsTabWidget, 0, 0, 1, 1) QHangupsConversations.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(QHangupsConversations) self.menubar.setGeometry(QtCore.QRect(0, 0, 500, 27)) self.menubar.setObjectName("menubar") QHangupsConversations.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(QHangupsConversations) self.statusbar.setObjectName("statusbar") QHangupsConversations.setStatusBar(self.statusbar) self.retranslateUi(QHangupsConversations) self.conversationsTabWidget.setCurrentIndex(-1) QtCore.QMetaObject.connectSlotsByName(QHangupsConversations)
Example #5
Source File: test_lib_qt_graphics.py From imperialism-remake with GNU General Public License v3.0 | 6 votes |
def test_calculate_constraints(self): parent = QtCore.QRect(10, 10, 1000, 500) size = QtCore.QSize(200, 100) constraint = qt.RelativeLayoutConstraint().south(10).west(20) x,y = qt.calculate_relative_position(parent, size, constraint) self.assertEqual((x,y), (30, 400)) constraint = qt.RelativeLayoutConstraint().north(30).east(40) x, y = qt.calculate_relative_position(parent, size, constraint) self.assertEqual((x, y), (770, 40)) constraint = qt.RelativeLayoutConstraint().center_horizontal().center_vertical() x1, y1 = qt.calculate_relative_position(parent, size, constraint) self.assertEqual((x1, y1), (410, 210))
Example #6
Source File: test_webkitelem.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def test_iframe(self, stubs, js_rect): """Test an element in an iframe. 0, 0 200, 0 ############################## # # 0,10 # iframe 100,10 # #********** # #* * # #* * # #* e * elem: 20,90 in iframe #********** # 0,100 # # ############################## 200, 0 200, 200 """ frame = stubs.FakeWebFrame(QRect(0, 0, 200, 200)) iframe = stubs.FakeWebFrame(QRect(0, 10, 100, 100), parent=frame) assert frame.geometry().contains(iframe.geometry()) elem = get_webelem(QRect(20, 90, 10, 10), iframe, js_rect_return=js_rect) assert elem.rect_on_view() == QRect(20, 10 + 90, 10, 10)
Example #7
Source File: qt.py From imperialism-remake with GNU General Public License v3.0 | 6 votes |
def setGeometry(self, rect: QtCore.QRect): # noqa: N802 """ Layout the elements by calculating their relative position inside the parent, given the parents coordinates and the sizes of the elements. The width and height are not changed but the offset is computed according to the layout constraint and the parent size. :param rect: Position and size of the parent. """ for item in self.items: o_size = item.widget().size() c = item.widget().layout_constraint x, y = calculate_relative_position(rect, o_size, c) item.setGeometry(QtCore.QRect(x, y, o_size.width(), o_size.height()))
Example #8
Source File: qt.py From imperialism-remake with GNU General Public License v3.0 | 6 votes |
def calculate_relative_position(parent_rect: QtCore.QRect, own_size: QtCore.QSize, constraint: RelativeLayoutConstraint): """ Calculates the position of the element, given its size, the position and size of the parent and a relative layout constraint. The position is the position of the parent plus the weighted size of the parent, the weighted size of the element and an offset. The weights and the offset are given by the constraint for each direction. :param parent_rect: parent coordinates and size as rectangle :param own_size: size of the element (width and height) :param constraint: relative layout constraint to apply :return: tuple of recommended x and y positions of the element """ """ Returns the left, upper corner of an object if the parent rectangle (QRect) is given and our own size (QSize) and a relative layout constraint (see RelativeLayoutConstraint). """ x = (parent_rect.x() + constraint.x[0] * parent_rect.width() + constraint.x[1] * own_size.width() + constraint.x[2]) y = (parent_rect.y() + constraint.y[0] * parent_rect.height() + constraint.y[1] * own_size.height() + constraint.y[2]) return x, y
Example #9
Source File: player.py From MusicBox with MIT License | 6 votes |
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_()
Example #10
Source File: player.py From MusicBox with MIT License | 6 votes |
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()
Example #11
Source File: quickplotter.py From phidl with MIT License | 6 votes |
def mouseReleaseEvent(self, event): if event.button() == Qt.RightButton: self.rubberBand.hide() rb_rect = QRect(self._rb_origin, event.pos()) rb_center = rb_rect.center() rb_size = rb_rect.size() if abs(rb_size.width()) > 3 and abs(rb_size.height()) > 3: viewport_size = self.viewport().geometry().size() zoom_factor_x = abs(viewport_size.width() / rb_size.width()) zoom_factor_y = abs(viewport_size.height() / rb_size.height()) new_center = self.mapToScene(rb_center) zoom_factor = min(zoom_factor_x, zoom_factor_y) self.zoom_view(zoom_factor) self.centerOn(new_center) self.update_grid() if event.button() == Qt.MidButton: self.setCursor(Qt.ArrowCursor) self._mousePressed = None self.update_grid()
Example #12
Source File: quickplotter.py From phidl with MIT License | 6 votes |
def mouseMoveEvent(self, event): super(QGraphicsView, self).mouseMoveEvent(event) # # Useful debug # try: # self.debug_label.setText(str(itemsBoundingRect_nogrid().width())) # except: # print('Debug statement failed') # Update the X,Y label indicating where the mouse is on the geometry mouse_position = self.mapToScene(event.pos()) self.mouse_position = [mouse_position.x(), mouse_position.y()] self.update_mouse_position_label() if not self._rb_origin.isNull() and self._mousePressed == Qt.RightButton: self.rubberBand.setGeometry(QRect(self._rb_origin, event.pos()).normalized()) # Middle-click-to-pan if self._mousePressed == Qt.MidButton: newPos = event.pos() diff = newPos - self._dragPos self._dragPos = newPos self.horizontalScrollBar().setValue(self.horizontalScrollBar().value() - diff.x()) self.verticalScrollBar().setValue(self.verticalScrollBar().value() - diff.y()) # event.accept()
Example #13
Source File: visual.py From stytra with GNU General Public License v3.0 | 6 votes |
def paint(self, p, w, h): super().paint(p, w, h) if self._experiment.calibrator is not None: mm_px = self._experiment.calibrator.mm_px else: mm_px = 1 # draw the background p.setPen(Qt.NoPen) p.setBrush(QBrush(QColor(*self.background_color))) self.clip(p, w, h) p.drawRect(QRect(-1, -1, w + 2, h + 2)) # draw the circle p.setBrush(QBrush(QColor(*self.circle_color))) p.drawEllipse(QPointF(self.x * w, self.y * h), self.radius * w, self.radius * h)
Example #14
Source File: quickplotter.py From phidl with MIT License | 6 votes |
def mousePressEvent(self, event): super(QGraphicsView, self).mousePressEvent(event) #============================================================================== # Zoom to rectangle, from # https://wiki.python.org/moin/PyQt/Selecting%20a%20region%20of%20a%20widget #============================================================================== if event.button() == Qt.RightButton: self._mousePressed = Qt.RightButton self._rb_origin = QPoint(event.pos()) self.rubberBand.setGeometry(QRect(self._rb_origin, QSize())) self.rubberBand.show() #============================================================================== # Mouse panning, taken from # http://stackoverflow.com/a/15043279 #============================================================================== elif event.button() == Qt.MidButton: self._mousePressed = Qt.MidButton self._mousePressedPos = event.pos() self.setCursor(QtCore.Qt.ClosedHandCursor) self._dragPos = event.pos()
Example #15
Source File: ui_qhangupsconversationslist.py From qhangups with GNU General Public License v3.0 | 6 votes |
def setupUi(self, QHangupsConversationsList): QHangupsConversationsList.setObjectName("QHangupsConversationsList") QHangupsConversationsList.resize(250, 500) self.centralwidget = QtWidgets.QWidget(QHangupsConversationsList) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.conversationsListWidget = QtWidgets.QListWidget(self.centralwidget) self.conversationsListWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.conversationsListWidget.setObjectName("conversationsListWidget") self.verticalLayout.addWidget(self.conversationsListWidget) QHangupsConversationsList.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(QHangupsConversationsList) self.menubar.setGeometry(QtCore.QRect(0, 0, 250, 27)) self.menubar.setObjectName("menubar") QHangupsConversationsList.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(QHangupsConversationsList) self.statusbar.setObjectName("statusbar") QHangupsConversationsList.setStatusBar(self.statusbar) self.retranslateUi(QHangupsConversationsList) QtCore.QMetaObject.connectSlotsByName(QHangupsConversationsList)
Example #16
Source File: pkcharts.py From pkmeter with BSD 3-Clause "New" or "Revised" License | 6 votes |
def paintEvent(self, event): QtWidgets.QFrame.paintEvent(self, event) painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.setPen(Qt.NoPen) # Draw the Pie rwidth = int(min([self.width(), self.height()]) - 2) x = int((self.width() / 2) - (rwidth / 2)) y = int((self.height() / 2) - (rwidth / 2)) rect = QtCore.QRect(x, y, rwidth, rwidth) angle1 = 0 for i in range(len(self.data)): angle2 = angle1 + (3.6 * self.data[i]) painter.setBrush(QtGui.QBrush(self.colors[i % len(self.colors)])) painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16) angle1 = angle2 # Draw the remainer (background) angle2 = 360 painter.setBrush(QtGui.QBrush(self.bgcolor)) painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16) painter.end()
Example #17
Source File: player.py From MusicBox with MIT License | 5 votes |
def paintEvent(self, event): painter = QPainter(self) painter.setFont(self.font) linear = QLinearGradient(QPoint(self.rect().topLeft()), QPoint(self.rect().bottomLeft())) linear.setStart(0, 10) linear.setFinalStop(0, 50) linear.setColorAt(0.1, QColor(14, 179, 255)); linear.setColorAt(0.5, QColor(154, 232, 255)); linear.setColorAt(0.9, QColor(14, 179, 255)); linear2 = QLinearGradient(QPoint(self.rect().topLeft()), QPoint(self.rect().bottomLeft())) linear2.setStart(0, 10) linear2.setFinalStop(0, 50) linear2.setColorAt(0.1, QColor(222, 54, 4)); linear2.setColorAt(0.5, QColor(255, 172, 116)); linear2.setColorAt(0.9, QColor(222, 54, 4)); painter.setPen(QColor(0, 0, 0, 200)); painter.drawText(QRect(1, 1, self.screen.width(), 60), Qt.AlignHCenter | Qt.AlignVCenter, self.lyric) painter.setPen(QColor('transparent')); self.textRect = painter.drawText(QRect(0, 0, self.screen.width(), 60), Qt.AlignHCenter | Qt.AlignVCenter, self.lyric) painter.setPen(QPen(linear, 0)) painter.drawText(self.textRect, Qt.AlignLeft | Qt.AlignVCenter, self.lyric) if self.intervel != 0: self.widthBlock = self.textRect.width()/(self.intervel/150.0) else: self.widthBlock = 0 self.maskRect = QRectF(self.textRect.x(), self.textRect.y(), self.textRect.width(), self.textRect.height()) self.maskRect.setWidth(self.maskWidth) painter.setPen(QPen(linear2, 0)); painter.drawText(self.maskRect, Qt.AlignLeft | Qt.AlignVCenter, self.lyric)
Example #18
Source File: DyMainWindow.py From DevilYuan with MIT License | 5 votes |
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(473, 235) self.centralWidget = QtWidgets.QWidget(MainWindow) self.centralWidget.setObjectName("centralWidget") self.pushButtonSelectStock = QtWidgets.QPushButton(self.centralWidget) self.pushButtonSelectStock.setGeometry(QtCore.QRect(10, 10, 221, 91)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(20) self.pushButtonSelectStock.setFont(font) self.pushButtonSelectStock.setObjectName("pushButtonSelectStock") self.pushButtonStockTrade = QtWidgets.QPushButton(self.centralWidget) self.pushButtonStockTrade.setGeometry(QtCore.QRect(240, 10, 221, 91)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(20) self.pushButtonStockTrade.setFont(font) self.pushButtonStockTrade.setObjectName("pushButtonStockTrade") self.pushButtonStockData = QtWidgets.QPushButton(self.centralWidget) self.pushButtonStockData.setGeometry(QtCore.QRect(240, 110, 221, 91)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(20) self.pushButtonStockData.setFont(font) self.pushButtonStockData.setObjectName("pushButtonStockData") self.pushButtonStockStrategyBackTestinig = QtWidgets.QPushButton(self.centralWidget) self.pushButtonStockStrategyBackTestinig.setGeometry(QtCore.QRect(10, 110, 221, 91)) font = QtGui.QFont() font.setFamily("Arial") font.setPointSize(20) self.pushButtonStockStrategyBackTestinig.setFont(font) self.pushButtonStockStrategyBackTestinig.setObjectName("pushButtonStockStrategyBackTestinig") MainWindow.setCentralWidget(self.centralWidget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
Example #19
Source File: NetworkMJPGImage.py From Cura with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self._stream_buffer = QByteArray() self._stream_buffer_start_index = -1 self._network_manager = None # type: QNetworkAccessManager self._image_request = None # type: QNetworkRequest self._image_reply = None # type: QNetworkReply self._image = QImage() self._image_rect = QRect() self._source_url = QUrl() self._started = False self._mirror = False self.setAntialiasing(True)
Example #20
Source File: mainwindow.py From kawaii-player with GNU General Public License v3.0 | 5 votes |
def dropEvent(self, event): urls = event.mimeData().urls() for url in urls: url = url.toString() ui.logger.debug(url) if url.startswith('file:///') or url.startswith('http') or url.startswith('magnet:'): if os.name == 'posix': url = url.replace('file://', '', 1) else: url = url.replace('file:///', '', 1) ext = None if '.' in url: ext = url.rsplit('.', 1)[-1] ext = ext.lower() rect = QtCore.QRect(ui.label.x(), ui.label.y(), ui.label.width(), ui.label.height()) pos = event.pos() name = ui.get_parameters_value(n='name')['name'] if rect.contains(pos): poster_drop = True out_file = os.path.join(ui.tmp_download_folder, name+'.jpg') else: poster_drop = False out_file = os.path.join(ui.tmp_download_folder, name+'-fanart.jpg') if ext and ext in ['jpg', 'jpeg', 'png'] and not url.startswith('http'): if os.path.isfile(url): shutil.copy(url, out_file) ui.gui_signals.poster_drop(poster_drop, url, name) elif url.startswith('http'): url = url.replace(' ', '%20') ui.vnt.head(url, onfinished=partial(self.process_dropped_url, poster_drop, name)) else: ui.watch_external_video('{}'.format(url), start_now=True)
Example #21
Source File: conditional.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint(self, p, w, h): p.setBrush(QBrush(QColor(0, 0, 0))) p.drawRect(QRect(-1, -1, w + 2, h + 2)) self.active.paint(p, w, h)
Example #22
Source File: kinematograms.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint(self, p, w, h): # draw background p.resetTransform() p.setPen(Qt.NoPen) p.setBrush(QBrush(QColor(*self.color_bg))) self.clip(p, w, h) p.drawRect(QRect(-1, -1, w + 2, h + 2)) p.setTransform(self.get_rot_transform(w, h)) self.paint_dots(p, w, h)
Example #23
Source File: equippedandgrenadeswidget.py From PyPipboyApp with GNU General Public License v3.0 | 5 votes |
def colouriseIcon(self, img, colour): size = img.size() image = QImage(QtCore.QSize(size.width()+1,size.height()+1), QImage.Format_ARGB32_Premultiplied) image.fill(QtCore.Qt.transparent) p = QPainter(image) p.setCompositionMode(QPainter.CompositionMode_SourceOver) p.drawImage(QtCore.QRect(1,1,size.width(), size.height()), img) p.setCompositionMode(QPainter.CompositionMode_SourceAtop) p.setBrush(colour) p.drawRect(QtCore.QRect(0,0,size.width()+1,size.height()+1)) p.end() return QPixmap.fromImage(image)
Example #24
Source File: WindowWithTitleBar.py From QCandyUi with MIT License | 5 votes |
def calculateCurrentStrechRect(self): # 四个角Rect self.m_leftTopRect = QRect(0, 0, STRETCH_RECT_WIDTH, STRETCH_RECT_HEIGHT) self.m_leftBottomRect = QRect(0, self.height() - STRETCH_RECT_HEIGHT, STRETCH_RECT_WIDTH, STRETCH_RECT_WIDTH) self.m_rightTopRect = QRect(self.width() - STRETCH_RECT_WIDTH, 0, STRETCH_RECT_WIDTH, STRETCH_RECT_HEIGHT) self.m_rightBottomRect = QRect(self.width() - STRETCH_RECT_WIDTH, self.height() - STRETCH_RECT_HEIGHT, STRETCH_RECT_WIDTH, STRETCH_RECT_HEIGHT) # 四条边Rect self.m_topBorderRect = QRect(STRETCH_RECT_WIDTH, 0, self.width() - STRETCH_RECT_WIDTH * 2, STRETCH_RECT_HEIGHT) self.m_rightBorderRect = QRect(self.width() - STRETCH_RECT_WIDTH, STRETCH_RECT_HEIGHT, STRETCH_RECT_WIDTH, self.height() - STRETCH_RECT_HEIGHT * 2) self.m_bottomBorderRect = QRect(STRETCH_RECT_WIDTH, self.height() - STRETCH_RECT_HEIGHT, self.width() - STRETCH_RECT_WIDTH * 2, STRETCH_RECT_HEIGHT) self.m_leftBorderRect = QRect(0, STRETCH_RECT_HEIGHT, STRETCH_RECT_WIDTH, self.height() - STRETCH_RECT_HEIGHT * 2)
Example #25
Source File: WindowWithTitleBar.py From QCandyUi with MIT License | 5 votes |
def mousePressEvent(self, event): # 当前鼠标进入了以上指定的8个区域,并且是左键按下时才开始进行窗口拉伸 if (self.m_stretchRectState != NO_SELECT and event.button() == Qt.LeftButton): self.m_isMousePressed = True # 记录下当前鼠标位置,为后面计算拉伸位置 self.m_startPoint = self.mapToGlobal(event.pos()) # 保存下拉伸前的窗口位置及大小 self.m_windowRectBeforeStretch = QRect(self.geometry().x(), self.geometry().y(), self.geometry().width(), self.geometry().height()) return super().mousePressEvent(event)
Example #26
Source File: stimulus_display.py From stytra with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, QPaintEvent): p = QPainter(self) p.setBrush(QBrush(QColor(0, 0, 0))) w = self.width() h = self.height() if self.display_state: if self.protocol_runner is not None: if self.protocol_runner.running: try: self.protocol_runner.current_stimulus.paint(p, w, h) except AttributeError: pass else: p.drawRect(QRect(-1, -1, w + 2, h + 2)) p.setRenderHint(QPainter.SmoothPixmapTransform, 1) if self.img is not None: p.drawImage(QPoint(0, 0), self.img) if self.calibrator is not None: if self.calibrator.enabled: self.calibrator.paint_calibration_pattern(p, h, w) p.end()
Example #27
Source File: __init__.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint_calibration_pattern(self, p, h, w): """ Parameters ---------- p : h : w : Returns ------- """ p.setPen(QPen(QColor(255, 0, 0))) if self.transparent: p.setBrush(QBrush(QColor(0, 0, 0, 0))) else: p.setBrush(QBrush(QColor(0, 0, 0, 255))) p.drawRect(QRect(1, 1, w - 2, h - 2)) l2 = self.length_px / 2 cw = w // 2 ch = h // 2 # draw the cross and the axis labels p.drawLine(cw - l2, ch, cw + l2, h // 2) p.drawText(w * 3 // 4, ch - 5, "x") p.drawLine(cw, h // 2 + l2, cw, ch - l2) p.drawText(cw + 5, h * 3 // 4, "y") # draw the "fish outline" p.drawEllipse(cw - 5, ch - 8, 3, 5) p.drawEllipse(cw + 2, ch - 8, 3, 5) p.drawPolygon( QPolygon( [QPoint(cw - 3, ch + 2), QPoint(cw + 3, ch + 2), QPoint(cw, ch + 20)] ) )
Example #28
Source File: updateScreen.py From pip-gui with GNU General Public License v3.0 | 5 votes |
def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(427, 456) self.listWidget = QtWidgets.QListWidget(Form) self.listWidget.setGeometry(QtCore.QRect(10, 60, 261, 381)) self.listWidget.setSelectionMode( QtWidgets.QAbstractItemView.MultiSelection) self.listWidget.setObjectName(_fromUtf8("listWidget")) self.verticalLayoutWidget = QtWidgets.QWidget(Form) self.verticalLayoutWidget.setGeometry( QtCore.QRect(290, 60, 121, 98)) self.verticalLayoutWidget.setObjectName( _fromUtf8("verticalLayoutWidget")) self.verticalLayout = QtWidgets.QVBoxLayout( self.verticalLayoutWidget) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.btnUpdate = QtWidgets.QPushButton(self.verticalLayoutWidget) self.btnUpdate.setObjectName(_fromUtf8("btnUpdate")) self.verticalLayout.addWidget(self.btnUpdate) self.btnUpdateAll = QtWidgets.QPushButton(self.verticalLayoutWidget) self.btnUpdateAll.setObjectName(_fromUtf8("btnUpdateAll")) self.verticalLayout.addWidget(self.btnUpdateAll) self.btnBack = QtWidgets.QPushButton(self.verticalLayoutWidget) self.btnBack.setObjectName(_fromUtf8("btnBack")) self.verticalLayout.addWidget(self.btnBack) self.label = QtWidgets.QLabel(Form) self.label.setGeometry(QtCore.QRect(10, 20, 401, 21)) font = QtGui.QFont() font.setPointSize(14) self.label.setFont(font) self.label.setObjectName(_fromUtf8("label")) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
Example #29
Source File: custom_visual_exp.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint(self, p, w, h): p.setBrush(QBrush(QColor(*self.color))) # Use chosen color p.drawRect(QRect(0, 0, w, h)) # draw full field rectangle
Example #30
Source File: stimulus_display.py From stytra with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, QPaintEvent): """Generate the stimulus that will be displayed. A QPainter object is defined, which is then passed to the current stimulus paint function for drawing the stimulus. Parameters ---------- QPaintEvent : Returns ------- """ p = QPainter(self) p.setBrush(QBrush(QColor(0, 0, 0))) w = self.width() h = self.height() if self.protocol_runner is not None: if self.protocol_runner.running: try: self.protocol_runner.current_stimulus.paint(p, w, h) except AttributeError: pass else: p.drawRect(QRect(-1, -1, w + 2, h + 2)) p.setRenderHint(QPainter.SmoothPixmapTransform, 1) if self.img is not None: p.drawImage(QPoint(0, 0), self.img) if self.calibrator is not None: if self.calibrator.enabled: self.calibrator.paint_calibration_pattern(p, h, w) p.end()