[Perl Tk] ASCII Art 0.2

Iniciado por BigBear, Octubre 04, 2012, 07:32:04 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Version Tk de esta nueva version de este script para hacer ascii art desde una palabra.

Una imagen


El codigo

Código: perl

#!usr/bin/perl
#ASCII Art 0.2
#Version Tk
#Coded By Doddy H
#
#http://search.cpan.org/~lory/Text-Banner-1.00/Banner.pm
#

use Tk;
use Tk::Dialog;
use Text::Banner;

#if ( $^O eq 'MSWin32' ) {
#use Win32::Console;
#Win32::Console::Free();
#}

my $color_fondo = "black";
my $color_texto = "green";

my $ven =
  MainWindow->new( -background => $color_fondo, -foreground => $color_texto );
$ven->title("ASCII Art 0.2 || Written By Doddy H");
$ven->geometry("555x305+20+20");
$ven->resizable( 0, 0 );

my $start = Text::Banner->new;

$menula = $ven->Frame(
    -relief     => "sunken",
    -bd         => 1,
    -background => $color_fondo,
    -foreground => $color_texto
);
my $menulnowaxm = $menula->Menubutton(
    -text             => "Options",
    -underline        => 1,
    -background       => $color_fondo,
    -foreground       => $color_texto,
    -activebackground => $color_texto
)->pack( -side => "left" );
my $aboutnowaxm = $menula->Menubutton(
    -text             => "About",
    -underline        => 1,
    -background       => $color_fondo,
    -foreground       => $color_texto,
    -activebackground => $color_texto
)->pack( -side => "left" );
my $exitnowaxm = $menula->Menubutton(
    -text             => "Exit",
    -underline        => 1,
    -background       => $color_fondo,
    -foreground       => $color_texto,
    -activebackground => $color_texto
)->pack( -side => "left" );
$menula->pack( -side => "top", -fill => "x" );

$menulnowaxm->command(
    -label      => "Scan",
    -background => $color_fondo,
    -foreground => $color_texto,
    -command    => \&now
);

$aboutnowaxm->command(
    -label      => "About",
    -background => $color_fondo,
    -foreground => $color_texto,
    -command    => \&about
);

$exitnowaxm->command(
    -label      => "Exit",
    -background => $color_fondo,
    -foreground => $color_texto,
    -command    => \&exitnow
);

my $fondo = $ven->Text(
    -width      => 75,
    -heigh      => 15,
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 12, -y => 40 );
$ven->Label(
    -text       => "Text : ",
    -font       => "Impact1",
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 20, -y => 265 );
my $tengo = $ven->Entry(
    -width      => 40,
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 66, -y => 269 );

$ven->Label(
    -text       => "Fill : ",
    -font       => "Impact1",
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 340, -y => 265 );
my $fi = $ven->Entry(
    -width      => 5,
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 375, -y => 269 );

MainLoop;

sub about {
    $ven->Dialog(
        -title            => "About",
        -buttons          => ["OK"],
        -text             => "Coded By Doddy H",
        -background       => $color_fondo,
        -foreground       => $color_texto,
        -activebackground => $color_texto
    )->Show();
}

sub exitnow {
    exit(1);
}

sub artnow {

    $start->set( $tengo->get );
    $start->fill( $fi->get );

    return $start->get;

}

sub now {

    $fondo->delete( "0.1", "end" );

    my $now  = $tengo->get;
    my $code = artnow($now);

    $fondo->insert( "end", $code );

}

#The End ?