当前位置: 首页>>代码示例>>Python>>正文


Python Qt.DisplayRole方法代码示例

本文整理汇总了Python中qtpy.QtCore.Qt.DisplayRole方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.DisplayRole方法的具体用法?Python Qt.DisplayRole怎么用?Python Qt.DisplayRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qtpy.QtCore.Qt的用法示例。


在下文中一共展示了Qt.DisplayRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_channels

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def update_channels(self):
        """
        """
        temp_active_channels = []
        channels = []

        for i in range(self.list.count()):
            item = self.list.item(i)
            channel = item.data(Qt.DisplayRole)

            if channel:
                channels.append(channel)

                if item.checkState() == Qt.Checked:
                    temp_active_channels.append(item.data(Qt.DisplayRole))

        if (sorted(channels) != sorted(self._channels) or
                sorted(temp_active_channels) != sorted(self._active_channels)):
            self.sig_channels_updated.emit(tuple(channels),
                                           tuple(temp_active_channels))
            self.accept()
        else:
            self.reject() 
开发者ID:spyder-ide,项目名称:conda-manager,代码行数:25,代码来源:channels.py

示例2: data

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def data(self, role):
        if role == Qt.DisplayRole:
            return self.column.title
        elif role == Qt.ToolTipRole:
            return self.column.name
        elif role == Qt.CheckStateRole:
            if self.column.visible:
                return Qt.Checked
            else:
                return Qt.Unchecked
        return None 
开发者ID:busimus,项目名称:cutelog,代码行数:13,代码来源:logger_table_header.py

示例3: data

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def data(self, role):
        if role == Qt.DisplayRole:
            return self.name
        return None 
开发者ID:busimus,项目名称:cutelog,代码行数:6,代码来源:merge_dialog.py

示例4: open_level_edit_dialog

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def open_level_edit_dialog(self, index):
        levelname = self.table.item(index.row(), 1).data(Qt.DisplayRole)
        level = self.levels[levelname]
        d = LevelEditDialog(self, level)
        d.setWindowModality(Qt.NonModal)
        d.setWindowTitle('Level editor')
        d.level_changed.connect(self.update_output)
        d.open() 
开发者ID:busimus,项目名称:cutelog,代码行数:10,代码来源:levels_preset_dialog.py

示例5: headerData

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def headerData(self, section, orientation, role=Qt.DisplayRole):
        """Return data for specified header."""
        if orientation == Qt.Horizontal and role == Qt.DisplayRole:
            return HEADERS[section]
        else:
            return None 
开发者ID:spyder-ide,项目名称:spyder-unittest,代码行数:8,代码来源:datatree.py

示例6: test_testdatamodel_shows_abbreviated_name_in_table

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def test_testdatamodel_shows_abbreviated_name_in_table(qtbot):
    model = TestDataModel()
    res = TestResult(Category.OK, 'status', 'foo.bar', '', 0, '')
    model.testresults = [res]
    index = model.index(0, 1)
    assert model.data(index, Qt.DisplayRole) == 'f.bar' 
开发者ID:spyder-ide,项目名称:spyder-unittest,代码行数:8,代码来源:test_datatree.py

示例7: test_testdatamodel_shows_time

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def test_testdatamodel_shows_time(qtmodeltester):
    model = TestDataModel()
    res = TestResult(Category.OK, 'status', 'foo.bar', time=0.0012345)
    model.testresults = [res]
    index = model.index(0, 3)
    assert model.data(index, Qt.DisplayRole) == '1.23'
    assert model.data(index, Qt.TextAlignmentRole) == Qt.AlignRight 
开发者ID:spyder-ide,项目名称:spyder-unittest,代码行数:9,代码来源:test_datatree.py

示例8: test_testdatamodel_shows_time_when_zero

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def test_testdatamodel_shows_time_when_zero(qtmodeltester):
    model = TestDataModel()
    res = TestResult(Category.OK, 'status', 'foo.bar', time=0)
    model.testresults = [res]
    assert model.data(model.index(0, 3), Qt.DisplayRole) == '0.00' 
