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 (Monk)
on Nov 11, 2012 at 05:11 UTC ( [id://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?

Replies are listed 'Best First'.
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).
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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-03-29 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found