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


Python Canvas.connect_item方法代码示例

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


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

示例1: test_connect_item

# 需要导入模块: from gaphas.canvas import Canvas [as 别名]
# 或者: from gaphas.canvas.Canvas import connect_item [as 别名]
    def test_connect_item(self):
        b1 = Box()
        b2 = Box()
        l = Line()
        c = Canvas()
        c.add(b1)
        c.add(b2)
        c.add(l)

        c.connect_item(l, l.handles()[0], b1, b1.ports()[0])
        assert count(c.get_connections(handle=l.handles()[0])) == 1

        # Add the same
        self.assertRaises(ConnectionError, c.connect_item, l, l.handles()[0], b1, b1.ports()[0])
        assert count(c.get_connections(handle=l.handles()[0])) == 1
开发者ID:adrianboguszewski,项目名称:gaphas,代码行数:17,代码来源:test_canvas.py

示例2: test_connect_item

# 需要导入模块: from gaphas.canvas import Canvas [as 别名]
# 或者: from gaphas.canvas.Canvas import connect_item [as 别名]
def test_connect_item():
    b1 = Box()
    b2 = Box()
    line = Line()
    c = Canvas()
    c.add(b1)
    c.add(b2)
    c.add(line)

    c.connect_item(line, line.handles()[0], b1, b1.ports()[0])
    assert count(c.get_connections(handle=line.handles()[0])) == 1

    # Add the same
    with pytest.raises(ConnectionError):
        c.connect_item(line, line.handles()[0], b1, b1.ports()[0])
    assert count(c.get_connections(handle=line.handles()[0])) == 1
开发者ID:amolenaar,项目名称:gaphas,代码行数:18,代码来源:test_canvas.py

示例3: test_disconnect_item_with_callback

# 需要导入模块: from gaphas.canvas import Canvas [as 别名]
# 或者: from gaphas.canvas.Canvas import connect_item [as 别名]
    def test_disconnect_item_with_callback(self):
        b1 = Box()
        b2 = Box()
        l = Line()
        c = Canvas()
        c.add(b1)
        c.add(b2)
        c.add(l)

        events = []
        def callback():
            events.append('called')

        c.connect_item(l, l.handles()[0], b1, b1.ports()[0], callback=callback)
        assert count(c.get_connections(handle=l.handles()[0])) == 1

        c.disconnect_item(l, l.handles()[0])
        assert count(c.get_connections(handle=l.handles()[0])) == 0
        assert events == ['called']
开发者ID:adrianboguszewski,项目名称:gaphas,代码行数:21,代码来源:test_canvas.py

示例4: test_disconnect_item_with_callback

# 需要导入模块: from gaphas.canvas import Canvas [as 别名]
# 或者: from gaphas.canvas.Canvas import connect_item [as 别名]
def test_disconnect_item_with_callback():
    b1 = Box()
    b2 = Box()
    line = Line()
    c = Canvas()
    c.add(b1)
    c.add(b2)
    c.add(line)

    events = []

    def callback():
        events.append("called")

    c.connect_item(line, line.handles()[0], b1, b1.ports()[0], callback=callback)
    assert count(c.get_connections(handle=line.handles()[0])) == 1

    c.disconnect_item(line, line.handles()[0])
    assert count(c.get_connections(handle=line.handles()[0])) == 0
    assert events == ["called"]
开发者ID:amolenaar,项目名称:gaphas,代码行数:22,代码来源:test_canvas.py

示例5: test_disconnect_item_with_constraint

# 需要导入模块: from gaphas.canvas import Canvas [as 别名]
# 或者: from gaphas.canvas.Canvas import connect_item [as 别名]
    def test_disconnect_item_with_constraint(self):
        b1 = Box()
        b2 = Box()
        l = Line()
        c = Canvas()
        c.add(b1)
        c.add(b2)
        c.add(l)

        cons = b1.ports()[0].constraint(c, l, l.handles()[0], b1)

        c.connect_item(l, l.handles()[0], b1, b1.ports()[0], constraint=cons)
        assert count(c.get_connections(handle=l.handles()[0])) == 1

        ncons = len(c.solver.constraints)
        assert ncons == 5

        c.disconnect_item(l, l.handles()[0])
        assert count(c.get_connections(handle=l.handles()[0])) == 0

        assert len(c.solver.constraints) == 4
开发者ID:adrianboguszewski,项目名称:gaphas,代码行数:23,代码来源:test_canvas.py

示例6: test_disconnect_item_with_constraint_by_deleting_element

# 需要导入模块: from gaphas.canvas import Canvas [as 别名]
# 或者: from gaphas.canvas.Canvas import connect_item [as 别名]
    def test_disconnect_item_with_constraint_by_deleting_element(self):
        b1 = Box()
        b2 = Box()
        l = Line()
        c = Canvas()
        c.add(b1)
        c.add(b2)
        c.add(l)

        cons = b1.ports()[0].constraint(c, l, l.handles()[0], b1)

        c.connect_item(l, l.handles()[0], b1, b1.ports()[0], constraint=cons)
        assert count(c.get_connections(handle=l.handles()[0])) == 1

        ncons = len(c.solver.constraints)
        assert ncons == 5

        c.remove(b1)

        assert count(c.get_connections(handle=l.handles()[0])) == 0

        self.assertEquals(2, len(c.solver.constraints))
开发者ID:adrianboguszewski,项目名称:gaphas,代码行数:24,代码来源:test_canvas.py

示例7: test_disconnect_item_with_constraint_by_deleting_element

# 需要导入模块: from gaphas.canvas import Canvas [as 别名]
# 或者: from gaphas.canvas.Canvas import connect_item [as 别名]
def test_disconnect_item_with_constraint_by_deleting_element():
    b1 = Box()
    b2 = Box()
    line = Line()
    c = Canvas()
    c.add(b1)
    c.add(b2)
    c.add(line)

    cons = b1.ports()[0].constraint(c, line, line.handles()[0], b1)

    c.connect_item(line, line.handles()[0], b1, b1.ports()[0], constraint=cons)
    assert count(c.get_connections(handle=line.handles()[0])) == 1

    ncons = len(c.solver.constraints)
    assert ncons == 5

    c.remove(b1)

    assert count(c.get_connections(handle=line.handles()[0])) == 0

    assert 2 == len(c.solver.constraints)
开发者ID:amolenaar,项目名称:gaphas,代码行数:24,代码来源:test_canvas.py


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