本文整理匯總了Python中PySide2.QtCore.QPoint方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QPoint方法的具體用法?Python QtCore.QPoint怎麽用?Python QtCore.QPoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PySide2.QtCore
的用法示例。
在下文中一共展示了QtCore.QPoint方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: color_point
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def color_point(self, point):
if point.x() < self._rect.left():
x = self._rect.left()
elif point.x() > self._rect.left() + self._rect.width():
x = self._rect.left() + self._rect.width()
else:
x = point.x()
if point.y() < self._rect.top():
y = self._rect.top()
elif point.y() > self._rect.top() + self._rect.height():
y = self._rect.top() + self._rect.height()
else:
y = point.y()
self._color_point = QtCore.QPoint(x, y)
示例2: set_current_color
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def set_current_color(self, color):
[r, g, b] = color.getRgb()[:3]
self._angle = 360.0 - (QtGui.QColor(r, g, b).getHslF()[0] * 360.0)
self._angle = self._angle if self._angle != 720.0 else 0
x = ((((
sorted([r, g, b], reverse=True)[0] -
sorted([r, g, b])[0]) / 255.0) * self._rect.width()) +
self._rect.left())
y = ((((
255 - (sorted([r, g, b], reverse=True)[0])) / 255.0) *
self._rect.height()) + self._rect.top())
self._current_color = color
self._color_point = QtCore.QPoint(x, y)
self.repaint()
示例3: updateIndicatorPos
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def updateIndicatorPos(self, eventPos):
"""
move indicator cursor to correct position under mouse
"""
rect = self.getImageDims()
gridSize = rect.width() / self.gridSize.width()
latentSize = self.latentSize * gridSize
centerOffset = latentSize // 2
scenePos = QGraphicsView.mapToScene(self, eventPos)
scenePos -= QPointF(centerOffset, centerOffset) #center latentIndicator around mouse
roundPos = QPoint(int(gridSize * round(scenePos.x()/gridSize)), int(gridSize * round(scenePos.y()/gridSize)))
roundPos.setX(int(max(-centerOffset, min(roundPos.x(), rect.width() - ( latentSize - centerOffset )))))
roundPos.setY(int(max(-centerOffset, min(roundPos.y(), rect.height() - ( latentSize - centerOffset )))))
self._latentIndicator.setPos(roundPos)
示例4: mouseMoveEvent
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def mouseMoveEvent(self, event):
if (event.pos() - self.dragStartPosition).manhattanLength() < QApplication.startDragDistance():
return
event.accept()
print('starting drag event')
self.latentDragged.emit(self.latentCluster)
self.setActive()
width = self.mainWidget.getCurrentLatentSize()
dragPix = self.image.scaled(width, width)
drag = QDrag(self)
drag.setMimeData(QMimeData(self))
drag.setPixmap(dragPix)
drag.setHotSpot(QPoint(drag.pixmap().width() // 2, drag.pixmap().height() // 2))
self.mainWidget.viewer.setDrag(drag)
dropAction = drag.start(QtCore.Qt.MoveAction)
print('created drag with pixmap of size {}x{}'.format(width, width))
示例5: polygonCb
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def polygonCb(self, state: PolygonCb):
LOG.debug(state)
p = self._paint(self.surface)
self._brush(state.brush)
p.brush().setColor(rgb_to_qcolor(state.fg))
p.setBackground(QBrush(rgb_to_qcolor(state.bg)))
set_rop2(state.rop2, p)
# Handle background mode.
if state.brush.style in [BrushStyle.PATTERN, BrushStyle.HATCHED]:
p.setBackgroundMode(Qt.TransparentMode if state.bgMode == BACKMODE_TRANSPARENT else Qt.OpaqueMode)
polygon = QPolygon()
polygon.append(QPoint(state.x0, state.y0))
for (x, y) in state.points:
polygon.append(QPoint(x, y))
p.drawPolygon(polygon, _fill[state.fillMode])
self._end(p)
示例6: onCustomContextMenu
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def onCustomContextMenu(self, localPosition: QPoint):
"""
Show a custom context menu with a "Download file" action when a file is right-clicked.
:param localPosition: position where the user clicked.
"""
selectedFile = self.selectedFile()
if selectedFile is None:
return
globalPosition = self.listWidget.mapToGlobal(localPosition)
downloadAction = QAction("Download file")
downloadAction.setEnabled(selectedFile.type in [FileSystemItemType.File])
downloadAction.triggered.connect(self.downloadFile)
downloadRecursiveAction = QAction("Download files recursively")
downloadRecursiveAction.setEnabled(selectedFile.type in [FileSystemItemType.Directory])
downloadRecursiveAction.triggered.connect(self.downloadDirectoryRecursively)
itemMenu = QMenu()
itemMenu.addAction(downloadAction)
itemMenu.addAction(downloadRecursiveAction)
itemMenu.exec_(globalPosition)
示例7: test_level
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def test_level(level_info, qtbot):
*level_info, transparent = level_info
level_ref = LevelRef()
level_ref.load_level(*level_info)
Block._block_cache.clear()
# monkeypatch level names, since the level name data is broken atm
level_ref.level.name = current_test_name()
level_view = LevelView(None, level_ref, ContextMenu(level_ref))
level_view.transparency = transparent
level_view.draw_jumps = False
level_view.draw_grid = False
level_view.draw_autoscroll = True
rect = QRect(QPoint(0, 0), QSize(*level_ref.level.size) * 16)
level_view.setGeometry(rect)
_test_level_against_reference(level_view, qtbot)
示例8: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def __init__(self, parent=None):
super(SlippyMap, self).__init__(parent)
self._offset = QPoint()
self._tilesRect = QRect()
self._tilePixmaps = {} # Point(x, y) to QPixmap mapping
self._manager = QNetworkAccessManager()
self._url = QUrl()
# public vars
self.width = 400
self.height = 300
self.zoom = 15
self.latitude = 59.9138204
self.longitude = 10.7387413
self._emptyTile = QPixmap(TDIM, TDIM)
self._emptyTile.fill(Qt.lightGray)
self.request = QNetworkRequest()
self.cache = QNetworkDiskCache()
self.cache.setCacheDirectory(QStandardPaths.writableLocation(QStandardPaths.CacheLocation))
self._manager.setCache(self.cache)
self._manager.finished.connect(self.handleNetworkData)
示例9: download
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def download(self):
grab = None
for x in range(self._tilesRect.width()):
for y in range(self._tilesRect.height()):
tp = Point(self._tilesRect.topLeft() + QPoint(x, y))
if tp not in self._tilePixmaps:
grab = QPoint(tp)
break
if grab is None:
self._url = QUrl()
return
path = 'http://tile.openstreetmap.org/%d/%d/%d.png' % (self.zoom, grab.x(), grab.y())
self._url = QUrl(path)
self.request = QNetworkRequest()
self.request.setUrl(self._url)
self.request.setRawHeader(b'User-Agent', b'Nokia (PyQt) Graphics Dojo 1.0')
self.request.setAttribute(QNetworkRequest.User, grab)
self._manager.get(self.request)
示例10: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def __init__(self, parent=None):
super(ColorWheel, self).__init__(parent)
self._is_clicked = False
self._rect = QtCore.QRect(25, 25, 50, 50)
self._current_color = QtGui.QColor(WHITE)
self._color_point = QtCore.QPoint(150, 50)
self._current_tool = None
self._angle = 180
self.setFixedSize(100, 100)
self.initUI()
示例11: mouse_update
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def mouse_update(self, event):
if self._current_tool == 'rect':
self.color_point = event.pos()
else:
center = self._get_center()
a = QtCore.QPoint(event.pos().x(), center.y())
self._angle = get_absolute_angle_c(a=a, b=event.pos(), c=center)
self.repaint()
self.currentColorChanged.emit(self.current_color())
示例12: _get_center
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def _get_center(self):
return QtCore.QPoint(self.width() / 2, self.height() / 2)
示例13: draw_editor_center
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def draw_editor_center(painter, rect, point):
color = QtGui.QColor(200, 200, 200, 125)
painter.setPen(QtGui.QPen(color))
painter.setBrush(QtGui.QBrush(color))
painter.drawRect(rect)
path = get_center_path(QtCore.QPoint(*point))
pen = QtGui.QPen(QtGui.QColor(50, 125, 255))
pen.setWidth(2)
painter.setPen(pen)
painter.drawPath(path)
示例14: get_center_path
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def get_center_path(point):
ext = 12
int_ = 5
path = QtGui.QPainterPath(point)
path.moveTo(QtCore.QPoint(point.x() - ext, point.y()))
path.lineTo(QtCore.QPoint(point.x() - int_, point.y()))
path.moveTo(QtCore.QPoint(point.x() + int_, point.y()))
path.lineTo(QtCore.QPoint(point.x() + ext, point.y()))
path.moveTo(QtCore.QPoint(point.x(), point.y() - ext))
path.lineTo(QtCore.QPoint(point.x(), point.y() - int_))
path.moveTo(QtCore.QPoint(point.x(), point.y() + int_))
path.lineTo(QtCore.QPoint(point.x(), point.y() + ext))
path.addEllipse(point, 1, 1)
return path
示例15: get_relative_point
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QPoint [as 別名]
def get_relative_point(rect, point):
x = point.x() - rect.left()
y = point.y() - rect.top()
return QtCore.QPoint(x, y)