Soko has asked for the wisdom of the Perl Monks concerning the following question:

Hello, Monks.

I found the above Perl module - it's a text entry box with two button widgets that allows one to increment or decrement an integer scalar variable - and it works very well at what it does. I'd love to find a comparable widget that allows one to use decimal values as well - IOW I'd like to be able to change the value of the increment/decrement from 1 to 0.1, 0.001 or 0.5, etc. I've found nothing to indicate that Tk::NumEntry allows for this in it's PerlDocs or via Google, nor found a Perl module that fulfills my needs. I even opened up NumEntry.pm and the two widget's it's derived from, NumEntryPlain.pm and FireButton.pm, but didn't see anything terribly

I thought about inserting a decimal value into the NumEntry, and then using regexps and/or simple math to allow this, but it would be far easier and much less of a bandaid to find a widget that does this natively. Or, to modify NumEntry to accept a -incrementValue parameter or somesuch. Has anyone found a widget that does what I want, or have you come up with another solution?

Thanks in advance,

Soko

Replies are listed 'Best First'.
Re: Tk::NumEntry - for decimals?
by crouchingpenguin (Priest) on May 21, 2003 at 17:06 UTC

    Tk::NumEntry supports -increment like so:

    #!/usr/bin/perl use strict; use warnings; use Tk 800; use Tk::NumEntry; my $mw = Tk::MainWindow->new( -title => 'Tk::NumEntry demo' ); my $ne = $mw->NumEntry( -value => 20.01, -increment => .2, )->pack(); # UPDATE: and you can always change the increment # $ne->configure( -increment => .002 ); $mw->MainLoop(); 1;

    cp
    ----
    "Never be afraid to try something new. Remember, amateurs built the ark. Professionals built the Titanic."
Re: Tk::NumEntry - for decimals?
by Soko (Sexton) on May 21, 2003 at 17:09 UTC
    Sorry - the first paragraph's last sentence should end in "terribly promising". *embarassed grin*

    Soko