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


Python Line.handles方法代码示例

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


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

示例1: test_orthogonal_line_undo

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [as 别名]
def test_orthogonal_line_undo(revert_undo, undo_fixture):
    """Test orthogonal line undo.

    """
    canvas = Canvas()
    line = Line()
    canvas.add(line)

    segment = Segment(line, None)
    segment.split_segment(0)

    # Start with no orthogonal constraints
    assert len(canvas.solver._constraints) == 0

    line.orthogonal = True

    # Check orthogonal constraints
    assert 2 == len(canvas.solver._constraints)
    assert 3 == len(line.handles())

    undo_fixture[0]()  # Call undo

    assert not line.orthogonal
    assert 0 == len(canvas.solver._constraints)
    assert 2 == len(line.handles())
开发者ID:amolenaar,项目名称:gaphas,代码行数:27,代码来源:test_line.py

示例2: test_segment

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [as 别名]
 def test_segment(self):
     """
     """
     view = self.view
     line = Line()
     self.canvas.add(line)
     segment = Segment(line, self.view)
     self.assertEquals(2, len(line.handles()))
     segment.split((5, 5))
     self.assertEquals(3, len(line.handles()))
开发者ID:jvorcak,项目名称:gpylint,代码行数:12,代码来源:test_segment.py

示例3: test_connect_item

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [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

示例4: create_canvas

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [as 别名]
def create_canvas(canvas, title):
    # Setup drawing window
    view = GtkView()
    view.painter = DefaultPainter()
    view.canvas = canvas
    window = Gtk.Window()
    window.set_title(title)
    window.set_default_size(400, 400)
    win_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
    window.add(win_box)
    win_box.pack_start(view, True, True, 0)

    # Draw first gaphas box
    b1 = Box(60, 60)
    b1.matrix = (1.0, 0.0, 0.0, 1, 10, 10)
    canvas.add(b1)

    # Draw second gaphas box
    b2 = Box(60, 60)
    b2.min_width = 40
    b2.min_height = 50
    b2.matrix.translate(170, 170)
    canvas.add(b2)

    # Draw gaphas line
    line = Line()
    line.matrix.translate(100, 60)
    canvas.add(line)
    line.handles()[1].pos = (30, 30)

    window.show_all()
    window.connect("destroy", Gtk.main_quit)
开发者ID:amolenaar,项目名称:gaphas,代码行数:34,代码来源:simple-box.py

示例5: test_constraints_after_merge

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [as 别名]
    def test_constraints_after_merge(self):
        """Test if constraints are recreated after line merge
        """

        # connect line2 to self.line
        line2 = Line()
        self.canvas.add(line2)
        head = line2.handles()[0]

        #conn = Connector(line2, head)
        #sink = conn.glue((25, 25))
        #assert sink is not None

        #conn.connect(sink)

        self.tool.connect(line2, head, (25, 25))
        cinfo = self.canvas.get_connection(head)
        self.assertEquals(self.line, cinfo.connected)

        segment = Segment(self.line, self.view)
        segment.split_segment(0)
        assert len(self.line.handles()) == 3
        c1 = cinfo.constraint

        segment.merge_segment(0)
        assert len(self.line.handles()) == 2

        h1, h2 = self.line.handles()
        # connection shall be reconstrained between 1st and 2nd handle
        cinfo = self.canvas.get_connection(head)
        self.assertEquals(cinfo.constraint._line[0]._point, h1.pos)
        self.assertEquals(cinfo.constraint._line[1]._point, h2.pos)
        self.assertFalse(c1 == cinfo.constraint)
开发者ID:jvorcak,项目名称:gpylint,代码行数:35,代码来源:test_segment.py

示例6: test_connect_item

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [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

示例7: test_line_guide

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [as 别名]
    def test_line_guide(self):
        c = Canvas()
        l = Line()
        c.add(l)
        l.handles().append(l._create_handle((20, 20)))
        l.handles().append(l._create_handle((30, 30)))
        l.handles().append(l._create_handle((40, 40)))
        l.orthogonal = True
        c.update_now()

        guides = list(Guide(l).horizontal())
        self.assertEquals(2, len(guides))
        self.assertEquals(10.0, guides[0])
        self.assertEquals(40.0, guides[1])

        guides = list(Guide(l).vertical())
        self.assertEquals(2, len(guides))
        self.assertEquals(00.0, guides[0])
        self.assertEquals(20.0, guides[1])
开发者ID:adrianboguszewski,项目名称:gaphas,代码行数:21,代码来源:test_guide.py

示例8: test_disconnect_item_with_callback

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [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

示例9: test_disconnect_item_with_callback

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [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

示例10: test_remove_connected_item

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [as 别名]
    def test_remove_connected_item(self):
        """Test adding canvas constraint"""
        canvas = Canvas()

        from gaphas.aspect import Connector, ConnectionSink

        l1 = Line()
        canvas.add(l1)


        b1 = Box()
        canvas.add(b1)

        number_cons1 = len(canvas.solver.constraints)

        b2 = Box()
        canvas.add(b2)

        number_cons2 = len(canvas.solver.constraints)

        conn = Connector(l1, l1.handles()[0])
        sink = ConnectionSink(b1, b1.ports()[0])

        conn.connect(sink)

        assert canvas.get_connection(l1.handles()[0])

        conn = Connector(l1, l1.handles()[1])
        sink = ConnectionSink(b2, b2.ports()[0])

        conn.connect(sink)

        assert canvas.get_connection(l1.handles()[1])


        self.assertEquals(number_cons2 + 2, len(canvas.solver.constraints))

        canvas.remove(b1)

        # Expecting a class + line connected at one end only
        self.assertEquals(number_cons1 + 1, len(canvas.solver.constraints))
开发者ID:adrianboguszewski,项目名称:gaphas,代码行数:43,代码来源:test_canvas.py

示例11: SimpleCanvas

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [as 别名]
class SimpleCanvas(object):
    """Creates a test canvas object.

    Adds a view, canvas, and handle connection tool to a test
    case. Two boxes and a line are added to the canvas as well.
    """

    def __init__(self):
        self.canvas = Canvas()

        self.box1 = Box()
        self.canvas.add(self.box1)
        self.box1.matrix.translate(100, 50)
        self.box1.width = 40
        self.box1.height = 40
        self.box1.request_update()

        self.box2 = Box()
        self.canvas.add(self.box2)
        self.box2.matrix.translate(100, 150)
        self.box2.width = 50
        self.box2.height = 50
        self.box2.request_update()

        self.line = Line()
        self.head = self.line.handles()[0]
        self.tail = self.line.handles()[-1]
        self.tail.pos = 100, 100
        self.canvas.add(self.line)

        self.canvas.update_now()
        self.view = GtkView()
        self.view.canvas = self.canvas

        self.win = Gtk.Window()
        self.win.add(self.view)
        self.view.show()
        self.view.update()
        self.win.show()

        self.tool = ConnectHandleTool(self.view)
开发者ID:amolenaar,项目名称:gaphas,代码行数:43,代码来源:conftest.py

示例12: create_canvas

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [as 别名]
def create_canvas():
    canvas = Canvas()
    box = Box()
    canvas.add(box)
    box.matrix.translate(100, 50)
    box.matrix.rotate(50)
    box2 = Box()
    canvas.add(box2, parent=box)


    line = Line()
    line.handles()[0].visible = False
    line.handles()[0].connected_to = box
    line.handles()[0].disconnect = my_disconnect()
    line.handles()[0].connection_data = 1

    canvas.add(line)

    canvas.update()

    return canvas
开发者ID:jvorcak,项目名称:gpylint,代码行数:23,代码来源:test_pickle.py

示例13: test_disconnect_item_with_constraint

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [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

示例14: test_disconnect_item_with_constraint_by_deleting_element

# 需要导入模块: from gaphas.item import Line [as 别名]
# 或者: from gaphas.item.Line import handles [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

示例15: test_disconnect_item_with_constraint_by_deleting_element

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