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])
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)
class SimpleCanvas: """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)