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


Python QGraphicsView.deleteLater方法代码示例

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


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

示例1: TestItems

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import deleteLater [as 别名]
class TestItems(QAppTestCase):
    def setUp(self):
        super().setUp()

        self.scene = QGraphicsScene()
        self.view = QGraphicsView(self.scene)
        self.view.setRenderHints(
            QPainter.Antialiasing |
            QPainter.SmoothPixmapTransform |
            QPainter.TextAntialiasing
        )
        self.view.resize(500, 300)
        self.view.show()

    def tearDown(self):
        self.scene.clear()
        self.scene.deleteLater()
        self.view.deleteLater()
        del self.scene
        del self.view
        super().tearDown()
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:23,代码来源:__init__.py

示例2: TestItems

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import deleteLater [as 别名]
class TestItems(unittest.TestCase):
    def setUp(self):
        import logging

        from AnyQt.QtWidgets import \
            QApplication, QGraphicsScene, QGraphicsView
        from AnyQt.QtGui import  QPainter
        from AnyQt.QtCore import QTimer

        logging.basicConfig()

        self.app = QApplication([])
        self.scene = QGraphicsScene()
        self.view = QGraphicsView(self.scene)
        self.view.setRenderHints(
            QPainter.Antialiasing | \
            QPainter.SmoothPixmapTransform | \
            QPainter.TextAntialiasing
            )
        self.view.resize(500, 300)
        self.view.show()
        QTimer.singleShot(10000, self.app.exit)

        def my_excepthook(*args):
            sys.setrecursionlimit(1010)
            traceback.print_exc(limit=4)

        self._orig_excepthook = sys.excepthook
        sys.excepthook = my_excepthook
        self.singleShot = QTimer.singleShot

    def tearDown(self):
        self.scene.clear()
        self.scene.deleteLater()
        self.view.deleteLater()
        del self.scene
        del self.view
        self.app.processEvents()
        del self.app
        sys.excepthook = self._orig_excepthook
开发者ID:PrimozGodec,项目名称:orange3,代码行数:42,代码来源:__init__.py

示例3: TestAnchorLayout

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import deleteLater [as 别名]
class TestAnchorLayout(QAppTestCase):
    def setUp(self):
        super().setUp()
        self.scene = CanvasScene()
        self.view = QGraphicsView(self.scene)
        self.view.setRenderHint(QPainter.Antialiasing)
        self.view.show()
        self.view.resize(600, 400)

    def tearDown(self):
        self.scene.clear()
        self.view.deleteLater()
        self.scene.deleteLater()
        del self.scene
        del self.view
        super().tearDown()

    def test_layout(self):
        one_desc, negate_desc, cons_desc = self.widget_desc()
        one_item = NodeItem()
        one_item.setWidgetDescription(one_desc)
        one_item.setPos(0, 150)
        self.scene.add_node_item(one_item)

        cons_item = NodeItem()
        cons_item.setWidgetDescription(cons_desc)
        cons_item.setPos(200, 0)
        self.scene.add_node_item(cons_item)

        negate_item = NodeItem()
        negate_item.setWidgetDescription(negate_desc)
        negate_item.setPos(200, 300)
        self.scene.add_node_item(negate_item)

        link = LinkItem()
        link.setSourceItem(one_item)
        link.setSinkItem(negate_item)
        self.scene.add_link_item(link)

        link = LinkItem()
        link.setSourceItem(one_item)
        link.setSinkItem(cons_item)
        self.scene.add_link_item(link)

        layout = AnchorLayout()
        self.scene.addItem(layout)
        self.scene.set_anchor_layout(layout)

        layout.invalidateNode(one_item)
        layout.activate()

        p1, p2 = one_item.outputAnchorItem.anchorPositions()
        self.assertTrue(p1 > p2)

        self.scene.node_item_position_changed.connect(layout.invalidateNode)

        path = QPainterPath()
        path.addEllipse(125, 0, 50, 300)

        def advance():
            t = time.process_time()
            cons_item.setPos(path.pointAtPercent(t % 1.0))
            negate_item.setPos(path.pointAtPercent((t + 0.5) % 1.0))

        timer = QTimer(negate_item, interval=20)
        timer.start()
        timer.timeout.connect(advance)
        self.app.exec_()

    def widget_desc(self):
        reg = small_testing_registry()
        one_desc = reg.widget("one")
        negate_desc = reg.widget("negate")
        cons_desc = reg.widget("cons")
        return one_desc, negate_desc, cons_desc
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:77,代码来源:test_layout.py

