本文整理汇总了Python中PyQt5.QtCore.QSizeF方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QSizeF方法的具体用法?Python QtCore.QSizeF怎么用?Python QtCore.QSizeF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QSizeF方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def __init__(self, page_size, print_pdf=False):
super().__init__(page_size)
self._printer = QPrinter(QPrinter.HighResolution)
self._printer.setFullPage(True)
self._printer.setPageSize(QtGui.QPageSize(QtCore.QSizeF(*page_size),
QtGui.QPageSize.Millimeter))
self._printer.setColorMode(QPrinter.Color)
logging.info('Using printer "%s"', self._printer.printerName())
self._print_pdf = print_pdf
if self._print_pdf:
logging.info('Using PDF printer')
self._counter = 0
self._printer.setOutputFormat(QPrinter.PdfFormat)
示例2: _on_contents_size_changed
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def _on_contents_size_changed(self, size):
self.contents_size_changed.emit(QSizeF(size))
示例3: _breathing_gi_hover
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def _breathing_gi_hover(self):
if mc.mc_global.breathing_state == mc.mc_global.BreathingState.breathing_in:
return
hover_rectangle_qsize = QtCore.QSizeF(BR_WIDTH_FT, BR_HEIGHT_FT)
# noinspection PyCallByClass
pos_pointf = QtWidgets.QGraphicsItem.mapFromItem(
self._breathing_gi,
self._breathing_gi,
self._breathing_gi.x() + (self._breathing_gi.boundingRect().width() - hover_rectangle_qsize.width()) / 2,
self._breathing_gi.y() + (self._breathing_gi.boundingRect().height() - hover_rectangle_qsize.height()) / 2
)
# -widget coords
hover_rectangle_coords_qrect = QtCore.QRectF(pos_pointf, hover_rectangle_qsize)
cursor = QtGui.QCursor() # -screen coords
cursor_pos_widget_coords_qp = self.mapFromGlobal(cursor.pos()) # -widget coords
logging.debug("cursor.pos() = " + str(cursor.pos()))
logging.debug("cursor_pos_widget_coords_qp = " + str(cursor_pos_widget_coords_qp))
logging.debug("hover_rectangle_coords_qrect = " + str(hover_rectangle_coords_qrect))
if hover_rectangle_coords_qrect.contains(cursor_pos_widget_coords_qp):
mc.mc_global.breathing_state = mc.mc_global.BreathingState.breathing_in
self.ib_signal.emit()
self.text_gi.update_pos_and_origin_point(VIEW_WIDTH_INT, VIEW_HEIGHT_INT)
self._breathing_gi.update_pos_and_origin_point(VIEW_WIDTH_INT, VIEW_HEIGHT_INT)
示例4: create_pages
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def create_pages(self, text_mode=None):
# Return to this value after page calcuation is done
cursorTop = self.cursorForPosition(QtCore.QPoint(0, 0))
# No changes in mode
# if text_mode == self.text_mode:
# return
# Account for resizeEvent
if not text_mode:
if self.text_mode == 'flow':
return
text_mode = self.text_mode
# Single Page mode
page_width = self.viewport().size().width()
page_height = self.viewport().size().height()
# Flow mode
if text_mode == 'flow':
page_height = -1
# TODO
# See what's an appropriate value to pad the text with
# profile_index = self.bookToolBar.profileBox.currentIndex()
# current_profile = self.bookToolBar.profileBox.itemData(
# profile_index, QtCore.Qt.UserRole)
# padding = 20
# Double page mode
if text_mode == 'doublePage':
page_width = page_width // 2 - 10
self.text_mode = text_mode
self.document().setPageSize(
QtCore.QSizeF(page_width, page_height))
self.generate_page_positions()
self.set_page(cursorTop)
示例5: reset_view
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def reset_view(self):
# The SceneRect controls how far you can pan, make it larger than
# just the bounding box so middle-click panning works
panning_rect = QRectF(self.scene_bounding_rect)
panning_rect_center = panning_rect.center()
panning_rect_size = max(panning_rect.width(), panning_rect.height())*3
panning_rect.setSize(QSizeF(panning_rect_size, panning_rect_size))
panning_rect.moveCenter(panning_rect_center)
self.setSceneRect(panning_rect)
self.fitInView(self.scene_bounding_rect, Qt.KeepAspectRatio)
self.zoom_view(0.8)
self.update_grid()
示例6: getSize
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def getSize(self, size) -> QSizeF:
if size in self._sizes:
return self._sizes[size]
Logger.log("w", "No size %s defined in Theme", size)
return QSizeF()
示例7: _initializeDefaults
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def _initializeDefaults(self) -> None:
self._fonts = {
"system": QCoreApplication.instance().font(),
"fixed": QFontDatabase.systemFont(QFontDatabase.FixedFont)
}
palette = QCoreApplication.instance().palette()
self._colors = {
"system_window": palette.window(),
"system_text": palette.text()
}
self._sizes = {
"line": QSizeF(self._em_width, self._em_height)
}
示例8: test_getKnownSize
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def test_getKnownSize(theme):
assert theme.getSize("test_size") == QSizeF(42, 1337)
示例9: test_getUnknownSize
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def test_getUnknownSize(theme):
assert theme.getSize("Dunno?") == QSizeF()
示例10: calculateTextSize
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def calculateTextSize(text):
"""
Calculates the size of text. Crops to 96 pixels wide.
"""
fontMetrics = QtGui.QFontMetrics(QtGui.QFont())
fontRect = fontMetrics.boundingRect(QtCore.QRect(0, 0, 96, 48), Qt.TextWordWrap, text)
w, h = fontRect.width(), fontRect.height()
return QtCore.QSizeF(min(w, 96), h)
示例11: _linetool_annotate_point
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def _linetool_annotate_point(self, point, idx):
annotation = QgsTextAnnotation()
c = QTextDocument()
html = "<strong>" + str(idx) + "</strong>"
c.setHtml(html)
annotation.setDocument(c)
annotation.setFrameSize(QSizeF(27, 20))
annotation.setFrameOffsetFromReferencePoint(QPointF(5, 5))
annotation.setMapPosition(point)
annotation.setMapPositionCrs(self.map_crs)
return QgsMapCanvasAnnotationItem(annotation, self._iface.mapCanvas()).annotation()
示例12: run
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def run(self, path):
"""
Perform PDF document generation.
:type path: str
"""
shape = self.diagram.visibleRect(margin=20)
if shape:
LOGGER.info('Exporting diagram %s to %s', self.diagram.name, path)
printer = QtPrintSupport.QPrinter(QtPrintSupport.QPrinter.HighResolution)
printer.setOutputFormat(QtPrintSupport.QPrinter.PdfFormat)
printer.setOutputFileName(path)
printer.setPaperSize(QtPrintSupport.QPrinter.Custom)
printer.setPageSize(QtGui.QPageSize(QtCore.QSizeF(shape.width(), shape.height()), QtGui.QPageSize.Point))
painter = QtGui.QPainter()
if painter.begin(printer):
# TURN CACHING OFF
for item in self.diagram.items():
if item.isNode() or item.isEdge():
item.setCacheMode(AbstractItem.NoCache)
# RENDER THE DIAGRAM IN THE PAINTER
self.diagram.render(painter, source=shape)
# TURN CACHING ON
for item in self.diagram.items():
if item.isNode() or item.isEdge():
item.setCacheMode(AbstractItem.DeviceCoordinateCache)
# COMPLETE THE EXPORT
painter.end()
# OPEN THE DOCUMENT
openPath(path)
示例13: boundingRect
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def boundingRect(self) -> qc.QRectF:
return qc.QRectF(self.pos, qc.QSizeF(1, 1))
示例14: set_page_size
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def set_page_size(self, qrect):
self.doc_width = qrect.width()
self.doc_height = qrect.height()
self.setFixedSize(qtc.QSize(self.doc_width, self.doc_height))
self.document().setPageSize(
qtc.QSizeF(self.doc_width, self.doc_height))
开发者ID:PacktPublishing,项目名称:Mastering-GUI-Programming-with-Python,代码行数:8,代码来源:invoice_maker_printable.py
示例15: mousePressEvent
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSizeF [as 别名]
def mousePressEvent(self, event):
# grabbing the position of the widget
sp = self.mapToScene(event.pos())
ret = self.scene().areaAt(sp)
edge = ret % 100
iArea = int(ret / 100) - 1
# resizing/moving the area if it exists
if edge:
self.bResizing = True
self.resizingEdge = edge
self.resizingArea = self.scene().areas[iArea]
self.resizingStartingPos = sp
self.resizingAreaRect = self.resizingArea.rect()
self.resizingAreaPos = self.resizingArea.pos()
self.resizingArea.setFlag(QGraphicsItem.ItemIsMovable, False)
# creation of a new area if there is an image
elif iArea == -1 and self.filename:
size = QSizeF(0, 0)
newArea = self.scene().createArea(sp,
size, self.areaType, self.areaBorder,
self.areaTextSize)
self.bResizing = True
self.resizingEdge = 10
self.resizingArea = newArea
self.resizingStartingPos = sp
self.resizingAreaRect = self.resizingArea.rect()
self.resizingAreaPos = self.resizingArea.pos()
self.resizingArea.setFlag(QGraphicsItem.ItemIsMovable, False)
QGraphicsView.mousePressEvent(self, event)