Updated 22 Oct 2005
Brother t0mas -- Thanks so much for adding the button
bevel size change to ButtonFactory. What was once good is
even better!
In the interest of sharing, just for fun, I am posting
some code I quickly hacked up last night to do something a
little different with ButtonFactory from the command line.
Based on what you include as a sample command-line script
in the POD, here is what I am doing:
#!perl -w
## ------------------------------------------------------------
# MS Windoze-specific script. Sorry :-).
## ------------------------------------------------------------
# NOT like t0mas' original idea -- this makes buttons for
# horizontal row use only bec if button text is longer
# than 20 chars, it expands the length by 8 px for each one
# (based on 8pt Myriad font).
use ButtonFactory;
use Win32::Clipboard;
my ( $N_state $P_state @RGBt $BWi );
my $clipping;
my $name_it = shift @ARGV;
my $btnText = shift @ARGV;
my $expsn = ((length ($btnText) - 20) > 0)?
(length ($btnText) - 20) * 8 : 0 ;
$BWi = 90 + $expsn;
@RGBt = ($clipping=Win32::Clipboard::Get())
# Pick-'o-Color format for rgb triplet: "RGB(155, 50, 23)"
? grep /\d+/, (split /[^\d]/,$clipping)
: split(/[^\w]/, shift @ARGV);
if (scalar @RGBt == 3)
{
print "Using ", join( ', ',@RGBt ), " for color specification for b
+uttons\n";
}
else
{
die "No color as RGB triplet gotten! \nContents of \@RGBt if any: "
." $clipping ". "@RGBt";
}
my $x=new ButtonFactory($BWi,21,
$RGBt[0],$RGBt[1],$RGBt[2],
$btnText =>"Myriad Web Bold.ttf"=>8);
$N_state = $name_it .'N_state.png';
$P_state = $name_it .'P_state.png';
open (FILE,">$N_state") or die $!;
binmode FILE;
my $Ntime = time;
print FILE $x->printNormal();
close (FILE);
open (FILE,">$P_state") or die $!;
binmode FILE;
print FILE $x->printPressed();
close (FILE);
utime $Ntime, $Ntime, ($N_state, $P_state);
_END_
Pick'o'Color is (was) a
Windows app found at:
http://www.itsme.de/software/index.html
Best,
soren Intrepid
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.