示例4: TestScene

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import deleteLater [as 别名]
class TestScene(QAppTestCase):
    def setUp(self):
        super().setUp()
        self.scene = CanvasScene()
        self.view = QGraphicsView(self.scene)
        self.view.setRenderHints(QPainter.Antialiasing |
                                 QPainter.TextAntialiasing)
        self.view.show()
        self.view.resize(400, 300)

    def tearDown(self):
        self.scene.clear()
        self.view.deleteLater()
        self.scene.deleteLater()
        del self.view
        del self.scene
        super().tearDown()

    def test_scene(self):
        """Test basic scene functionality.
        """
        one_desc, negate_desc, cons_desc = self.widget_desc()

        one_item = items.NodeItem(one_desc)
        negate_item = items.NodeItem(negate_desc)
        cons_item = items.NodeItem(cons_desc)

        one_item = self.scene.add_node_item(one_item)
        negate_item = self.scene.add_node_item(negate_item)
        cons_item = self.scene.add_node_item(cons_item)

        # Remove a node
        self.scene.remove_node_item(cons_item)
        self.assertSequenceEqual(self.scene.node_items(),
                                 [one_item, negate_item])

        # And add it again
        self.scene.add_node_item(cons_item)
        self.assertSequenceEqual(self.scene.node_items(),
                                 [one_item, negate_item, cons_item])

        # Adding the same item again should raise an exception
        with self.assertRaises(ValueError):
            self.scene.add_node_item(cons_item)

        # Add links
        link1 = self.scene.new_link_item(
            one_item, "value", negate_item, "value")
        link2 = self.scene.new_link_item(
            negate_item, "result", cons_item, "first")

        link1a = self.scene.add_link_item(link1)
        link2a = self.scene.add_link_item(link2)
        self.assertEqual(link1, link1a)
        self.assertEqual(link2, link2a)
        self.assertSequenceEqual(self.scene.link_items(), [link1, link2])

        # Remove links
        self.scene.remove_link_item(link2)
        self.scene.remove_link_item(link1)
        self.assertSequenceEqual(self.scene.link_items(), [])

        self.assertTrue(link1.sourceItem is None and link1.sinkItem is None)
        self.assertTrue(link2.sourceItem is None and link2.sinkItem is None)

        self.assertSequenceEqual(one_item.outputAnchors(), [])
        self.assertSequenceEqual(negate_item.inputAnchors(), [])
        self.assertSequenceEqual(negate_item.outputAnchors(), [])
        self.assertSequenceEqual(cons_item.outputAnchors(), [])

        # And add one link again
        link1 = self.scene.new_link_item(
            one_item, "value", negate_item, "value")
        link1 = self.scene.add_link_item(link1)
        self.assertSequenceEqual(self.scene.link_items(), [link1])

        self.assertTrue(one_item.outputAnchors())
        self.assertTrue(negate_item.inputAnchors())

        self.app.exec_()

    def test_scene_with_scheme(self):
        """Test scene through modifying the scheme.
        """
        test_scheme = scheme.Scheme()
        self.scene.set_scheme(test_scheme)

        node_items = []
        link_items = []

        self.scene.node_item_added.connect(node_items.append)
        self.scene.node_item_removed.connect(node_items.remove)
        self.scene.link_item_added.connect(link_items.append)
        self.scene.link_item_removed.connect(link_items.remove)

        one_desc, negate_desc, cons_desc = self.widget_desc()
        one_node = scheme.SchemeNode(one_desc)
        negate_node = scheme.SchemeNode(negate_desc)
        cons_node = scheme.SchemeNode(cons_desc)

#.........这里部分代码省略.........
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:103,代码来源:test_scene.py


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