本文整理汇总了Python中AnyQt.QtTest.QTest.mouseClick方法的典型用法代码示例。如果您正苦于以下问题:Python QTest.mouseClick方法的具体用法?Python QTest.mouseClick怎么用?Python QTest.mouseClick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtTest.QTest
的用法示例。
在下文中一共展示了QTest.mouseClick方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_zoom_rect
# 需要导入模块: from AnyQt.QtTest import QTest [as 别名]
# 或者: from AnyQt.QtTest.QTest import mouseClick [as 别名]
def test_zoom_rect(self):
""" Test zooming with two clicks. """
self.widget.show()
qWaitForWindow(self.widget)
self.send_signal("Data", self.iris)
vb = self.widget.curveplot.plot.vb
vb.set_mode_zooming()
vr = vb.viewRect()
QTest.qWait(100)
tls = vr.bottomRight() if self.widget.curveplot.invertX else vr.bottomLeft()
tl = vb.mapViewToScene(tls).toPoint() + QPoint(2, 2)
br = vb.mapViewToScene(vr.center()).toPoint()
tlw = vb.mapSceneToView(tl)
brw = vb.mapSceneToView(br)
ca = self.widget.curveplot.childAt(tl)
QTest.mouseClick(ca, Qt.LeftButton, pos=tl)
QTest.qWait(1)
QTest.mouseMove(self.widget.curveplot, pos=tl)
QTest.qWait(1)
QTest.mouseMove(self.widget.curveplot)
QTest.qWait(1)
QTest.mouseClick(ca, Qt.LeftButton, pos=br)
vr = vb.viewRect()
self.assertAlmostEqual(vr.bottom(), tlw.y())
self.assertAlmostEqual(vr.top(), brw.y())
if self.widget.curveplot.invertX:
self.assertAlmostEqual(vr.right(), tlw.x())
self.assertAlmostEqual(vr.left(), brw.x())
else:
self.assertAlmostEqual(vr.left(), tlw.x())
self.assertAlmostEqual(vr.right(), brw.x())
self.widget.hide()
示例2: do_zoom_rect
# 需要导入模块: from AnyQt.QtTest import QTest [as 别名]
# 或者: from AnyQt.QtTest.QTest import mouseClick [as 别名]
def do_zoom_rect(self, invertX):
""" Test zooming with two clicks. """
self.send_signal("Data", self.iris)
vb = self.widget.curveplot.plot.vb
self.widget.curveplot.invertX = invertX
self.widget.curveplot.invertX_apply()
vb.set_mode_zooming()
vr = vb.viewRect()
tls = vr.bottomRight() if self.widget.curveplot.invertX else vr.bottomLeft()
# move down to avoid clicking on the menu button
tl = vb.mapViewToScene(tls).toPoint() + QPoint(0, 100)
br = vb.mapViewToScene(vr.center()).toPoint()
tlw = vb.mapSceneToView(tl)
brw = vb.mapSceneToView(br)
ca = self.widget.curveplot.childAt(tl)
QTest.mouseClick(ca, Qt.LeftButton, pos=tl)
QTest.qWait(1)
self.widget.curveplot.plot.scene().sigMouseMoved.emit(tl)
QTest.qWait(1)
self.widget.curveplot.plot.scene().sigMouseMoved.emit(tl + QPoint(10, 10))
QTest.qWait(1)
QTest.mouseClick(ca, Qt.LeftButton, pos=br)
vr = vb.viewRect()
self.assertAlmostEqual(vr.bottom(), tlw.y())
self.assertAlmostEqual(vr.top(), brw.y())
if self.widget.curveplot.invertX:
self.assertAlmostEqual(vr.right(), tlw.x())
self.assertAlmostEqual(vr.left(), brw.x())
else:
self.assertAlmostEqual(vr.left(), tlw.x())
self.assertAlmostEqual(vr.right(), brw.x())
示例3: __set_value
# 需要导入模块: from AnyQt.QtTest import QTest [as 别名]
# 或者: from AnyQt.QtTest.QTest import mouseClick [as 别名]
def __set_value(widget, value):
if isinstance(widget, QLineEdit):
QTest.mouseClick(widget, Qt.LeftButton)
QTest.keyClicks(widget, value, delay=0)
QTest.keyClick(widget, Qt.Key_Enter)
elif isinstance(widget, QComboBox):
simulate.combobox_activate_item(widget, value)
else:
raise ValueError("Unsupported widget {}".format(widget))
示例4: select_diagonal
# 需要导入模块: from AnyQt.QtTest import QTest [as 别名]
# 或者: from AnyQt.QtTest.QTest import mouseClick [as 别名]
def select_diagonal(self):
vb = self.widget.curveplot.plot.vb
vb.set_mode_select()
vr = vb.viewRect()
tls = vr.bottomRight() if self.widget.curveplot.invertX else vr.bottomLeft()
brs = vr.topLeft() if self.widget.curveplot.invertX else vr.topRight()
tl = vb.mapViewToScene(tls).toPoint() + QPoint(2, 100) # avoid menu button
br = vb.mapViewToScene(brs).toPoint() - QPoint(2, 2)
ca = self.widget.curveplot.childAt(tl)
QTest.mouseClick(ca, Qt.LeftButton, pos=tl)
self.widget.curveplot.plot.scene().sigMouseMoved.emit(tl)
self.widget.curveplot.plot.scene().sigMouseMoved.emit(tl + QPoint(10, 10))
QTest.qWait(1)
QTest.mouseClick(ca, Qt.LeftButton, pos=br)
示例5: enterFilter
# 需要导入模块: from AnyQt.QtTest import QTest [as 别名]
# 或者: from AnyQt.QtTest.QTest import mouseClick [as 别名]
def enterFilter(self, variable, filter, value=None, value2=None):
row = self.widget.cond_list.model().rowCount()
self.widget.add_button.click()
var_combo = self.widget.cond_list.cellWidget(row, 0)
simulate.combobox_activate_item(var_combo, variable.name, delay=0)
oper_combo = self.widget.cond_list.cellWidget(row, 1)
simulate.combobox_activate_item(oper_combo, filter, delay=0)
value_inputs = self._get_value_line_edits(row)
for i, value in enumerate([value, value2]):
if value is None:
continue
QTest.mouseClick(value_inputs[i], Qt.LeftButton)
QTest.keyClicks(value_inputs[i], value, delay=0)
QTest.keyClick(value_inputs[i], Qt.Key_Enter)
示例6: test_resort_on_data_change
# 需要导入模块: from AnyQt.QtTest import QTest [as 别名]
# 或者: from AnyQt.QtTest.QTest import mouseClick [as 别名]
def test_resort_on_data_change(self):
iris = Table("iris")
# one example is included from the other class
# to keep F1 from complaining
setosa = iris[:51]
versicolor = iris[49:100]
class SetosaLearner:
def __call__(self, data):
model = ConstantModel([1., 0, 0])
model.domain = iris.domain
return model
class VersicolorLearner:
def __call__(self, data):
model = ConstantModel([0, 1., 0])
model.domain = iris.domain
return model
# this is done manually to avoid multiple computations
self.widget.resampling = 5
self.widget.set_train_data(iris)
self.widget.set_learner(SetosaLearner(), 1)
self.widget.set_learner(VersicolorLearner(), 2)
self.send_signal(self.widget.Inputs.test_data, setosa, wait=5000)
self.widget.show()
header = self.widget.view.horizontalHeader()
QTest.mouseClick(header.viewport(), Qt.LeftButton)
# Ensure that the click on header caused an ascending sort
# Ascending sort means that wrong model should be listed first
self.assertEqual(header.sortIndicatorOrder(), Qt.AscendingOrder)
self.assertEqual(
self.widget.view.model().item(0, 0).text(),
"VersicolorLearner")
self.send_signal(self.widget.Inputs.test_data, versicolor, wait=5000)
self.assertEqual(
self.widget.view.model().item(0, 0).text(),
"SetosaLearner")
self.widget.hide()