def test_close_page_force_close(window, qtbot):
"""Test the Force Close Tombs on the Close tab."""
window.pages.setCurrentIndex(2)
button = window.close_page.force_close_button
qtbot.mouseClick(button, Qt.LeftButton)
python类LeftButton()的实例源码
def test_engrave_key(window, qtbot, key):
"""Test engraving the key inside a QR image."""
window.pages.setCurrentIndex(5)
window.advanced_page.key_path.setText(key)
button = window.advanced_page.engrave_button
qtbot.mouseClick(button, Qt.LeftButton)
def test_bury_key(window, qtbot, key, image_file, password):
"""Test burying the key inside the given image file."""
window.pages.setCurrentIndex(5)
window.advanced_page.key_path.setText(key)
window.advanced_page.image_path.setText(image_file)
window.advanced_page.key_password.setText(password)
button = window.advanced_page.bury_button
qtbot.mouseClick(button, Qt.LeftButton)
def exhume_bury_key(window, qtbot, image_file, password):
"""Test exhuming the key from inside the given image file."""
window.pages.setCurrentIndex(5)
window.advanced_page.image_path.setText(image_file)
window.advanced_page.key_password.setText(password)
button = window.advanced_page.exhume_button
qtbot.mouseClick(button, Qt.LeftButton)
def mouseDoubleClickEvent(self, event):
if self.currentIndex() != 0:
if event.button() != Qt.LeftButton:
super(TabBarPlus, self).mouseDoubleClickEvent(event)
idx = self.currentIndex()
ok = True
input_dialog = QInputDialog()
newName, ok = QInputDialog.getText(self, 'Mudar nome',
'Novo nome:')
if ok:
self.setTabText(idx, newName)
def mouseDoubleClickEvent(self, event):
if event.button() != Qt.LeftButton:
super(TabBarPlus, self).mouseDoubleClickEvent(event)
idx = self.currentIndex()
ok = True
self.input_dialog = QInputDialog()
print(type(self.input_dialog.textEchoMode()))
newName, ok = QInputDialog.getText(self, 'Mudar nome',
'Novo nome:')
if ok:
self.setTabText(idx, newName)
def mouseDoubleClickEvent(self, event):
if event.button() == Qt.LeftButton:
if self._selected is not None:
glyphRecord = self._glyphRecords[self._selected]
self.glyphActivated.emit(glyphRecord.glyph)
else:
super(GlyphLineWidget, self).mouseDoubleClickEvent(event)
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
selected = None
for rect, recordIndex in self._glyphRecordsRects.items():
if QRectF(*rect).contains(event.localPos()):
selected = recordIndex
if self._selected == selected:
return
self._selected = selected
self.selectionModified.emit(self._selected)
self.update()
else:
super(GlyphLineWidget, self).mousePressEvent(event)
def mousePressEvent(self, event):
if event.button() in (Qt.LeftButton, Qt.RightButton):
self._oldSelection = set(self._selection)
index = self._findIndexForEvent(event)
modifiers = event.modifiers()
if index is None:
if not (modifiers & Qt.ControlModifier or
modifiers & Qt.ShiftModifier):
# TODO: consider setSelection(None)
self.setSelection(set())
return
if modifiers & Qt.ControlModifier:
if index in self._selection:
self._selection.remove(index)
else:
self._selection.add(index)
elif modifiers & Qt.ShiftModifier:
self._selection = self._linearSelection(index)
elif index not in self._selection:
self._selection = {index}
else:
self._maybeDragPosition = event.localPos()
self._lastSelectedCell = index
self.selectionChanged.emit()
self.update()
else:
super(GlyphCellWidget, self).mousePressEvent(event)
def mouseReleaseEvent(self, event):
if event.button() in (Qt.LeftButton, Qt.RightButton):
self._maybeDragPosition = None
# XXX: we should use modifiers registered on click
if not event.modifiers() & Qt.ShiftModifier:
if self._lastSelectedCell is not None:
self._selection = {self._lastSelectedCell}
else:
self._selection = set()
self.update()
self._oldSelection = None
else:
super(GlyphCellWidget, self).mouseReleaseEvent(event)
def mouseDoubleClickEvent(self, event):
if event.button() in (Qt.LeftButton, Qt.RightButton):
index = self._findIndexForEvent(event)
if index is not None:
self.glyphActivated.emit(self._glyphs[index])
else:
super(GlyphCellWidget, self).mouseDoubleClickEvent(event)
def mouseMoveEvent(self, event):
dx = event.x() - self.lastPos.x()
dy = event.y() - self.lastPos.y()
if event.buttons() & Qt.LeftButton:
self.rotateBy(8 * dy, 8 * dx, 0)
elif event.buttons() & Qt.RightButton:
self.rotateBy(8 * dy, 0, 8 * dx)
self.lastPos = event.pos()
def mouseMoveEvent(self, event):
dx = event.x() - self.lastPos.x()
dy = event.y() - self.lastPos.y()
if event.buttons() & Qt.LeftButton:
self.setXRotation(self.xRot + 8 * dy)
self.setYRotation(self.yRot + 8 * dx)
elif event.buttons() & Qt.RightButton:
self.setXRotation(self.xRot + 8 * dy)
self.setZRotation(self.zRot + 8 * dx)
self.lastPos = event.pos()
def mouseMoveEvent(self, event):
dx = event.x() - self.lastPos.x()
dy = event.y() - self.lastPos.y()
if event.buttons() & Qt.LeftButton:
self.setXRotation(self.xRot + 8 * dy)
self.setYRotation(self.yRot + 8 * dx)
elif event.buttons() & Qt.RightButton:
self.setXRotation(self.xRot + 8 * dy)
self.setZRotation(self.zRot + 8 * dx)
self.lastPos = event.pos()
def mouseMoveEvent(self, event):
dx = event.x() - self.lastPos.x()
dy = event.y() - self.lastPos.y()
if event.buttons() & Qt.LeftButton:
self.setXRotation(self.xRot + 8 * dy)
self.setYRotation(self.yRot + 8 * dx)
elif event.buttons() & Qt.RightButton:
self.setXRotation(self.xRot + 8 * dy)
self.setZRotation(self.zRot + 8 * dx)
self.lastPos = QPoint(event.pos())
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.lastKey = (event.y() // self.squareSize) * self.columns + event.x() // self.squareSize
key_ch = self._chr(self.lastKey)
if unicodedata.category(key_ch) != 'Cn':
self.characterSelected.emit(key_ch)
self.update()
else:
super(CharacterWidget, self).mousePressEvent(event)
def mouseMoveEvent(self, event):
if event.buttons() == Qt.LeftButton:
self.move(event.globalPos() - self.dragPosition)
event.accept()
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
index = self.itemAt(event.pos())
if index != -1:
self.itemInMotion = self.shapeItems[index]
self.previousPosition = event.pos()
value = self.shapeItems[index]
del self.shapeItems[index]
self.shapeItems.insert(len(self.shapeItems) - 1, value)
self.update()
def mouseMoveEvent(self, event):
if (event.buttons() & Qt.LeftButton) and self.itemInMotion:
self.moveItemTo(event.pos())
def mouseReleaseEvent(self, event):
if (event.button() == Qt.LeftButton) and self.itemInMotion:
self.moveItemTo(event.pos())
self.itemInMotion = None