开发者ID:spyder-ide,项目名称:spyder-unittest,代码行数:7,代码来源:test_datatree.py

示例9: test_run_tests_and_display_results

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def test_run_tests_and_display_results(qtbot, tmpdir, monkeypatch, framework):
    """Basic integration test."""
    os.chdir(tmpdir.strpath)
    testfilename = tmpdir.join('test_foo.py').strpath

    with open(testfilename, 'w') as f:
        f.write("def test_ok(): assert 1+1 == 2\n"
                "def test_fail(): assert 1+1 == 3\n")

    MockQMessageBox = Mock()
    monkeypatch.setattr('spyder_unittest.widgets.unittestgui.QMessageBox',
                        MockQMessageBox)

    widget = UnitTestWidget(None)
    qtbot.addWidget(widget)
    config = Config(wdir=tmpdir.strpath, framework=framework)
    with qtbot.waitSignal(widget.sig_finished, timeout=10000, raising=True):
        widget.run_tests(config)

    MockQMessageBox.assert_not_called()
    model = widget.testdatamodel
    assert model.rowCount() == 2
    assert model.index(0, 0).data(
        Qt.DisplayRole) == 'ok' if framework == 'nose' else 'passed'
    assert model.index(0, 1).data(Qt.DisplayRole) == 't.test_ok'
    assert model.index(0, 1).data(Qt.ToolTipRole) == 'test_foo.test_ok'
    assert model.index(0, 2).data(Qt.DisplayRole) == ''
    assert model.index(1, 0).data(
        Qt.DisplayRole) == 'failure' if framework == 'nose' else 'failed'
    assert model.index(1, 1).data(Qt.DisplayRole) == 't.test_fail'
    assert model.index(1, 1).data(Qt.ToolTipRole) == 'test_foo.test_fail' 
开发者ID:spyder-ide,项目名称:spyder-unittest,代码行数:33,代码来源:test_unittestgui.py

示例10: test_run_tests_using_unittest_and_display_results

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def test_run_tests_using_unittest_and_display_results(qtbot, tmpdir,
                                                      monkeypatch):
    """Basic check."""
    os.chdir(tmpdir.strpath)
    testfilename = tmpdir.join('test_foo.py').strpath

    with open(testfilename, 'w') as f:
        f.write("import unittest\n"
                "class MyTest(unittest.TestCase):\n"
                "   def test_ok(self): self.assertEqual(1+1, 2)\n"
                "   def test_fail(self): self.assertEqual(1+1, 3)\n")

    MockQMessageBox = Mock()
    monkeypatch.setattr('spyder_unittest.widgets.unittestgui.QMessageBox',
                        MockQMessageBox)

    widget = UnitTestWidget(None)
    qtbot.addWidget(widget)
    config = Config(wdir=tmpdir.strpath, framework='unittest')
    with qtbot.waitSignal(widget.sig_finished, timeout=10000, raising=True):
        widget.run_tests(config)

    MockQMessageBox.assert_not_called()
    model = widget.testdatamodel
    assert model.rowCount() == 2
    assert model.index(0, 0).data(Qt.DisplayRole) == 'FAIL'
    assert model.index(0, 1).data(Qt.DisplayRole) == 't.M.test_fail'
    assert model.index(0, 1).data(Qt.ToolTipRole) == 'test_foo.MyTest.test_fail'
    assert model.index(0, 2).data(Qt.DisplayRole) == ''
    assert model.index(1, 0).data(Qt.DisplayRole) == 'ok'
    assert model.index(1, 1).data(Qt.DisplayRole) == 't.M.test_ok'
    assert model.index(1, 1).data(Qt.ToolTipRole) == 'test_foo.MyTest.test_ok'
    assert model.index(1, 2).data(Qt.DisplayRole) == '' 
开发者ID:spyder-ide,项目名称:spyder-unittest,代码行数:35,代码来源:test_unittestgui.py

示例11: paint

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def paint(self, painter, option, index):
        t = index.data(Qt.DisplayRole)
        r = option.rect.adjusted(2, 2, -2, -2)
        painter.drawText(r, Qt.AlignVCenter | Qt.AlignLeft, t, r)

