本文整理汇总了Python中PyQt5.QtCore.QPoint类的典型用法代码示例。如果您正苦于以下问题:Python QPoint类的具体用法?Python QPoint怎么用?Python QPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CanvasView
class CanvasView(QtCanvasView):
itemClickedSignal = pyqtSignal(QtCanvasItem)
itemMovedSignal = pyqtSignal(QtCanvasItem)
def __init__(self, arg1=None, arg2=None):
if type(arg1)==QtCanvas:
super(CanvasView, self).__init__(arg1, arg2)
else:
super(CanvasView, self).__init__(arg1)
self.moving = QtCanvasItem(None)
self.moving_start = QPoint()
def contentsMousePressEvent(self, event):
self.handleMouseClickEvent(event)
def contentsMouseDoubleClickEvent(self, event):
self.handleMouseClickEvent(event)
def handleMouseClickEvent(self, event):
p = self.inverseWorldMatrix().map(event.pos())
l = self.canvas().collisions(p)
self.moving = QtCanvasItem(None)
if (not l.isEmpty()):
self.moving = l.first()
self.moving_start = p
self.itemClickedSignal.emit(self.moving)
def contentsMouseMoveEvent(self, event):
if (self.moving):
p = self.inverseWorldMatrix().map(event.pos())
self.moving.moveBy(p.x() - self.moving_start.x(), p.y() - self.moving_start.y())
self.moving_start = p
self.canvas().update()
self.itemMovedSignal.emit(self.moving)
示例2: __updateOrdAbsPos
def __updateOrdAbsPos(self):
# FIXME : handle the case where size.height() < self.MARGIN
size = self.size()
self.max_ord_pos = QPoint(self.MARGIN, self.MARGIN)
self.max_abs_pos = QPoint(size.width() - self.MARGIN,
size.height() - self.MARGIN)
self.zero_pos = QPoint(self.MARGIN, size.height() - self.MARGIN)
示例3: click
def click():
window_name = get_window_name()
query_value = get_query_value()
automation_type = get_query_automation_type()
widget = find_widget(window_name, query_value, automation_type)
if widget is None:
return {}
if isinstance(widget, QWidget):
clicker.click_on(widget)
return get_widget_json(widget)
if isinstance(widget, QQuickItem):
pointf = widget.mapToScene(QPointF(0.0, 0.0))
x = pointf.x()
y = pointf.y()
x += qml_method_or_default(widget, "width", 0.0) / 2.0
y += qml_method_or_default(widget, "height", 0.0) / 2.0
window_name = get_window_name()
root_widget = get_root_widget(window_name)
point = QPoint(x,y)
quick_widget = root_widget.childAt(point.x(), point.y())
clicker.click_on(quick_widget, point)
return get_widget_json(widget)
return {}
示例4: __init__
def __init__(self, parent, binpath):
super().__init__(parent)
sizePolicy = QSizePolicy()
sizePolicy.setHorizontalPolicy(QSizePolicy.Maximum)
sizePolicy.setVerticalPolicy(QSizePolicy.Maximum)
#self.setSizePolicy(sizePolicy)
self.setMouseTracking(True)
self.on_selection = False
self.selected = False
self.c = Communicate()
self.start_position = QPoint(0,0)
self.last_position = QPoint(0,0)
image = (
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\xFF\xFF\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00"
b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00"
b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00"
b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00"
b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00"
b"\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\xFF\xFF\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
im = QImage(image, 8,8, QImage.Format_RGB16)
im = im.scaled(64,64)
self.crop = QPixmap()
self.crop.convertFromImage(im)
示例5: dropEvent
def dropEvent(self, event):
if event.mimeData().hasText():
mime = event.mimeData()
pieces = mime.text().split()
position = event.pos()
hotSpot = QPoint()
hotSpotPos = mime.data('application/x-hotspot').split(' ')
if len(hotSpotPos) == 2:
hotSpot.setX(hotSpotPos[0].toInt()[0])
hotSpot.setY(hotSpotPos[1].toInt()[0])
for piece in pieces:
newLabel = DragLabel(piece, self)
newLabel.move(position - hotSpot)
newLabel.show()
position += QPoint(newLabel.width(), 0)
if event.source() in self.children():
event.setDropAction(Qt.MoveAction)
event.accept()
else:
event.acceptProposedAction()
else:
event.ignore()
示例6: __init__
def __init__(self,parent=None):
super(Winform,self).__init__(parent)
self.setWindowTitle("绘制矩形图形例子")
self.pix = QPixmap()
self.lastPoint = QPoint()
self.endPoint = QPoint()
self.initUi()
示例7: snapToGrid
def snapToGrid(self, position):
#Return position of closest grid point
gridSizeX = 40
gridSizeY = 20
curPos = QPoint(position.x(), position.y())
gridPos = QPoint(round(curPos.x() / gridSizeX) * gridSizeX, round(curPos.y() / gridSizeY) * gridSizeY)
return gridPos
示例8: get_linear_gradient
def get_linear_gradient(self):
fontHeight = self.fontMetrics().height()
startPoint = QPoint(self.rect().x(), self.rect().y() + 0.5 * (self.rect().height() - fontHeight))
endPoint = QPoint(startPoint.x(), startPoint.y() + fontHeight)
linear = QLinearGradient(startPoint, endPoint)
colorCounts = len(self.colors)
for i in range(colorCounts):
linear.setColorAt(0.2 + i / colorCounts, self.colors[i])
return linear
示例9: __init__
def __init__(self,parent=None):
super(Winform,self).__init__(parent)
self.setWindowTitle("双缓冲绘图例子")
self.pix = QPixmap()
self.lastPoint = QPoint()
self.endPoint = QPoint()
# 辅助画布
self.tempPix = QPixmap()
# 标志是否正在绘图
self.isDrawing = False
self.initUi()
示例10: Winform
class Winform(QWidget):
def __init__(self,parent=None):
super(Winform,self).__init__(parent)
self.setWindowTitle("双缓冲绘图例子")
self.pix = QPixmap()
self.lastPoint = QPoint()
self.endPoint = QPoint()
# 辅助画布
self.tempPix = QPixmap()
# 标志是否正在绘图
self.isDrawing = False
self.initUi()
def initUi(self):
#窗口大小设置为600*500
self.resize(600, 500);
# 画布大小为400*400,背景为白色
self.pix = QPixmap(400, 400);
self.pix.fill(Qt.white);
def paintEvent(self,event):
painter = QPainter(self)
x = self.lastPoint.x()
y = self.lastPoint.y()
w = self.endPoint.x() - x
h = self.endPoint.y() - y
# 如果正在绘图,就在辅助画布上绘制
if self.isDrawing :
# 将以前pix中的内容复制到tempPix中,保证以前的内容不消失
self.tempPix = self.pix
pp = QPainter( self.tempPix)
pp.drawRect(x,y,w,h)
painter.drawPixmap(0, 0, self.tempPix)
else :
pp = QPainter(self.pix )
pp.drawRect(x, y, w, h)
painter.drawPixmap(0, 0, self.pix)
def mousePressEvent(self, event) :
# 鼠标左键按下
if event.button() == Qt.LeftButton :
self.lastPoint = event.pos()
self.endPoint = self.lastPoint
self.isDrawing = True
def mouseReleaseEvent( self, event):
# 鼠标左键释放
if event.button() == Qt.LeftButton :
self.endPoint = event.pos()
#进行重新绘制
self.update()
self.isDrawing = False
示例11: Text
class Bullet:
"""Bullet contains:
1 StartPosition
2 EndPosition
3 Color
4 Text( A String)
5 Duration
It uses the "window" to draw it selft
"""
#这个叫做 类的属性
Count=0# 通过类名Bullet.bullet访问,就是一个静态变量
Height=GLOBAL.BULLETFONTSIZE+6 #一个Bullet占用的像素高度
def __init__(self, Text, Color,Duration):
Bullet.Count+=1
#这个里面self给定的内容则只属于当前对象
self.Text=Text
self.Color=Color
self.Duration=Duration*1000 #单位是毫秒,输入的是秒
self.IsExpired=False
"""this method must be called when this
bullet is ready to shoot at the first time
"""
def prepare(self):
self.elapsedTimer=QElapsedTimer()
self.elapsedTimer.start() #start time
self.StartPosition=QPoint(GLOBAL.WINDOWWIDTH+random.randrange(200,500,20),\
(Bullet.Height+(Bullet.Count%(GLOBAL.WINDOWHEIGHT//Bullet.Height))*Bullet.Height))
self.EndPosition=QPoint(-2000 ,self.StartPosition.y())
"""Draw this bullet at position x,y ,use painter
Returns True indicates this bullet is out of screen
"""
def draw(self,painter):
ratio=self.elapsedTimer.elapsed()/self.Duration
if(ratio>0.9):
self.IsExpired=True
# pos=ratio*self.EndPosition+(1-ratio)*self.StartPosition
pos=QPoint(ratio*self.EndPosition.x()+(1-ratio)*self.StartPosition.x(),self.StartPosition.y())
#这里需要插入绘制字体阴影的代码
#
# font.setFixedPitch(True)
# painter.setFont(font)
painter.save()
painter.drawText(pos+QPoint(2,2),self.Text)
painter.setPen(QPen(self.Color))
painter.drawText(pos,self.Text)
painter.restore()
# def __del__(self):
# Count-=1
# print ("刚刚自动Delete了一个bullet\n")
示例12: setOffset
def setOffset(self, offset):
# Clamp the offset within the offset bounds
newOffset = QPoint(min(self.mOffsetBounds.right(),
max(self.mOffsetBounds.left(), offset.x())),
min(self.mOffsetBounds.bottom(),
max(self.mOffsetBounds.top(), offset.y())))
if (self.mOffset != newOffset):
xChanged = self.mOffset.x() != newOffset.x()
yChanged = self.mOffset.y() != newOffset.y()
self.mOffset = newOffset
if (xChanged):
self.offsetXChanged.emit(self.mOffset.x())
if (yChanged):
self.offsetYChanged.emit(self.mOffset.y())
self.offsetChanged.emit(self.mOffset)
self.update()
示例13: invalidate
def invalidate(self):
if self.width <= 0 or self.height <= 0:
return
ct = tileForCoordinate(self.latitude, self.longitude, self.zoom)
tx = ct.x()
ty = ct.y()
# top-left corner of the center tile
xp = int(self.width / 2 - (tx - math.floor(tx)) * TDIM)
yp = int(self.height / 2 - (ty - math.floor(ty)) * TDIM)
# first tile vertical and horizontal
xa = (xp + TDIM - 1) / TDIM
ya = (yp + TDIM - 1) / TDIM
xs = int(tx) - xa
ys = int(ty) - ya
# offset for top-left tile
self._offset = QPoint(xp - xa * TDIM, yp - ya * TDIM)
# last tile vertical and horizontal
xe = int(tx) + (self.width - xp - 1) / TDIM
ye = int(ty) + (self.height - yp - 1) / TDIM
# build a rect
self._tilesRect = QRect(xs, ys, xe - xs + 1, ye - ys + 1)
if self._url.isEmpty():
self.download()
self.updated.emit(QRect(0, 0, self.width, self.height))
示例14: __init__
def __init__(self, parent=None):
super(GLWidget, self).__init__(parent)
self.shapes = Shapes([])
self.orientation = 0
self.wpZero = 0
self.routearrows = []
self.expprv = None
self.isPanning = False
self.isRotating = False
self.isMultiSelect = False
self._lastPos = QPoint()
self.posX = 0.0
self.posY = 0.0
self.posZ = 0.0
self.rotX = 0.0
self.rotY = 0.0
self.rotZ = 0.0
self.scale = 1.0
self.scaleCorr = 1.0
self.showPathDirections = False
self.showDisabledPaths = False
self.topLeft = Point()
self.bottomRight = Point()
self.tol = 0
示例15: __init__
def __init__(self):
self.black = QColor(0, 0, 0)
self.colors = [QColor(255, 0, 0), QColor(0, 255, 0), QColor(0 ,0, 255),\
QColor(128, 0, 128), QColor(128, 128, 0)]
super().__init__()
self.setGeometry(100, 100, 900,500)
self.setFixedSize(1000, 500)
self.flag_rects = True
self.pen = False
hbox = QHBoxLayout()
hbox.addStretch(1)
self.b_stop_entering = QPushButton("Закончить ввод", self)
self.b_stop_entering.clicked[bool].connect(self.stop_entering)
hbox.addWidget(self.b_stop_entering)
vbox = QVBoxLayout()
vbox.addStretch(1)
vbox.addLayout(hbox)
self.setLayout(vbox)
self.setWindowTitle("Map")
self.qp = QPainter()
self.vertexes = []
self.edges = []
self.previous_point = QPoint()
self.countries = []
self.points_for_country = []