Simple edutainment with gtk+ and perl

This simple bit of code has helped my toddlers learn letters and numbers for quite some time. I thought i should share it, if for nothing else than the line where i set the font size. :-)

#!/usr/bin/perl -w
use strict;
use Gtk2 -init;

my $window = Gtk2::Window->new;
my $label = Gtk2::Label->new ("W");
my $font_desc = Gtk2::Pango::FontDescription->from_string ("Sans Bold");
$font_desc->set_size (512000);
$label->modify_font ($font_desc);
$window->add ($label);
$window->signal_connect (key_press_event => sub {
        my ($widget, $event) = @_;
        my $key = uc Gtk2::Gdk->keyval_name ($event->keyval);
        $label->set_text ($key) if $key =~ m/^[[:alnum:]]$/;

$window->signal_connect (destroy => sub { Gtk2->main_quit });

One, two, free, four, five, six, sebben, eight, nine, ten, elebben, twull, fourteen, sickteen, sebbenteen, eightteen, elebbenteen, fiffeen, elebbenteen!
  -- Zella, aged three, counting to twenty.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]