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


Python QGraphicsView.resize方法代码示例

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


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

示例1: test_editlinksnode

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import resize [as 别名]
    def test_editlinksnode(self):
        from ...registry.tests import small_testing_registry

        reg = small_testing_registry()
        file_desc = reg.widget("Orange.widgets.data.owfile.OWFile")
        bayes_desc = reg.widget("Orange.widgets.classify.ownaivebayes."
                                "OWNaiveBayes")
        source_node = SchemeNode(file_desc, title="This is File")
        sink_node = SchemeNode(bayes_desc)

        scene = QGraphicsScene()
        view = QGraphicsView(scene)

        node = EditLinksNode(node=source_node)
        scene.addItem(node)

        node = EditLinksNode(direction=Qt.RightToLeft)
        node.setSchemeNode(sink_node)

        node.setPos(300, 0)
        scene.addItem(node)

        view.show()
        view.resize(800, 300)
        self.app.exec_()
开发者ID:PrimozGodec,项目名称:orange3,代码行数:27,代码来源:test_editlinksdialog.py

示例2: test_graphicstextwidget

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import resize [as 别名]
    def test_graphicstextwidget(self):
        scene = QGraphicsScene()
        view = QGraphicsView(scene)

        text = GraphicsTextWidget()
        text.setHtml("<center><b>a text</b></center><p>paragraph</p>")
        scene.addItem(text)
        view.show()
        view.resize(400, 300)

        self.app.exec_()
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:13,代码来源:test_editlinksdialog.py

示例3: TestItems

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import resize [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

示例4: TestItems

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import resize [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

示例5: test_editlinksnode

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import resize [as 别名]
    def test_editlinksnode(self):
        reg = small_testing_registry()
        one_desc = reg.widget("one")
        negate_desc = reg.widget("negate")
        source_node = SchemeNode(one_desc, title="This is 1")
        sink_node = SchemeNode(negate_desc)

        scene = QGraphicsScene()
        view = QGraphicsView(scene)

        node = EditLinksNode(node=source_node)
        scene.addItem(node)

        node = EditLinksNode(direction=Qt.RightToLeft)
        node.setSchemeNode(sink_node)

        node.setPos(300, 0)
        scene.addItem(node)

        view.show()
        view.resize(800, 300)
        self.app.exec_()
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:24,代码来源:test_editlinksdialog.py

示例6: TestScene

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

    def test_scene(self):
        """Test basic scene functionality.
        """
        file_desc, disc_desc, bayes_desc = self.widget_desc()

        file_item = items.NodeItem(file_desc)
        disc_item = items.NodeItem(disc_desc)
        bayes_item = items.NodeItem(bayes_desc)

        file_item = self.scene.add_node_item(file_item)
        disc_item = self.scene.add_node_item(disc_item)
        bayes_item = self.scene.add_node_item(bayes_item)

        # Remove a node
        self.scene.remove_node_item(bayes_item)
        self.assertSequenceEqual(self.scene.node_items(),
                                 [file_item, disc_item])

        # And add it again
        self.scene.add_node_item(bayes_item)
        self.assertSequenceEqual(self.scene.node_items(),
                                 [file_item, disc_item, bayes_item])

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

        # Add links
        link1 = self.scene.new_link_item(file_item, "Data", disc_item, "Data")
        link2 = self.scene.new_link_item(disc_item, "Data", bayes_item, "Data")

        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(file_item.outputAnchors(), [])
        self.assertSequenceEqual(disc_item.inputAnchors(), [])
        self.assertSequenceEqual(disc_item.outputAnchors(), [])
        self.assertSequenceEqual(bayes_item.outputAnchors(), [])

        # And add one link again
        link1 = self.scene.new_link_item(file_item, "Data", disc_item, "Data")
        link1 = self.scene.add_link_item(link1)
        self.assertSequenceEqual(self.scene.link_items(), [link1])

        self.assertTrue(file_item.outputAnchors())
        self.assertTrue(disc_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)

        file_desc, disc_desc, bayes_desc = self.widget_desc()
        file_node = scheme.SchemeNode(file_desc)
        disc_node = scheme.SchemeNode(disc_desc)
        bayes_node = scheme.SchemeNode(bayes_desc)

        nodes = [file_node, disc_node, bayes_node]
        test_scheme.add_node(file_node)
        test_scheme.add_node(disc_node)
        test_scheme.add_node(bayes_node)

        self.assertTrue(len(self.scene.node_items()) == 3)
        self.assertSequenceEqual(self.scene.node_items(), node_items)

        for node, item in zip(nodes, node_items):
            self.assertIs(item, self.scene.item_for_node(node))

#.........这里部分代码省略.........
开发者ID:PrimozGodec,项目名称:orange3,代码行数:103,代码来源:test_scene.py

示例7: TestAnchorLayout

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

    def test_layout(self):
        file_desc, disc_desc, bayes_desc = self.widget_desc()
        file_item = NodeItem()
        file_item.setWidgetDescription(file_desc)
        file_item.setPos(0, 150)
        self.scene.add_node_item(file_item)

        bayes_item = NodeItem()
        bayes_item.setWidgetDescription(bayes_desc)
        bayes_item.setPos(200, 0)
        self.scene.add_node_item(bayes_item)

        disc_item = NodeItem()
        disc_item.setWidgetDescription(disc_desc)
        disc_item.setPos(200, 300)
        self.scene.add_node_item(disc_item)

        link = LinkItem()
        link.setSourceItem(file_item)
        link.setSinkItem(disc_item)
        self.scene.add_link_item(link)

        link = LinkItem()
        link.setSourceItem(file_item)
        link.setSinkItem(bayes_item)
        self.scene.add_link_item(link)

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

        layout.invalidateNode(file_item)
        layout.activate()

        p1, p2 = file_item.outputAnchorItem.anchorPositions()
        self.assertGreater(p1, p2)

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

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

        def advance():
            t = time.clock()
            bayes_item.setPos(path.pointAtPercent(t % 1.0))
            disc_item.setPos(path.pointAtPercent((t + 0.5) % 1.0))

            self.singleShot(20, advance)

        advance()

        self.app.exec_()

    def widget_desc(self):
        from ...registry.tests import small_testing_registry
        reg = small_testing_registry()

        file_desc = reg.widget(
            "Orange.widgets.data.owfile.OWFile"
        )

        discretize_desc = reg.widget(
            "Orange.widgets.data.owdiscretize.OWDiscretize"
        )

        bayes_desc = reg.widget(
            "Orange.widgets.classify.ownaivebayes.OWNaiveBayes"
        )

        return file_desc, discretize_desc, bayes_desc
开发者ID:PrimozGodec,项目名称:orange3,代码行数:81,代码来源:test_layout.py

示例8: TestAnchorLayout

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import resize [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

示例9: TestScene

# 需要导入模块: from AnyQt.QtWidgets import QGraphicsView [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsView import resize [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.resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。