def key_sequence_item_view(model, view, index, sequence, delay=0):
    """ Perform Key Sequence on the given QAbstractItemModel (model) and
    QAbstractItemView (view) with the given row and column.

    Parameters
    ----------
    model : QAbstractItemModel
        Model from which QModelIndex will be obtained
    view : QAbstractItemView
        View from which the widget identified by the index will be
        found and key sequence be performed.
    index : QModelIndex
    sequence : str
        Sequence of characters to be inserted to the widget identifed
        by the row and column.

    Raises
    ------
    Disabled
        If the widget cannot be edited.
    LookupError
        If the index cannot be located.
        Note that the index error provides more
    """
    check_q_model_index_valid(index)
    widget = view.indexWidget(index)
    if widget is None:
        raise Disabled(
            "No editable widget for item at row {!r} and column {!r}".format(
                index.row(), index.column()))
    QTest.keyClicks(widget, sequence, delay=delay)
示例#2
0
def key_sequence_qwidget(control, interaction, delay):
    """ Performs simulated typing of a sequence of keys on the given widget
    after a delay.

    Parameters
    ----------
    control : Qwidget
        The Qt widget to be acted on.
    interaction : instance of command.KeySequence
        The interaction object holding the sequence of key inputs
        to be simulated being typed
    delay : int
        Time delay (in ms) in which each key click in the sequence will be
        performed.
    """
    if not control.isEnabled():
        raise Disabled("{!r} is disabled.".format(control))
    QTest.keyClicks(control, interaction.sequence, delay=delay)
示例#3
0
 def check(typed, expected):
     cursor = cw.textCursor()
     cursor.setPosition(0)
     cw.setTextCursor(cursor)
     QTest.keyClicks(cw, typed)
     self.assertEqual(cw.toPlainText(), expected)
示例#4
0
 def check(typed, expected):
     cursor = cw.textCursor()
     cursor.setPosition(0)
     cw.setTextCursor(cursor)
     QTest.keyClicks(cw, typed)
     self.assertEqual(cw.toPlainText(), expected)