use Tk;

$top = tkinit;
$messagetext = "Click here and/or type to stdin.\n";
$m = Message::new($top, "-width" => 150, "-textvariable" => $messagetext);
tkpack $m, "-fill" => "both", "-expand" => "y";
tkbind($m, "<1>", sub { print "Hello world\n" });
addasyncio(STDIN, "r", \&handlepipe);
tkmainloop;

sub handlepipe {
    my($slave, $toread, $towrite, $exception) = @_;
    if ($toread) {
        sysread(STDIN, $_, $toread);
        $messagetext .= $_;
    } else {
        delasyncio(STDIN);
    }
    update;
}

