本文整理汇总了Python中AnyQt.QtGui.QPixmap.devicePixelRatioF方法的典型用法代码示例。如果您正苦于以下问题:Python QPixmap.devicePixelRatioF方法的具体用法?Python QPixmap.devicePixelRatioF怎么用?Python QPixmap.devicePixelRatioF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QPixmap
的用法示例。
在下文中一共展示了QPixmap.devicePixelRatioF方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from AnyQt.QtGui import QPixmap [as 别名]
# 或者: from AnyQt.QtGui.QPixmap import devicePixelRatioF [as 别名]
def __init__(self, parent=None, filename=None):
super(MainForm, self).__init__(parent)
self.view = GraphicsView()
background = QPixmap(filename)
# assume screnshots were taken on the same system stamper is being used on
# DPI check might be more robust, can be added if needed
background.setDevicePixelRatio(self.devicePixelRatioF())
self.filename = os.path.splitext(filename)[0]
if ("-%s" % ORG) in self.filename:
self.filename = self.filename[:-len(ORG)-5] + ".png"
# self.view.setBackgroundBrush(QBrush(background))
# self.view.setCacheMode(QGraphicsView.CacheBackground)
# self.view.setDragMode(QGraphicsView.ScrollHandDrag)
self.scene = QGraphicsScene(self)
self.scene.addPixmap(background)
global scene
scene = self.scene
self.view.dialog = self
self.view.setScene(self.scene)
self.prevPoint = QPoint()
self.lastStamp = -1
buttonLayout = QVBoxLayout()
for text, slot in (
("&Tag", self.addTag),
("Align &bottom", self.alignBottom),
("Align &left", self.alignLeft),
("&Save", self.save),
("&Quit", self.accept)):
button = QPushButton(text)
button.clicked.connect(slot)
if not MAC:
button.setFocusPolicy(Qt.NoFocus)
self.lineedit.returnPressed.connect(self.updateUi)
if text == "&Save":
buttonLayout.addStretch(5)
if text == "&Quit":
buttonLayout.addStretch(1)
buttonLayout.addWidget(button)
buttonLayout.addStretch()
size = background.size() / background.devicePixelRatioF()
self.view.resize(size.width(), size.height())
self.scene.setSceneRect(0, 0, size.width(), size.height())
self.view.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
layout = QHBoxLayout()
layout.addWidget(self.view, 1)
layout.addLayout(buttonLayout)
self.setLayout(layout)
self.setWindowTitle(AppName)
info_name = self.filename + "-" + TAG + ".txt"
if os.path.exists(info_name):
for tag, x, y in [line.strip().split("\t") for line in open(info_name, "rt").readlines()]:
self.addTag(int(tag), QPointF(int(x), int(y)), adjust_position=False)
global Dirty; Dirty=False
self.show()
self.raise_()