本文整理汇总了Python中qtpy.QtCore.Qt.LeftButton方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.LeftButton方法的具体用法?Python Qt.LeftButton怎么用?Python Qt.LeftButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.LeftButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_play_button
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def test_play_button(qtbot):
"""test that the play button and its popup dialog work"""
ndim = 3
view = QtDims(Dims(ndim))
qtbot.addWidget(view)
button = view.slider_widgets[0].play_button
qtbot.mouseClick(button, Qt.LeftButton)
qtbot.waitSignal(view._animation_thread.started, timeout=5000)
qtbot.wait(200)
assert view.is_playing
with qtbot.waitSignal(view._animation_thread.finished, timeout=7000):
qtbot.mouseClick(button, Qt.LeftButton)
qtbot.wait(200)
assert not view.is_playing
with patch.object(button.popup, 'show_above_mouse') as mock_popup:
qtbot.mouseClick(button, Qt.RightButton)
mock_popup.assert_called_once()
示例2: mouseReleaseEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def mouseReleaseEvent(self, ev):
self._ActiveButton = ev.button()
try:
ctrl = self._iren.GetControlKey()
except AttributeError:
return
shift = self._iren.GetShiftKey()
self._iren.SetEventInformationFlipY(ev.x(), ev.y(),
ctrl, shift, chr(0), 0, None)
if ev.button() == Qt.LeftButton:
self._iren.LeftButtonReleaseEvent()
self.Rotating = 0
self.Panning = 0
self.Rolling = 0
elif ev.button() == Qt.RightButton:
self._iren.RightButtonReleaseEvent()
self.Zooming = 0
elif ev.button() == Qt.MidButton:
self._iren.MiddleButtonReleaseEvent()
self.Panning = 0
示例3: mousePressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def mousePressEvent(self, event: QMouseEvent) -> None:
"""Press event.
Middle button: Move canvas of view.
Left button: Select the point (only first point will be catch).
"""
self.selector.x, self.selector.y = self.__mouse_pos(event)
button = event.buttons()
if button == Qt.MiddleButton:
self.selector.middle_dragged = True
self.browse_tracking.emit(self.selector.x, self.selector.y)
elif button == Qt.LeftButton:
self.selector.left_dragged = True
self.__select_func()
if self.selector.selection_rect:
self.selected.emit(tuple(self.selector.selection_rect[:1]),
True)
示例4: mouseDoubleClickEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def mouseDoubleClickEvent(self, event: QMouseEvent) -> None:
"""Mouse double click.
+ Middle button: Zoom to fit.
+ Left button: Edit point function.
"""
button = event.buttons()
if button == Qt.MidButton:
self.zoom_to_fit()
elif button == Qt.LeftButton and (not self.show_target_path):
self.selector.x, self.selector.y = self.__mouse_pos(event)
self.__select_func()
if self.selector.selection_rect:
self.selected.emit(tuple(self.selector.selection_rect[:1]),
True)
if self.free_move == FreeMode.NO_FREE_MOVE:
self.doubleclick_edit.emit(self.selector.selection_rect[0])
示例5: test_scope_widget
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def test_scope_widget(self):
if self.pyrpl is None:
return
widget = self.pyrpl.rp.scope._create_widget()
for attr in widget.attribute_widgets:
if isinstance(attr, SelectAttributeWidget):
for option in attr.options:
to_set = attr.widget.findText(str(option))
# it would be a pain to select an element with a QTest
attr.widget.setCurrentIndex(to_set)
assert (getattr(self.pyrpl.rp.scope, attr.attribute_name) == option)
elif isinstance(attr, BoolAttributeWidget):
for i in range(2):
QTest.mouseClick(attr.widget, Qt.LeftButton)
assert (getattr(self.pyrpl.rp.scope, attr.attribute_name) ==
(attr.widget.checkState() == 2))
elif isinstance(attr, NumberAttributeWidget):
for i in range(3):
attr.widget.stepUp()
assert(abs(getattr(self.pyrpl.rp.scope, attr.attribute_name) -
attr.widget.value()) < 0.0001)
示例6: try_gui_module
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def try_gui_module(self, module_widget): # name should not start with test
if not self.do_gui_tests:
return
module = module_widget.module
for attr in module._gui_attributes:
if isinstance(attr, SelectProperty):
for option in attr.options(module):
to_set = attr.widget.findText(str(option))
attr.widget.setCurrentIndex(to_set)
assert (getattr(module, attr.name) == option)
elif isinstance(attr, BoolProperty):
for i in range(2):
QTest.mouseClick(attr.widget, Qt.LeftButton)
assert (getattr(module, attr.name)
== (attr.widget.checkState() == 2))
elif isinstance(attr, NumberProperty):
for i in range(3):
attr.widget.stepUp()
val = getattr(module, attr.name)
wid_val = attr.widget.value()
err = abs((val - wid_val)/max(val, 1.))
assert(err < 0.001)
示例7: custom_change_event
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def custom_change_event(self, value):
"""Emits editingFinished if valueChanged AND left mouse button is down.
(i.e. when the user clicks on the spin buttons)
Paramters
---------
value : float
The value of this custom double spin box.
"""
if QApplication.mouseButtons() & Qt.LeftButton:
self.editingFinished.emit()
示例8: mouseReleaseEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def mouseReleaseEvent(self, event):
"""Show popup for right-click, toggle animation for right click.
Parameters
----------
event : qtpy.QtCore.QEvent
Event from the qt context.
"""
# using this instead of self.customContextMenuRequested.connect and
# clicked.connect because the latter was not sending the
# rightMouseButton release event.
if event.button() == Qt.RightButton:
self.popup.show_above_mouse()
elif event.button() == Qt.LeftButton:
self._on_click()
示例9: mouseReleaseEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def mouseReleaseEvent(self, event: QEvent):
"""Show QColorPopup picker when the user clicks on the swatch."""
if event.button() == Qt.LeftButton:
initial = QColor(*(255 * self._color).astype('int'))
popup = QColorPopup(self, initial)
popup.colorSelected.connect(self.setColor)
popup.show_right_of_mouse()
示例10: mouseMoveEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def mouseMoveEvent(self, event):
if event.buttons() & Qt.LeftButton:
# dragging with the mouse button down should move the slider
self._move_to_mouse_position(event)
return super().mouseMoveEvent(event)
示例11: mousePressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
# clicking the mouse button should move slider to the clicked point
self._move_to_mouse_position(event)
return super().mousePressEvent(event)
示例12: test_modified_scrollbar_click
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def test_modified_scrollbar_click(qtbot):
w = ModifiedScrollBar(Qt.Horizontal)
w.resize(100, 10)
assert w.value() == 0
qtbot.mousePress(w, Qt.LeftButton, pos=QPoint(50, 5))
# the normal QScrollBar would have moved to "10"
assert w.value() >= 40
示例13: mousePressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def mousePressEvent(self, event):
if not self.isEnabled():
return
pos = self.getPos(event)
top = self.rangeSliderSize() + self.handle_radius
if event.button() == Qt.LeftButton:
if not self.collapsed:
if abs(self.display_min - pos) <= (self.handle_radius):
self.moving = "min"
elif abs(self.display_max - pos) <= (self.handle_radius):
self.moving = "max"
elif pos > self.display_min and pos < self.display_max:
self.moving = "bar"
elif pos > self.display_max and pos < top:
self.display_max = pos
self.moving = "max"
self.updateValuesFromDisplay()
elif pos < self.display_min and pos > self.handle_radius:
self.display_min = pos
self.moving = "min"
self.updateValuesFromDisplay()
else:
self.moving = "bar"
if pos > self.handle_radius and pos < top:
self.display_max = pos
self.display_min = pos
else:
if self.collapsible:
if self.collapsed:
self.expand()
else:
self.collapse()
self.collapsedChanged.emit(self.collapsed)
self.start_display_min = self.display_min
self.start_display_max = self.display_max
self.start_pos = pos
self.focused.emit()
示例14: setup_reports_close_tab
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def setup_reports_close_tab(qtbot):
"""Set up reports widget, witha handy function to close tabs."""
reports = setup_reports(qtbot)
def close_tab(index):
"""Find the close button and click it."""
for i in [0, 1]: # LeftSide, RightSide
close_button = reports.tabs.tabBar().tabButton(index, i)
if close_button:
break
qtbot.mouseClick(close_button, Qt.LeftButton)
return reports, close_tab
示例15: mousePressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import LeftButton [as 别名]
def mousePressEvent(self, event):
"""Override Qt method"""
QTableView.mousePressEvent(self, event)
self.current_index = self.currentIndex()
column = self.current_index.column()
if event.button() == Qt.LeftButton and column == const.COL_ACTION:
pos = QPoint(event.x(), event.y())
index = self.indexAt(pos)
self.action_pressed(index)
self.context_menu_requested(event)
elif event.button() == Qt.RightButton:
self.context_menu_requested(event, right_click=True)
self.update_visible_rows()