Re: muppet's alphabet teacher V2

On Fri, 27 Apr 2007 15:45:33 -0400
zentara <zentara1 sbcglobal net> wrote:

With slight modifications, the alphabet trainer can be upgraded
to V2... the keyboard trainer.  Train those monkeys while they are young,
I predict we will get some Shakespeare out of them. :-)

#!/usr/bin/perl -w

# muppet
# 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.  :-)

# zentara
# Version 2 ... the keyboard for all who purchased
# Version 1 within the last year :-)

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 (100000);
$label->modify_font ($font_desc);
$window->add ($label);

$window->signal_connect (key_release_event => \&keyrelease);

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

sub keyrelease {
        my ($widget, $event) = @_;
        my $key = Gtk2::Gdk->keyval_name ($event->keyval);
        if( $key =~ /^(Alt|Multi|Control|Shift)/ ){ return }   
        $key =~ tr/_/ /;
        my $ukey = uc($key);
        $label->set_text ($ukey);
        Gtk2->main_iteration while Gtk2->events_pending;
        system('flite', '-t', "$key");


I'm not really a human, but I play one on earth.

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