Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

A simple words memorization tool

by bhappy (Scribe)
on Feb 24, 2004 at 12:12 UTC ( [id://331368]=sourcecode: print w/replies, xml ) Need Help??
Category: GUI Programming
Author/Contact Info bhappy
Description: Perl is not the only language i'm learning right now, i'm also learning english ;)... i was looking for a little tool, which would stay on the top of my desktop and show english words with a translation changing them in every N seconds. i'm using FlashKard, coming with KDE, and i have alredy collected a little vocabulary. so i decided to make a script which would use a file created by FlashKard (xml) and show words randomly.
don't judge it too strictly, it's my first public code.
i would be happy to get any notices, corrections or additions.
#!/usr/bin/perl

=head1 NAME

kvread - Vocabulary memorization tool

=head1 SYNOPSYS

kvread [file name]

=head1 DESCRIPTION

kvread makes use of a vocabulary files created by KDE FlashKard. This 
+script shows words from a given file with a translation\
 randomly.

=head1 AUTHOR

bhappy

=cut

use strict;
use warnings;

use Tk;
use XML::Simple;
use Getopt::Long;

my $xml_file = shift;
my $words = XMLin($xml_file,
                  forcearray => [ qw(e) ],
                  keyattr => []
                  );

my $mw = Tk::MainWindow->new;
# $mw->overrideredirect(1);
my ($worde, $wordr) = &rand_n(\@{$words->{e}});
$mw->Label(-textvariable => \$worde, -background => 'pink', -font => '
+verdana')->pack;
$mw->Label(-textvariable => \$wordr, -background => 'lightblue')->pack
+;
$mw->update;
$mw->repeat(8*1000, sub{($worde, $wordr) = &rand_n(\@{$words->{e}})});

MainLoop;

sub rand_n {
    my ($words_ref) = @_;
    my $count = rand @$words_ref;
    my $worde = $words_ref->[$count]->{o};
    my $wordr = $words_ref->[$count]->{t};
    return ($worde, $wordr);
}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://331368]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-18 09:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found