# ----------------------------------------------------------------- 
开发者ID:pyCGNS,项目名称:pyCGNS,代码行数:8,代码来源:wpattern.py

示例12: paint

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def paint(self, painter, option, index):
        t = index.data(Qt.DisplayRole)
        r = option.rect.adjusted(2, 2, -2, -2)
        painter.drawText(r, Qt.AlignVCenter | Qt.AlignLeft, t, r)
        # QStyledItemDelegate.paint(self, painter, option, index)


# ----------------------------------------------------------------- 
开发者ID:pyCGNS,项目名称:pyCGNS,代码行数:10,代码来源:wform.py

示例13: add_event

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def add_event(self):
        current_row = self.table.selectedIndexes()[0].row()
        pos = int(self.table.item(current_row, 0).data(Qt.DisplayRole))
        self.table.setSortingEnabled(False)
        self.table.insertRow(current_row)
        self.table.setItem(current_row, 0, IntTableWidgetItem(pos))
        self.table.setItem(current_row, 1, IntTableWidgetItem(0))
        self.table.setItem(current_row, 2, QTableWidgetItem("New Annotation"))
        self.table.setSortingEnabled(True) 
开发者ID:cbrnr,项目名称:mnelab,代码行数:11,代码来源:annotationsdialog.py

示例14: add_event

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def add_event(self):
        current_row = self.table.selectedIndexes()[0].row()
        pos = int(self.table.item(current_row, 0).data(Qt.DisplayRole))
        self.table.setSortingEnabled(False)
        self.table.insertRow(current_row)
        self.table.setItem(current_row, 0, IntTableWidgetItem(pos))
        self.table.setItem(current_row, 1, IntTableWidgetItem(0))
        self.table.setSortingEnabled(True) 
开发者ID:cbrnr,项目名称:mnelab,代码行数:10,代码来源:eventsdialog.py

示例15: test_profile_and_display_results

# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import DisplayRole [as 别名]
def test_profile_and_display_results(qtbot, tmpdir, monkeypatch):
    """Run profiler on simple script and check that results are okay."""
    os.chdir(tmpdir.strpath)
    testfilename = tmpdir.join('test_foo.py').strpath

    with open(testfilename, 'w') as f:
        f.write(TEST_SCRIPT)

    MockQMessageBox = Mock()
    monkeypatch.setattr('spyder_line_profiler.widgets.lineprofiler.QMessageBox',
                        MockQMessageBox)

    widget = LineProfilerWidget(None)
    qtbot.addWidget(widget)
    with qtbot.waitSignal(widget.sig_finished, timeout=10000, raising=True):
        widget.analyze(testfilename)

    MockQMessageBox.assert_not_called()
    dt = widget.datatree
    assert dt.topLevelItemCount() == 1  # number of functions profiled
    
    top = dt.topLevelItem(0)                               
    assert top.data(0, Qt.DisplayRole).startswith('foo ')
    assert top.childCount() == 6
    for i in range(6):
        assert top.child(i).data(0, Qt.DisplayRole) == i + 2  # line no

    assert top.child(2).data(1, Qt.DisplayRole) == '1'  # hits
    assert top.child(3).data(1, Qt.DisplayRole) == '1' 
    assert top.child(4).data(1, Qt.DisplayRole) == '101'
    assert top.child(5).data(1, Qt.DisplayRole) == '100'

    assert float(top.child(2).data(2, Qt.DisplayRole)) >= 900  # time (ms)
    assert float(top.child(2).data(2, Qt.DisplayRole)) <= 1200
    assert float(top.child(3).data(2, Qt.DisplayRole)) <= 100
    assert float(top.child(4).data(2, Qt.DisplayRole)) <= 100
    assert float(top.child(5).data(2, Qt.DisplayRole)) <= 100 
开发者ID:spyder-ide,项目名称:spyder-line-profiler,代码行数:39,代码来源:test_lineprofiler.py


注:本文中的qtpy.QtCore.Qt.DisplayRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。