#! /usr/bin/env python # -*- coding: iso8859-1 -*- import gtk, pango, time white = gtk.gdk.color_parse ("#000") black = gtk.gdk.color_parse ("#fff") count = 0 layout = None drawarea = None fontname = "PMN Caecilia, bold 27" fontname = "NomisScript 45" fontname = "URW Palladio L, Italic 30" fontname = "URW Chancery L, Medium Italic 33" developers = [u"Spencer Kimball", "Peter Mattis", "Adam D. Moss"] text = u"""Far out in the uncharted backwaters of the unfashionable end of the western spiral arm of the Galaxy lies a small unregarded yellow sun. Orbiting this at a distance of roughly ninety-two million miles is an utterly insigni\N{LATIN SMALL LIGATURE FI}cant little blue green planet. This planet has \N{EN DASH} or rather had \N{EN DASH} a problem, which was this: most of the people on it were unhappy for pretty much of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movements of small green pieces of paper, which is odd because on the whole it wasn't the small green pieces of paper that were unhappy\N{HORIZONTAL ELLIPSIS}""" text = u"""\N{EN DASH}\N{EM QUAD}\N{EN DASH} \N{EN DASH}\N{EM SPACE}\N{EN DASH} \N{EN DASH}\N{EN QUAD}\N{EN DASH} \N{EN DASH}\N{EN SPACE}\N{EN DASH} \N{EN DASH}\N{FIGURE SPACE}\N{EN DASH} \N{EN DASH}\N{THREE-PER-EM SPACE}\N{EN DASH} \N{EN DASH}\N{FOUR-PER-EM SPACE}\N{EN DASH} \N{EN DASH}\N{PUNCTUATION SPACE}\N{EN DASH} \N{EN DASH}\N{THIN SPACE}\N{EN DASH} \N{EN DASH}\N{SIX-PER-EM SPACE}\N{EN DASH} \N{EN DASH}\N{ZERO WIDTH SPACE}\N{EN DASH}""" def keypress (widget, event): if event.string.lower() == 'q': gtk.mainquit () def expose (widget, event): global layout widget.style.text_gc[widget.state].set_clip_rectangle (event.area) widget.window.draw_layout (widget.style.text_gc [widget.state], 50, 60, layout) def add_letter (): global drawarea, layout, count # layout.set_text (text[:count]) # count = (count + 7) % 510 count = count + 1 if count >= 256: char = "%02x" % (510 - count) else: char = "%02x" % count spcnr = [10,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9][count % 20] if count % 20 == 11: time.sleep (1) char = "%02x" % (round (spcnr * 25.5)) text = u"\n".join ([(u"\N{SIX-PER-EM SPACE}" * spcnr).join (list (i)) for i in developers]) layout.set_text (text) drawarea.modify_text (gtk.STATE_NORMAL, gtk.gdk.color_parse ("#" + char*3)) drawarea.queue_draw () return True # count < len (text) + 1 def showui (): global layout, drawarea drawarea = gtk.DrawingArea () drawarea.set_size_request (800, 600) drawarea.set_events (gtk.gdk.EXPOSURE_MASK) drawarea.connect ('expose_event', expose) win = gtk.Window () win.add (drawarea) win.set_events (gtk.gdk.KEY_PRESS_MASK) win.connect ('destroy', gtk.mainquit) win.connect ('key_press_event', keypress) font = pango.FontDescription (fontname) drawarea.modify_font (font) drawarea.modify_text (gtk.STATE_NORMAL, white) drawarea.modify_bg (gtk.STATE_NORMAL, black) layout = drawarea.create_pango_layout (text) layout.set_width (725 * 1000) layout.set_alignment (pango.ALIGN_CENTER) win.show_all () if __name__ == '__main__': showui () gtk.timeout_add (25, add_letter) gtk.main ()