JoinGladeApp

This example requires SimpleGladeApp.py, don't forget to download it.

JoinGladeApp.png

JoinGladeApp.png

JoinGladeApp.glade

JoinGladeApp.py

#!/usr/bin/env python
# -*- coding:UTF-8 -*-

from SimpleGladeApp import SimpleGladeApp
import gtk
import cairo
import cairo.gtk

class JoinGladeApp(SimpleGladeApp):

        def on_expose(self, area, event):
                self.ctx = cairo.Context()
                cairo.gtk.set_target_drawable(self.ctx, self.drawingarea1.window)
                width, height = self.drawingarea1.window.get_size()
                self.ctx.scale(width/100.0, height/100.0)


                self.draw_line1()
                self.draw_line2()
                self.draw_line3()
                self.draw_altline1()
                self.draw_altline2()
                self.draw_altline3()

        def draw_line1(self):
                self.ctx.set_rgb_color(0, 0, 0)
                self.ctx.set_line_width(12)
                self.ctx.set_line_join(cairo.LINE_JOIN_MITER)
                self.ctx.move_to(20, 40)
                self.ctx.rel_line_to(30, -20)
                self.ctx.rel_line_to(30, 20)
                self.ctx.stroke()

        def draw_line2(self):
                self.ctx.set_rgb_color(0, 0, 0)
                self.ctx.set_line_width(12)
                self.ctx.set_line_join(cairo.LINE_JOIN_BEVEL)
                self.ctx.move_to(20, 60)
                self.ctx.rel_line_to(30, -20)
                self.ctx.rel_line_to(30, 20)
                self.ctx.stroke()

        def draw_line3(self):
                self.ctx.set_rgb_color(0, 0, 0)
                self.ctx.set_line_width(12)
                self.ctx.set_line_join(cairo.LINE_JOIN_ROUND)
                self.ctx.move_to(20, 80)
                self.ctx.rel_line_to(30, -20)
                self.ctx.rel_line_to(30, 20)
                self.ctx.stroke()

        def draw_altline1(self):
                self.ctx.set_rgb_color(0.2, 0.2, 2)
                self.ctx.set_line_width(2)
                self.ctx.set_line_join(cairo.LINE_JOIN_MITER)
                self.ctx.move_to(20, 40)
                self.ctx.rel_line_to(30, -20)
                self.ctx.rel_line_to(30, 20)
                self.ctx.stroke()

        def draw_altline2(self):
                self.ctx.set_rgb_color(0.2, 0.2, 2)
                self.ctx.set_line_width(2)
                self.ctx.set_line_join(cairo.LINE_JOIN_BEVEL)
                self.ctx.move_to(20, 60)
                self.ctx.rel_line_to(30, -20)
                self.ctx.rel_line_to(30, 20)
                self.ctx.stroke()

        def draw_altline3(self):
                self.ctx.set_rgb_color(0.2, 0.2, 2)
                self.ctx.set_line_width(2)
                self.ctx.set_line_join(cairo.LINE_JOIN_ROUND)
                self.ctx.move_to(20, 80)
                self.ctx.rel_line_to(30, -20)
                self.ctx.rel_line_to(30, 20)
                self.ctx.stroke()

app = JoinGladeApp('JoinGladeApp.glade')
app.run()