| Category: | Utility Scripts |
| Author/Contact Info | smokemachine |
| Description: | financery calculator |
Can any one help me to finish this?!
#!/usr/bin/perl -w
#use strict;
require 5.002;
use Tk;
use Tk::Text;
use Tk::Menu;
use Tk::Scrollbar;
use Tk::DialogBox;
use Tk::ROText;
use Tk::Pixmap;
use Tk::Bitmap;
our $x=0;
our $y=0;
our $z=0;
our $t=0;
our $res='n';
our $sto='n';
our $rcl='n';
our $pnt='n';
our $sto0=0;
our $sto1=0;
our $sto2=0;
our $sto3=0;
our $sto4=0;
our $sto5=0;
our $sto6=0;
our $sto7=0;
our $sto8=0;
our $sto9=0;
our $stop0=0;
our $stop1=0;
our $stop2=0;
our $stop3=0;
our $stop4=0;
our $stop5=0;
our $stop6=0;
our $stop7=0;
our $stop8=0;
our $stop9=0;
our $xxx='17';
my $mw = MainWindow->new;
$mw->maxsize(qw(400 200));
$mw->minsize(qw(400 200));
$mw->title("Calculadora Financeira");
$mw->configure(-bg=>"black");
$label = $mw->Text(
-background => 'light goldenrod',
-borderwidth => '0',
-width => '50',
-height => '4',
-state => 'disable'
)->pack;
#my $fundo = $mw->Pixmap(
# -data => '/* XPM*/',
# -background => 'yellow',
# -file => 'calc.xpm',
# -width => '350',
# -height => '50'
# )->pack(-side => 'top');
########################################################
our $dis = $mw->Entry(
-width => '10',
)->pack;
$dis->place(-x=>'105',-y=>'20');
######################################################################
+########################################
my $enter = $mw->Button(
-text => 'Enter',
-command => sub{entersub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$enter->place(-x=>'197',-y=>'155');
my $soma = $mw->Button(
-text => '+',
-command => sub{somasub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$soma->place(-x=>'353',-y=>'170');
my $subitracao = $mw->Button(
-text => '-',
-command => sub{subtrasub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$subitracao->place(-x=>'353',-y=>'140');
my $multiplicacao = $mw->Button(
-text => 'x',
-command => sub{multisub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$multiplicacao->place(-x=>'353',-y=>'110');
my $divisao = $mw->Button(
-text => '/',
-command => sub{divisub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$divisao->place(-x=>'353',-y=>'80');
######################################################################
+###############################################
my $CLx = $mw->Button(
-text => 'CLx',
-command => sub{CLxsub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$CLx->place(-x=>133 + $xxx,-y=>'140');
my $xsy = $mw->Button(
-text => 'xsy',
-command => sub{xsysub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$xsy->place(-x=>100 + $xxx,-y=>'140');
my $Rs = $mw->Button(
-text => 'Rs',
-command => sub{Rssub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$Rs->place(-x=>66 + $xxx,-y=>'140');
my $SST = $mw->Button(
-text => 'SST',
# -command => sub{Rssub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$SST->place(-x=>33 + $xxx,-y=>'140');
my $RbS = $mw->Button(
-text => 'R/S',
# -command => sub{Rssub()},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$RbS->place(-x=> $xxx,-y=>'140');
my $RCL = $mw->Button(
-text => 'RCL',
-command => sub{$rcl='s'},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$RCL->place(-x=>133 + $xxx,-y=>'170');
my $STO = $mw->Button(
-text => 'STO',
-command => sub{$sto='s'},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$STO->place(-x=>100 + $xxx,-y=>'170');
my $g = $mw->Button(
-text => 'g',
# -command => sub{$sto='s'},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'dark blue'
)->pack;
$g->place(-x=>66 + $xxx,-y=>'170');
my $f = $mw->Button(
-text => 'f',
# -command => sub{$sto='s'},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'dark goldenrod'
)->pack;
$f->place(-x=>33 + $xxx,-y=>'170');
my $OFF = $mw->Button(
-text => 'OFF',
-command => sub{exit},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$OFF->place(-x=>$xxx,-y=>'170');
######################################################################
+###########################################
my $zero=$mw->Button(
-text => '0',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop0=$dis->get:
$sto0=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop0):
$dis->insert('end',$sto0);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','0')},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$zero->place(-x=>'245',-y=>'170');
my $ponto=$mw->Button(
-text => '.',
-command => sub
{
if($sto eq 's')
{
$pnt='s';
return;
}
if($rcl eq 's')
{
$pnt='s';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','.')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$ponto->place(-x=>'275',-y=>'170');
my $somatorio=$mw->Button(
-text => 'E+',
# -command => sub{$dis->insert('end','E')},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$somatorio->place(-x=>'305',-y=>'170');
my $um=$mw->Button(
-text => '1',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop1=$dis->get:
$sto1=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop1):
$dis->insert('end',$sto1);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','1')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$um->place(-x=>'245',-y=>'140');
my $dois=$mw->Button(
-text => '2',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop2=$dis->get:
$sto2=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop2):
$dis->insert('end',$sto2);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','2')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$dois->place(-x=>'275',-y=>'140');
my $tres=$mw->Button(
-text => '3',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop3=$dis->get:
$sto3=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop3):
$dis->insert('end',$sto3);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','3')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$tres->place(-x=>'305',-y=>'140');
my $quatro=$mw->Button(
-text => '4',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop4=$dis->get:
$sto4=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop4):
$dis->insert('end',$sto4);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','4')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$quatro->place(-x=>'245',-y=>'110');
my $cinco=$mw->Button(
-text => '5',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop5=$dis->get:
$sto5=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop5):
$dis->insert('end',$sto5);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','5')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$cinco->place(-x=>'275',-y=>'110');
my $seis=$mw->Button(
-text => '6',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop6=$dis->get:
$sto6=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop6):
$dis->insert('end',$sto6);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','6')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$seis->place(-x=>'305',-y=>'110');
my $sete=$mw->Button(
-text => '7',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop7=$dis->get:
$sto7=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop7):
$dis->insert('end',$sto7);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','7')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$sete->place(-x=>'245',-y=>'80');
my $oito=$mw->Button(
-text => '8',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop8=$dis->get:
$sto8=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop8):
$dis->insert('end',$sto8);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','8')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$oito->place(-x=>'275',-y=>'80');
my $nove=$mw->Button(
-text => '9',
-command => sub
{
if ($sto eq 's')
{
($pnt eq 's')?
$stop9=$dis->get:
$sto9=$dis->get;
$sto='n';
$res='s';
$pnt='n';
return;
} elsif ($rcl eq 's')
{
$dis->delete('0.0','end');
($pnt eq 's')?
$dis->insert('end',$stop9):
$dis->insert('end',$sto9);
$rcl='n';
$pnt='n';
return;
}
if ($res eq 's')
{
$dis->delete('0.0','end');
$res='n';
}
$dis->insert('end','9')
},
-width =>'1',
-height =>'1',
-foreground => 'white',
-background => 'black'
)->pack;
$nove->place(-x=>'305',-y=>'80');
MainLoop;
######################################################################
+#############################################
sub entersub
{
$t=$z;
$z=$x;
$x=$dis->get;
$y=$x;
#$dis->delete('0.0','end');
$res='s';
}
sub somasub
{
if ($res eq 's')
{
$x+=$y;
} else
{
$x+=$dis->get;
}
$dis->delete('0.0','end');
$dis->insert('end',$x);
$y=$z;
$z=$t;
$res='s';
}
sub subtrasub
{
if ($res eq 's')
{
$x-=$y;
} else
{
$x-=$dis->get;
}
$dis->delete('0.0','end');
$dis->insert('end',$x);
$y=$z;
$z=$t;
$res='s';
}
sub multisub
{
if ($res eq 's')
{
$x*=$y;
} else
{
$x*=$dis->get;
}
$dis->delete('0.0','end');
$dis->insert('end',$x);
$y=$z;
$z=$t;
$res='s';
}
sub divisub
{
if ($res eq 's')
{
$x/=$y;
} else
{
$x/=$dis->get;
}
$dis->delete('0.0','end');
$dis->insert('end',$x);
$y=$z;
$z=$t;
$res='s';
}
######################################################################
+#############################################
sub CLxsub
{
$x=0;
$dis->delete('0.0','end');
}
sub xsysub
{
$x = $y;
$y = $dis->get;
$dis->delete('0.0','end');
$dis->insert('end',$x);
$res='s';
}
sub Rssub
{
my $aj=$dis->get;
$dis->delete('0.0','end');
$dis->insert('end',$y);
$x=$y;
$y=$z;
$z=$t;
$t=$aj;
$res='s';
}
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Xcalcfin
by jdporter (Paladin) on Jan 05, 2006 at 22:12 UTC | |
|
Re: Xcalcfin
by liverpole (Monsignor) on Jan 06, 2006 at 16:07 UTC | |
|
Re: Xcalcfin
by zentara (Cardinal) on Jan 05, 2006 at 22:09 UTC |