Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Numeric entry Tk widget with up/down buttons, does it exist?

by perltux (Scribe)
on Nov 11, 2012 at 05:11 UTC ( #1003300=perlquestion: print w/ replies, xml ) Need Help??
perltux has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I was wondering if for Perl/Tk there is a ready-made widget that provides an entry box for numeric values with at the side up/down buttons, for example like this one (from Qt):
http://www.linuxtech.net/files/widget.png

If it doesn't exist, has anyone written such a custom widget and is willing to share the code?

Comment on Numeric entry Tk widget with up/down buttons, does it exist?
Re: Numeric entry Tk widget with up/down buttons, does it exist?
by trizen (Hermit) on Nov 11, 2012 at 08:15 UTC
    There is a module, called Tk::NumEntryPlain.
    use Tk; use strict; use Tk::NumEntry; use Tk::NumEntryPlain; my $mw = MainWindow->new; $mw->NumEntry( -minvalue => 10, -maxvalue => 30, -value => 15 )->pack; MainLoop;
      Thanks that looks exactly like what I need!
Re: Numeric entry Tk widget with up/down buttons, does it exist?
by Anonymous Monk on Nov 11, 2012 at 08:30 UTC

    It exists (the basics are the basics), see spin.pl, Spinbox Demonstration listed in widget under Entries and Spin-boxes as 4. Spin-boxes.

    $ perl -MTk -le " print Tk->findINC(q,demos/widget_lib/spin.pl,) "
    C:/perl/site/5.14.1/lib/MSWin32-x86-multi-thread/Tk/demos/widget_lib/spin.pl

Re: Numeric entry Tk widget with up/down buttons, does it exist?
by zentara (Archbishop) on Nov 11, 2012 at 10:18 UTC
    Here is a basic Spinbox example.
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Spinbox; #see also JComboBox my $mw = MainWindow->new; $mw->title("Spinner"); $mw->fontCreate('big', -family=>'courier', -weight=>'bold', -size=> 24); my $sp1 = $mw->Spinbox(-width => 2, -font => 'big', -command => sub{ &show_set }, -value => [0..23])->pack (-side=>'left'); $mw->Label(-text=>":")->pack (-side=>'left'); my $sp2 = $mw->Spinbox(-width => 2, -font => 'big', -command => sub{ &show_set }, -value => [0..59])->pack (-side=>'left'); MainLoop; ########################### sub show_set{ print "@_\n"; }

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Thanks, after checking out both NumEntry and Spinbox I chose Spinbox as it seems the better one (at least for my specific use-case).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1003300]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2015-07-07 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls