This example requires SimpleGladeApp.py, don't forget to download it.
#!/usr/bin/env python # -*- Coding:UTF-8 -*- from SimpleGladeApp import SimpleGladeApp from math import pi import gtk import cairo import cairo.gtk class Cairo5GladeApp(SimpleGladeApp): def new(self): self.elapsed = 50 self.curve = 0 self.count = 0 self.count2 = 0 self.sign = 1 self.on_timeout() def on_timeout(self): self.curve += 7.5 * self.sign self.count += 0.02 * self.sign self.count2 += 0.02 if self.count > 1: self.count = 1 global c c = self.count if self.count2 > 2: self.sign *= -1 self.count2 = 0 self.window1.queue_draw() gtk.timeout_add(self.elapsed, self.on_timeout) 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.rectangle(0, 0, width, height) self.ctx.fill() self.ctx.scale(width/100.0, height/100.0) self.ctx.set_rgb_color(1, 1, 1) self.draw_c() self.draw_a() self.draw_i() self.draw_r() self.draw_o() self.ctx.set_line_width(3) self.ctx.set_alpha(self.count) self.ctx.set_rgb_color(0.9, 0.2, 0.2) self.ctx.stroke() self.ctx.set_rgb_color(0, 0, 0) self.draw_text() def draw_c(self): self.ctx.move_to(35, 22) self.ctx.curve_to(c * 20 , c * 25 , c * 30 , c * 34 , c * 35 , c * 35) def draw_a(self): self.ctx.move_to(39, 38) self.ctx.curve_to(c * 41, c * 10, c * 44, c * 20, c * 50, c * 38) self.ctx.move_to(39, 30) self.ctx.line_to(c * 48, c * 30) def draw_i(self): self.ctx.move_to(57, 20) self.ctx.line_to(c * 55, c * 38) def draw_r(self): self.ctx.move_to(61, 20) self.ctx.line_to(c * 60, c * 38) self.ctx.move_to(61, 20) self.ctx.curve_to(c * 65, c * 22, c * 67, c * 28, c * 60, c * 30 ) self.ctx.move_to(61, 29) self.ctx.line_to(c * 65, c * 38) self.ctx.close_path() def draw_o(self): angle = self.curve if angle > 360: self.curve = angle self.ctx.arc(72, 30, 5, 0, angle * (pi/180) ) def draw_text(self): self.ctx.select_font("babelfish") self.ctx.scale_font(30) self.ctx.move_to(7, 75) self.ctx.text_path('PYTHON') self.ctx.save() self.ctx.set_rgb_color(0.5, 0.5, 1) self.ctx.fill() self.ctx.restore() self.ctx.set_line_width(0.5) self.ctx.stroke() app = Cairo5GladeApp('cairo5gladeapp.glade') app.run()