Python qtpy.QtCore.QRect() Examples
The following are 3
code examples of qtpy.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
qtpy.QtCore
, or try the search function
.
Example #1
Source File: prompt.py From pyqtconsole with MIT License | 6 votes |
def paintEvent(self, event): edit = self.edit height = edit.fontMetrics().height() block = edit.firstVisibleBlock() count = block.blockNumber() painter = QPainter(self) painter.fillRect(event.rect(), edit.palette().base()) first = True while block.isValid(): count += 1 block_top = edit.blockBoundingGeometry(block).translated( edit.contentOffset()).top() if not block.isVisible() or block_top > event.rect().bottom(): break rect = QRect(0, block_top, self.width(), height) self.draw_block(painter, rect, block, first) first = False block = block.next() painter.end() super(PromptArea, self).paintEvent(event)
Example #2
Source File: iconic_font.py From qtawesome with MIT License | 5 votes |
def pixmap(self, size, mode, state): pm = QPixmap(size) pm.fill(Qt.transparent) self.paint(QPainter(pm), QRect(QPoint(0, 0), size), mode, state) return pm
Example #3
Source File: graph_view.py From pyflowgraph with BSD 3-Clause "New" or "Revised" License | 4 votes |
def frameNodes(self, nodes): if len(nodes) == 0: return def computeWindowFrame(): windowRect = self.rect() windowRect.setLeft(windowRect.left() + 16) windowRect.setRight(windowRect.right() - 16) windowRect.setTop(windowRect.top() + 16) windowRect.setBottom(windowRect.bottom() - 16) return windowRect nodesRect = None for node in nodes: nodeRectF = node.transform().mapRect(node.rect()) nodeRect = QtCore.QRect(nodeRectF.x(), nodeRectF.y(), nodeRectF.width(), nodeRectF.height()) if nodesRect is None: nodesRect = nodeRect else: nodesRect = nodesRect.united(nodeRect) windowRect = computeWindowFrame() scaleX = float(windowRect.width()) / float(nodesRect.width()) scaleY = float(windowRect.height()) / float(nodesRect.height()) if scaleY > scaleX: scale = scaleX else: scale = scaleY if scale < 1.0: self.setTransform(QtGui.QTransform.fromScale(scale, scale)) else: self.setTransform(QtGui.QTransform()) sceneRect = self.sceneRect() pan = sceneRect.center() - nodesRect.center() sceneRect.translate(-pan.x(), -pan.y()) self.setSceneRect(sceneRect) # Update the main panel when reframing. self.update()