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

Hello, I'm new here and was wondering if someone could tell me if there's a way of making spinners (I'm not sure about the terminology I think that's what they're called in office so it is likely to be different for Unix based systems) in perl/tk. I haven't really been able to find anything to help me and the only way I've thought about doing this is by creating 2 buttons and placing them one on top of the other. I'm new with this language so any help would be much appreciated :D (thank you)

Replies are listed 'Best First'.
Re: "spinners" in perl/tk
by castaway (Parson) on Nov 21, 2004 at 18:32 UTC
    You appear to want Tk::SpinBox. Your Perl/Tk installation should include the "widget" programm, which has examples/demonstrations of a lot of the Tk:: widgets. Try running it and look at the examples for SpinBox.

    C.

Re: "spinners" in perl/tk
by perlNoob (Acolyte) on Nov 21, 2004 at 19:21 UTC
    Thank you for the quick reply but I also have one more question about this, i'm trying to create a spinner that will allow the user to chose a time (00:00 - 23:59) but I can't seem to figure out how I can associate the 2.

    also I tried this code:

    use Tk; use Tk::SpinBox; my $mw = MainWindow->new; $mw->title("Spinner"); $mw->MainWindow->Frame(-relief=>'groove'); $mw->minsize(600,300); my $spin = $mw -> SpinBox()-> pack ( -anchor => 'nw'); MainLoop;
    but it says:
    Assuming 'require Tk::SpinBox;' at a.pl line 9
    Failed to AUTOLOAD 'Tk::Widget::SpinBox' at a.pl line 9

    and i've gone to my perl and perl lib folder and done:
    ppm install Tk::SpinBox

    any suggestions? :S

    PS: I tried to make my message neater this time, I hope it's up to standards :)

      Hmm, I have no Windows installation to check, but I guess its there somewhere. It should be in the standard Tk set of widgets. (It also appears to be inside another widget).

      Did you look at the widget example? In your case, you'll probably need to pass it a list of values for every minute between 00:00 and 23:59, using the -values attribute.

      my $spin = $mw->SpinBox(-values => ['00:00','00:01','00:02' .. ])-> pa +ck ( -anchor => 'nw');
      Or did you mean you want two spinboxes, one for hours and one for minutes? Then you'll have to set up callbacks for the -command attribute.

      PS: Please don't double post things, thanks.

      C.

      "Failed to AUTOLOAD 'Tk::Widget::SpinBox' at a.pl line 9"

      Spell SpinBox as Spinbox, a small b ;-)

        you probably have older version of Tk installed which doesn't contains Tk::SpinBox module. Try installing the latest version of Tk from CPAN.
Re: "spinners" in perl/tk
by pg (Canon) on Nov 21, 2004 at 22:14 UTC
    use Tk; use Tk::SpinBox; my $mw = MainWindow->new; $mw->title("Spinner"); $mw->Spinbox(-width => 2, -value => [0..23])->pack (-side=>'left'); $mw->Label(-text=>":")->pack (-side=>'left'); $mw->Spinbox(-width => 2, -value => [0..59])->pack (-side=>'left'); MainLoop;