def test_flags():
    model = DataFrameModel(pandas.DataFrame([0], columns=["A"]))
    index = model.index(0, 0)
    assert index.isValid()
    assert model.flags(index) == Qt.ItemIsSelectable | Qt.ItemIsEnabled

    model.enableEditing(True)
    assert model.flags(index) == Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable

    model.setDataFrame(pandas.DataFrame([True], columns=["A"]))
    index = model.index(0, 0)
    model.enableEditing(True)
    assert model.flags(index) != Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable
    assert model.flags(index) == Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable
Beispiel #2
0
def test_flags():
    model = DataFrameModel(pandas.DataFrame([0], columns=['A']))
    index = model.index(0, 0)
    assert index.isValid()
    assert model.flags(index) == Qt.ItemIsSelectable | Qt.ItemIsEnabled

    model.enableEditing(True)
    assert model.flags(
        index) == Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable

    model.setDataFrame(pandas.DataFrame([True], columns=['A']))
    index = model.index(0, 0)
    model.enableEditing(True)
    assert model.flags(
        index) != Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable
    assert model.flags(
        index
    ) == Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable
    def test_editing(self, dataFrame, qtbot):
        model = DataFrameModel(dataFrame)

        tableView = QtGui.QTableView()

        qtbot.addWidget(tableView)
        tableView.setModel(model)

        delegate = TextDelegate(tableView)
        createDelegate(numpy.dtype('O'), 0, tableView)
        tableView.show()

        index = model.index(0, 0)
        preedit_data = index.data()

        assert not model.editable
        model.enableEditing(True)
        tableView.edit(index)
        editor = tableView.findChildren(QtGui.QLineEdit)[0]
        qtbot.keyPress(editor, QtCore.Qt.Key_F)
        qtbot.keyPress(editor, QtCore.Qt.Key_Enter)
        QtGui.QApplication.processEvents()
        with qtbot.waitSignal(timeout=100):
            assert index.data(QtCore.Qt.DisplayRole) == 'f'
Beispiel #4
0
    def test_editing(self, dataFrame, qtbot):
        model = DataFrameModel(dataFrame)

        tableView = QtGui.QTableView()

        qtbot.addWidget(tableView)
        tableView.setModel(model)

        delegate = TextDelegate(tableView)
        createDelegate(numpy.dtype('O'), 0, tableView)
        tableView.show()

        index = model.index(0, 0)
        preedit_data = index.data()

        assert not model.editable
        model.enableEditing(True)
        tableView.edit(index)
        editor = tableView.findChildren(QtGui.QLineEdit)[0]
        qtbot.keyPress(editor, QtCore.Qt.Key_F)
        qtbot.keyPress(editor, QtCore.Qt.Key_Enter)
        QtGui.QApplication.processEvents()
        with qtbot.waitSignal(timeout=100):
            assert index.data(QtCore.Qt.DisplayRole) == 'f'