本文整理汇总了Python中PyQt5.QtGui.QWheelEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QWheelEvent方法的具体用法?Python QtGui.QWheelEvent怎么用?Python QtGui.QWheelEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui
的用法示例。
在下文中一共展示了QtGui.QWheelEvent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: event
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def event(self, e):
if not isinstance(e, (
QtCore.QEvent,
QtCore.QChildEvent,
QtCore.QDynamicPropertyChangeEvent,
QtGui.QPaintEvent,
QtGui.QHoverEvent,
QtGui.QMoveEvent,
QtGui.QEnterEvent,
QtGui.QResizeEvent,
QtGui.QShowEvent,
QtGui.QPlatformSurfaceEvent,
QtGui.QWindowStateChangeEvent,
QtGui.QKeyEvent,
QtGui.QWheelEvent,
QtGui.QMouseEvent,
QtGui.QFocusEvent,
QtGui.QHelpEvent,
QtGui.QHideEvent,
QtGui.QCloseEvent,
QtGui.QInputMethodQueryEvent,
QtGui.QContextMenuEvent,
)):
log().warning("unknown event: %r %r", e.type(), e)
return super().event(e)
示例2: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, event: QWheelEvent) -> None:
if self.parent.mediaAvailable:
if event.angleDelta().y() > 0:
self.parent.mpvWidget.frameBackStep()
else:
self.parent.mpvWidget.frameStep()
self.parent.setPlayButton(False)
event.accept()
示例3: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, event: QWheelEvent):
self.wheel_event_triggered.emit(event)
if self.capturing_data:
return
super().wheelEvent(event)
示例4: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, event: QWheelEvent) -> None:
self.parent.seekSlider.wheelEvent(event)
示例5: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, event: QWheelEvent):
adj = (event.angleDelta().y() / 120) * 0.1
self.scale(1 + adj, 1 + adj)
示例6: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, wheelEvent):
"""Overrides the wheelEvent to handle zooming.
:param QWheelEvent wheelEvent: instance of |QWheelEvent|"""
assert isinstance(wheelEvent, QtGui.QWheelEvent)
if wheelEvent.modifiers() & QtCore.Qt.ControlModifier:
self.wheelNotches.emit(wheelEvent.angleDelta().y() / 240.0)
wheelEvent.accept()
else:
super(SynchableGraphicsView, self).wheelEvent(wheelEvent)
示例7: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, event: qg.QWheelEvent) -> None:
# dividing by 120 gets number of notches on a typical scroll wheel. See QWheelEvent documentation
delta_notches = event.angleDelta().y() / 120
zoom_per_scroll_notch = 0.2
factor = 1 + zoom_per_scroll_notch * delta_notches
resulting_zoom = self._zoom * factor
if resulting_zoom < self._zoom_limits[0]:
factor = self._zoom_limits[0] / self._zoom
elif resulting_zoom > self._zoom_limits[1]:
factor = self._zoom_limits[1] / self._zoom
self.scale(factor, factor)
self._zoom *= factor
示例8: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, event: QtGui.QWheelEvent) -> None:
"""
Reimplement this method of parent to zoom in/out.
"""
delta = event.angleDelta()
if delta.y() > 0:
self._on_key_up()
elif delta.y() < 0:
self._on_key_down()
示例9: on_graphics_view_wheel_event_triggered
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def on_graphics_view_wheel_event_triggered(self, event: QWheelEvent):
self.ui.sliderYscale.wheelEvent(event)
示例10: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, event: QWheelEvent):
zoom_factor = 1.001 ** event.angleDelta().y()
self.zoom(zoom_factor, cursor_pos=event.pos())
示例11: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, event: QWheelEvent):
event.ignore()
示例12: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, a0: QtGui.QWheelEvent) -> None:
if len(self.data) == 0 and len(self.reference) == 0:
a0.ignore()
return
do_zoom_x = do_zoom_y = True
if a0.modifiers() == QtCore.Qt.ShiftModifier:
do_zoom_x = False
if a0.modifiers() == QtCore.Qt.ControlModifier:
do_zoom_y = False
if a0.angleDelta().y() > 0:
# Zoom in
a0.accept()
# Center of zoom = a0.x(), a0.y()
# We zoom in by 1/10 of the width/height.
rate = a0.angleDelta().y() / 120
if do_zoom_x:
zoomx = rate * self.chartWidth / 10
else:
zoomx = 0
if do_zoom_y:
zoomy = rate * self.chartHeight / 10
else:
zoomy = 0
absx = max(0, a0.x() - self.leftMargin)
absy = max(0, a0.y() - self.topMargin)
ratiox = absx/self.chartWidth
ratioy = absy/self.chartHeight
p1x = int(self.leftMargin + ratiox * zoomx)
p1y = int(self.topMargin + ratioy * zoomy)
p2x = int(self.leftMargin + self.chartWidth - (1 - ratiox) * zoomx)
p2y = int(self.topMargin + self.chartHeight - (1 - ratioy) * zoomy)
self.zoomTo(p1x, p1y, p2x, p2y)
elif a0.angleDelta().y() < 0:
# Zoom out
a0.accept()
# Center of zoom = a0.x(), a0.y()
# We zoom out by 1/9 of the width/height, to match zoom in.
rate = -a0.angleDelta().y() / 120
if do_zoom_x:
zoomx = rate * self.chartWidth / 9
else:
zoomx = 0
if do_zoom_y:
zoomy = rate * self.chartHeight / 9
else:
zoomy = 0
absx = max(0, a0.x() - self.leftMargin)
absy = max(0, a0.y() - self.topMargin)
ratiox = absx/self.chartWidth
ratioy = absy/self.chartHeight
p1x = int(self.leftMargin - ratiox * zoomx)
p1y = int(self.topMargin - ratioy * zoomy)
p2x = int(self.leftMargin + self.chartWidth + (1 - ratiox) * zoomx)
p2y = int(self.topMargin + self.chartHeight + (1 - ratioy) * zoomy)
self.zoomTo(p1x, p1y, p2x, p2y)
else:
a0.ignore()
示例13: wheelEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWheelEvent [as 别名]
def wheelEvent(self, a0: QtGui.QWheelEvent) -> None:
if len(self.tdrWindow.td) == 0:
a0.ignore()
return
chart_height = self.chartHeight
chart_width = self.chartWidth
do_zoom_x = do_zoom_y = True
if a0.modifiers() == QtCore.Qt.ShiftModifier:
do_zoom_x = False
if a0.modifiers() == QtCore.Qt.ControlModifier:
do_zoom_y = False
if a0.angleDelta().y() > 0:
# Zoom in
a0.accept()
# Center of zoom = a0.x(), a0.y()
# We zoom in by 1/10 of the width/height.
rate = a0.angleDelta().y() / 120
if do_zoom_x:
zoomx = rate * chart_width / 10
else:
zoomx = 0
if do_zoom_y:
zoomy = rate * chart_height / 10
else:
zoomy = 0
absx = max(0, a0.x() - self.leftMargin)
absy = max(0, a0.y() - self.topMargin)
ratiox = absx/chart_width
ratioy = absy/chart_height
# TODO: Change zoom to center on the mouse if possible,
# or extend box to the side that has room if not.
p1x = int(self.leftMargin + ratiox * zoomx)
p1y = int(self.topMargin + ratioy * zoomy)
p2x = int(self.leftMargin + chart_width - (1 - ratiox) * zoomx)
p2y = int(self.topMargin + chart_height - (1 - ratioy) * zoomy)
self.zoomTo(p1x, p1y, p2x, p2y)
elif a0.angleDelta().y() < 0:
# Zoom out
a0.accept()
# Center of zoom = a0.x(), a0.y()
# We zoom out by 1/9 of the width/height, to match zoom in.
rate = -a0.angleDelta().y() / 120
if do_zoom_x:
zoomx = rate * chart_width / 9
else:
zoomx = 0
if do_zoom_y:
zoomy = rate * chart_height / 9
else:
zoomy = 0
absx = max(0, a0.x() - self.leftMargin)
absy = max(0, a0.y() - self.topMargin)
ratiox = absx/chart_width
ratioy = absy/chart_height
p1x = int(self.leftMargin - ratiox * zoomx)
p1y = int(self.topMargin - ratioy * zoomy)
p2x = int(self.leftMargin + chart_width + (1 - ratiox) * zoomx)
p2y = int(self.topMargin + chart_height + (1 - ratioy) * zoomy)
self.zoomTo(p1x, p1y, p2x, p2y)
else:
a0.ignore()