Exemple #1
0
def main():
    ##
    ## State handling (a.k.a. undo handlers)
    ##

    # First, activate the revert handler:
    state.observers.add(state.revert_handler)

    def print_handler(event):
        print 'event:', event

    c = Canvas()

    create_window(c, 'View created before')

    create_canvas(c)

    #state.subscribers.add(print_handler)

    ##
    ## Start the main application
    ##

    create_window(c, 'View created after')

    gtk.main()
Exemple #2
0
    def activate(app):
        c = Canvas()

        win1 = create_window(c, "View created before")
        app.add_window(win1)
        create_canvas(c)
        win2 = create_window(c, "View created after")
        app.add_window(win2)
Exemple #3
0
def main():
    # State handling (a.k.a. undo handlers)

    def print_handler(event):
        print("event:", event)

    c = Canvas()

    create_window(c, "View created before")

    create_canvas(c)

    # Start the main application

    create_window(c, "View created after")

    Gtk.main()
Exemple #4
0
def main():
    builder = Gtk.Builder()
    builder.add_from_file("AppWindow.glade")

    graph_view = GtkView()
    graph_view.painter = DefaultPainter()
    graph_view.canvas = Canvas()

    gaphas_window = builder.get_object("GaphasWindow")
    gaphas_window.add(graph_view)

    main_view = MainView()
    controller = Controller(builder, main_view, graph_view)
    builder.connect_signals(controller)
    #view.connect("focus-changed", handler.focus_changed, "focus")

    window = builder.get_object("MainWindow")
    main_view.show_main_window(window)

    Gtk.main()
Exemple #5
0
    def __init__(self):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)

        log.info("Loading Workbench")
        canvas = Canvas()
        view = GtkView()
        __.canvas = canvas
        __.view = view
        view.painter = DefaultPainter()
        view.canvas = canvas
        self.pack_start(view, True, True, 20)
        self.index = interpreter()

        self.index.add_to_canvas(canvas)
        # # Draw first gaphas box
        # b1 = Box(Rectangle(1, 0, 60, 60))
        # canvas.add(b1)

        # tx = Text(text="joo")
        # tx.matrix.translate(20, 20)
        # canvas.add(tx)

        # # Draw second gaphas box
        # b2 = Box(Rectangle(170, 170, 60, 60))
        # canvas.add(b2)

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

        self.view = view
        self.canvas = canvas
        self.show_all()
        log.info("Workbench loaded")

        view.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
        # self.connect('clicked', self.on_field_click)
        # "set-focus-child" container, widget
        self.connect("focus", self.on_field_click)
Exemple #6
0
def main():
    # State handling (a.k.a. undo handlers)

    # First, activate the revert handler:
    state.observers.add(state.revert_handler)

    def print_handler(event):
        print("event:", event)

    c = Canvas()

    create_window(c, "View created before")

    create_canvas(c)

    # state.subscribers.add(print_handler)

    # Start the main application

    create_window(c, "View created after")

    Gtk.main()
Exemple #7
0
def create_canvas(c=None):
    if not c:
        c = Canvas()
    b = MyBox()
    b.min_width = 20
    b.min_height = 30
    b.matrix = (1.0, 0.0, 0.0, 1, 20, 20)
    b.width = b.height = 40
    c.add(b)

    bb = Box()
    bb.matrix = (1.0, 0.0, 0.0, 1, 10, 10)
    c.add(bb, parent=b)

    fl = FatLine()
    fl.height = 50
    fl.matrix.translate(100, 100)
    c.add(fl)

    circle = Circle()
    h1, h2 = circle.handles()
    circle.radius = 20
    circle.matrix.translate(50, 100)
    c.add(circle)

    # AJM: extra boxes:
    bb = Box()
    bb.matrix.rotate(math.pi / 1.567)
    c.add(bb, parent=b)
    # for i in xrange(10):
    #     bb = Box()
    #     print('box', bb)
    #     bb.matrix.rotate(math.pi/4.0 * i / 10.0)
    #     c.add(bb, parent=b)

    b = PortoBox(60, 60)
    b.min_width = 40
    b.min_height = 50
    b.matrix.translate(55, 55)
    c.add(b)

    t = UnderlineText()
    t.matrix.translate(70, 30)
    c.add(t)

    t = MyText("Single line")
    t.matrix.translate(70, 70)
    c.add(t)

    l = MyLine()
    c.add(l)
    l.handles()[1].pos = (30, 30)
    segment = Segment(l, view=None)
    segment.split_segment(0, 3)
    l.matrix.translate(30, 60)
    l.orthogonal = True

    off_y = 0
    for align_x in (-1, 0, 1):
        for align_y in (-1, 0, 1):
            t = MyText(
                f"Aligned text {align_x:d}/{align_y:d}",
                align_x=align_x,
                align_y=align_y,
            )
            t.matrix.translate(120, 200 + off_y)
            off_y += 30
            c.add(t)

    t = MyText("Multiple\nlines", multiline=True)
    t.matrix.translate(70, 100)
    c.add(t)

    return c
