本文整理汇总了Python中PyQt5.QtCore.Qt.RightButton方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.RightButton方法的具体用法?Python Qt.RightButton怎么用?Python Qt.RightButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.RightButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def mousePressEvent(self, event):
super(QGraphicsView, self).mousePressEvent(event)
#==============================================================================
# Zoom to rectangle, from
# https://wiki.python.org/moin/PyQt/Selecting%20a%20region%20of%20a%20widget
#==============================================================================
if event.button() == Qt.RightButton:
self._mousePressed = Qt.RightButton
self._rb_origin = QPoint(event.pos())
self.rubberBand.setGeometry(QRect(self._rb_origin, QSize()))
self.rubberBand.show()
#==============================================================================
# Mouse panning, taken from
# http://stackoverflow.com/a/15043279
#==============================================================================
elif event.button() == Qt.MidButton:
self._mousePressed = Qt.MidButton
self._mousePressedPos = event.pos()
self.setCursor(QtCore.Qt.ClosedHandCursor)
self._dragPos = event.pos()
示例2: mouseMoveEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def mouseMoveEvent(self, event):
super(QGraphicsView, self).mouseMoveEvent(event)
# # Useful debug
# try:
# self.debug_label.setText(str(itemsBoundingRect_nogrid().width()))
# except:
# print('Debug statement failed')
# Update the X,Y label indicating where the mouse is on the geometry
mouse_position = self.mapToScene(event.pos())
self.mouse_position = [mouse_position.x(), mouse_position.y()]
self.update_mouse_position_label()
if not self._rb_origin.isNull() and self._mousePressed == Qt.RightButton:
self.rubberBand.setGeometry(QRect(self._rb_origin, event.pos()).normalized())
# Middle-click-to-pan
if self._mousePressed == Qt.MidButton:
newPos = event.pos()
diff = newPos - self._dragPos
self._dragPos = newPos
self.horizontalScrollBar().setValue(self.horizontalScrollBar().value() - diff.x())
self.verticalScrollBar().setValue(self.verticalScrollBar().value() - diff.y())
# event.accept()
示例3: mouseReleaseEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def mouseReleaseEvent(self, event):
if event.button() == Qt.RightButton:
self.rubberBand.hide()
rb_rect = QRect(self._rb_origin, event.pos())
rb_center = rb_rect.center()
rb_size = rb_rect.size()
if abs(rb_size.width()) > 3 and abs(rb_size.height()) > 3:
viewport_size = self.viewport().geometry().size()
zoom_factor_x = abs(viewport_size.width() / rb_size.width())
zoom_factor_y = abs(viewport_size.height() / rb_size.height())
new_center = self.mapToScene(rb_center)
zoom_factor = min(zoom_factor_x, zoom_factor_y)
self.zoom_view(zoom_factor)
self.centerOn(new_center)
self.update_grid()
if event.button() == Qt.MidButton:
self.setCursor(Qt.ArrowCursor)
self._mousePressed = None
self.update_grid()
示例4: text_mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def text_mousePressEvent(self, e):
if e.button() == Qt.LeftButton and self.current_pos is None:
self.current_pos = e.pos()
self.current_text = ""
self.timer_event = self.text_timerEvent
elif e.button() == Qt.LeftButton:
self.timer_cleanup()
# Draw the text to the image
p = QPainter(self.pixmap())
p.setRenderHints(QPainter.Antialiasing)
font = build_font(self.config)
p.setFont(font)
pen = QPen(self.primary_color, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
p.setPen(pen)
p.drawText(self.current_pos, self.current_text)
self.update()
self.reset_mode()
elif e.button() == Qt.RightButton and self.current_pos:
self.reset_mode()
示例5: mouseMoveEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def mouseMoveEvent(self,event):
pos = event.pos()
x,y = pos.x(),pos.y()
if event.buttons() == Qt.LeftButton:
self.view.Rotation(x,y)
elif event.buttons() == Qt.MiddleButton:
self.view.Pan(x - self.old_pos.x(),
self.old_pos.y() - y, theToStart=True)
elif event.buttons() == Qt.RightButton:
self.view.ZoomAtPoint(self.old_pos.x(), y,
x, self.old_pos.y())
self.old_pos = pos
示例6: mouseReleaseEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def mouseReleaseEvent(self, event):
""" Stop mouse pan or zoom mode (apply zoom if valid).
"""
QGraphicsView.mouseReleaseEvent(self, event)
scenePos = self.mapToScene(event.pos())
if event.button() == Qt.LeftButton:
self.setDragMode(QGraphicsView.NoDrag)
self.leftMouseButtonReleased.emit(scenePos.x(), scenePos.y())
elif event.button() == Qt.RightButton:
if self.canZoom:
viewBBox = self.zoomStack[-1] if len(self.zoomStack) else self.sceneRect()
selectionBBox = self.scene.selectionArea().boundingRect().intersected(viewBBox)
self.scene.setSelectionArea(QPainterPath()) # Clear current selection area.
if selectionBBox.isValid() and (selectionBBox != viewBBox):
self.zoomStack.append(selectionBBox)
self.updateViewer()
self.setDragMode(QGraphicsView.NoDrag)
self.rightMouseButtonReleased.emit(scenePos.x(), scenePos.y())
示例7: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def mousePressEvent(self, ev):
ctrl, shift = self._GetCtrlShift(ev)
repeat = 0
if ev.type() == QEvent.MouseButtonDblClick:
repeat = 1
self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
ctrl, shift, chr(0), repeat, None)
self._ActiveButton = ev.button()
if self._ActiveButton == Qt.LeftButton:
self._Iren.LeftButtonPressEvent()
elif self._ActiveButton == Qt.RightButton:
self._Iren.RightButtonPressEvent()
elif self._ActiveButton == Qt.MidButton:
self._Iren.MiddleButtonPressEvent()
示例8: on_mb_click
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def on_mb_click(self, event, addr, size, mouse_offs):
button = event.button()
if button == Qt.MiddleButton:
mouse = addr+mouse_offs
c = get_byte(mouse)
head, name, size = self._get_item_info(mouse)
funcname = self._get_func_name(mouse)
self.ann = [(mouse, qRgb(c, 0xFF, self.hl_color), "Address: %X" % (mouse), qRgb(c, 0xFF, self.hl_color)),
(None, None, " Item: %s" % (name), qRgb(c, 0xFF, self.hl_color)),
(None, None, " Head: %X" % (head), qRgb(c, 0xFF, self.hl_color)),
(None, None, " Size: %d" % (size), qRgb(c, 0xFF, self.hl_color))
]
if funcname:
self.ann.append((None, None, " Function: %s" % (funcname), qRgb(c, 0xFF, self.hl_color)))
self.last_sel = (head, size)
elif button == Qt.MiddleButton:
pass
elif button == Qt.RightButton:
self.switch ^= 1
msg('Highlighting %s\n' % self.mode[self.switch])
示例9: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def mousePressEvent(self, ev):
ctrl, shift = self._GetCtrlShift(ev)
repeat = 0
if ev.type() == QEvent.MouseButtonDblClick:
repeat = 1
self._Iren.SetEventInformationFlipY(
ev.x(), ev.y(), ctrl, shift, chr(0), repeat, None
)
self._ActiveButton = ev.button()
if self._ActiveButton == Qt.LeftButton:
self._Iren.LeftButtonPressEvent()
elif self._ActiveButton == Qt.RightButton:
self._Iren.RightButtonPressEvent()
elif self._ActiveButton == Qt.MidButton:
self._Iren.MiddleButtonPressEvent()
示例10: right_click
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def right_click(self) -> None:
"""Simulate a right-click on the element."""
self._click_fake_event(usertypes.ClickTarget.normal,
button=Qt.RightButton)
示例11: _handle_mouse_press
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def _handle_mouse_press(self, e):
"""Handle pressing of a mouse button.
Args:
e: The QMouseEvent.
Return:
True if the event should be filtered, False otherwise.
"""
is_rocker_gesture = (config.val.input.mouse.rocker_gestures and
e.buttons() == Qt.LeftButton | Qt.RightButton)
if e.button() in [Qt.XButton1, Qt.XButton2] or is_rocker_gesture:
self._mousepress_backforward(e)
return True
self._ignore_wheel_event = True
pos = e.pos()
if pos.x() < 0 or pos.y() < 0:
log.mouse.warning("Ignoring invalid click at {}".format(pos))
return False
if e.button() != Qt.NoButton:
self._tab.elements.find_at_pos(pos, self._mousepress_insertmode_cb)
return False
示例12: _mousepress_backforward
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def _mousepress_backforward(self, e):
"""Handle back/forward mouse button presses.
Args:
e: The QMouseEvent.
Return:
True if the event should be filtered, False otherwise.
"""
if (not config.val.input.mouse.back_forward_buttons and
e.button() in [Qt.XButton1, Qt.XButton2]):
# Back and forward on mice are disabled
return
if e.button() in [Qt.XButton1, Qt.LeftButton]:
# Back button on mice which have it, or rocker gesture
if self._tab.history.can_go_back():
self._tab.history.back()
else:
message.error("At beginning of history.")
elif e.button() in [Qt.XButton2, Qt.RightButton]:
# Forward button on mice which have it, or rocker gesture
if self._tab.history.can_go_forward():
self._tab.history.forward()
else:
message.error("At end of history.")
示例13: mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def mousePressEvent(self, e):
"""Clear messages when they are clicked on."""
if e.button() in [Qt.LeftButton, Qt.MiddleButton, Qt.RightButton]:
self.clear_messages()
示例14: selectpoly_mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def selectpoly_mousePressEvent(self, e):
if not self.locked or e.button == Qt.RightButton:
self.active_shape_fn = 'drawPolygon'
self.preview_pen = SELECTION_PEN
self.generic_poly_mousePressEvent(e)
示例15: dropper_mousePressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import RightButton [as 别名]
def dropper_mousePressEvent(self, e):
c = self.pixmap().toImage().pixel(e.pos())
hex = QColor(c).name()
if e.button() == Qt.LeftButton:
self.set_primary_color(hex)
self.primary_color_updated.emit(hex) # Update UI.
elif e.button() == Qt.RightButton:
self.set_secondary_color(hex)
self.secondary_color_updated.emit(hex) # Update UI.
# Generic shape events: Rectangle, Ellipse, Rounded-rect