#!/usr/bin/perl -w

# LinguaNormsUSF-tk - Basic interface to Nelson association norms (University of South Florida) via Lingua::Norms::USF

use strict;
use Tk;

use strict;
use warnings;

use Lingua::Norms::USF;

my $mw = MainWindow->new();
my $word = '';
my $wdata = 0;

$mw->setPalette('#f5f5f5');

my $usf = Lingua::Norms::USF->new();

my $fw = $mw->Frame()->pack();
 
$fw->Label(-text => 'word:')->grid(-row => 0, -column => 0, -sticky => 'n', -padx => 0);

$fw->Entry(-textvariable => \$word)->grid(-row => 0, -column => 1, -sticky => 'n', -padx => 0);

$fw->Button(-text => 'list associates', -command => sub {
    if ($wdata) {
        printf("\%s\n", join(',',@{$_})) foreach $usf->list_associates($word, ref => 0, data => 1);
    }
    else {
        printf("\%s\t", $_) foreach $usf->list_associates($word, ref => 0);
        print "\n";
    }
})->grid(-row => 0, -column => 2, -sticky => 'n', -padx => 0);

$fw->Button(-text => 'list cues', -command => sub {
    printf("\%s\t", $_) foreach $usf->list_cues($word, ref => 0);
    print "\n";
})->grid(-row => 0, -column => 3, -sticky => 'n', -padx => 0);

$fw->Checkbutton(-variable => \$wdata, -text => 'with data?', -selectcolor => $mw->cget(-bg))->grid(-row => 0, -column => 4, -sticky => 'n', -padx => 0);

MainLoop;