Exemple #8
0
    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)


c = Canvas()
create_canvas(c, "Simple Gaphas App")
Gtk.main()
Exemple #9
0
def create_canvas(c=None):
    if not c:
        c = Canvas()
    b=MyBox()
    b.min_width = 20
    b.min_height = 30
    print 'box', b
    b.matrix=(1.0, 0.0, 0.0, 1, 20,20)
    b.width = b.height = 40
    c.add(b)

    bb=Box()
    print 'box', bb
    bb.matrix=(1.0, 0.0, 0.0, 1, 10,10)
    c.add(bb, parent=b)

    fl = FatLine()
    fl.height = 50
    fl.matrix.translate(100, 100)
    c.add(fl)

    circle = Circle()
    h1, h2 = circle.handles()
    circle.radius = 20
    circle.matrix.translate(50, 100)
    c.add(circle)

    # AJM: extra boxes:
    bb = Box()
    print 'box', bb
    bb.matrix.rotate(math.pi/4.)
    c.add(bb, parent=b)
#    for i in xrange(10):
#        bb=Box()
#        print 'box', bb
#        bb.matrix.rotate(math.pi/4.0 * i / 10.0)
#        c.add(bb, parent=b)

    b = PortoBox(60, 60)
    b.min_width = 40
    b.min_height = 50
    b.matrix.translate(55, 55)
    c.add(b)

    t = UnderlineText()
    t.matrix.translate(70,30)
    c.add(t)

    t = MyText('Single line')
    t.matrix.translate(70,70)
    c.add(t)

    l = MyLine()
    c.add(l)
    l.handles()[1].pos = (30, 30)
    segment = Segment(l, view=None)
    segment.split_segment(0, 3)
    l.matrix.translate(30, 60)
    l.orthogonal = True

    off_y = 0
    for align_x in (-1, 0, 1):
        for align_y in (-1, 0, 1):
            t=MyText('Aligned text %d/%d' % (align_x, align_y),
                     align_x=align_x, align_y=align_y)
            t.matrix.translate(120, 200 + off_y)
            off_y += 30
            c.add(t)

    t=MyText('Multiple\nlines', multiline = True)
    t.matrix.translate(70,100)
    c.add(t)

    return c
Exemple #10
0
def create_canvas(c=None):
    if not c:
        c = Canvas()
    b = MyBox(c.connections)
    b.min_width = 20
    b.min_height = 30
    b.matrix.translate(20, 20)
    b.width = b.height = 40
    c.add(b)

    bb = Box(c.connections)
    bb.matrix.translate(10, 10)
    c.add(bb, parent=b)

    bb = Box(c.connections)
    bb.matrix.rotate(math.pi / 1.567)
    c.add(bb, parent=b)

    circle = Circle()
    h1, h2 = circle.handles()
    circle.radius = 20
    circle.matrix.translate(50, 160)
    c.add(circle)

    pb = Box(c.connections, 60, 60)
    pb.min_width = 40
    pb.min_height = 50
    pb.matrix.translate(100, 20)
    c.add(pb)

    ut = UnderlineText()
    ut.matrix.translate(100, 130)
    c.add(ut)

    t = MyText("Single line")
    t.matrix.translate(100, 170)
    c.add(t)

    line = MyLine(c.connections)
    c.add(line)
    line.handles()[1].pos = (30, 30)
    segment = Segment(line, c)
    segment.split_segment(0, 3)
    line.matrix.translate(30, 80)
    line.orthogonal = True

    return c