| 1 | # ############################################################################## | ||
| 2 | # # Script : Buttonbox.pl # | ||
| 3 | # # -------------------------------------------------------------------------- # | ||
| 4 | # # Copyright : This program is free software; you can redistribute it and/or # | ||
| 5 | # # modify it under the same terms as Perl itself. # | ||
| 6 | # # Author : Jürgen von Brietzke JvBSoft # | ||
| 7 | # # Version : 1.2.01 16.Jun.2013 # | ||
| 8 | # ############################################################################## | ||
| 9 | # # http://incrtcl.sourceforge.net/iwidgets/iwidgets/buttonbox.html # | ||
| 10 | # ############################################################################## | ||
| 11 | |||
| 12 | use strict; | ||
| 13 | use warnings; | ||
| 14 | |||
| 15 | use Tkx::TclTk::Bind::IWidgets; | ||
| 16 | |||
| 17 | # ############################################################################## | ||
| 18 | |||
| 19 | our $current = 0; | ||
| 20 | our $last = 5; | ||
| 21 | our $buttonbox; | ||
| 22 | |||
| 23 | my $main_window = Tkx::widget->new(q{.}); | ||
| 24 | $main_window->Tkx::wm_title('Buttonbox Example'); | ||
| 25 | $buttonbox = $main_window->new_iwidgets__buttonbox( | ||
| 26 | -padx => 10, | ||
| 27 | -pady => 10, | ||
| 28 | ); | ||
| 29 | foreach my $t (qw(more less)) { | ||
| 30 | no strict; | ||
| 31 | $buttonbox->add( $t, -text => $t, -command => \&{$t} ); | ||
| 32 | use strict; | ||
| 33 | } | ||
| 34 | foreach my $i ( 1 .. 5 ) { | ||
| 35 | $buttonbox->add( "button$i", -text => "Button$i" ); | ||
| 36 | $buttonbox->hide("button$i"); | ||
| 37 | } | ||
| 38 | $buttonbox->default('more'); | ||
| 39 | Tkx::pack( $buttonbox, -expand => 'yes', -fill => 'both' ); | ||
| 40 | Tkx::MainLoop(); | ||
| 41 | |||
| 42 | # ------------------------------------------------------------------------------ | ||
| 43 | |||
| 44 | sub more { | ||
| 45 | if ( $current < $last ) { | ||
| 46 | $buttonbox->show( $current + 2 ); | ||
| 47 | $current++; | ||
| 48 | } | ||
| 49 | if ( $current == $last ) { | ||
| 50 | $buttonbox->default('less'); | ||
| 51 | } | ||
| 52 | return; | ||
| 53 | } # end of sub more | ||
| 54 | |||
| 55 | sub less { | ||
| 56 | if ( $current != 0 ) { | ||
| 57 | $buttonbox->hide("button$current"); | ||
| 58 | $current--; | ||
| 59 | } | ||
| 60 | else { | ||
| 61 | $buttonbox->default("more"); | ||
| 62 | } | ||
| 63 | return; | ||
| 64 | } # end of sub less | ||
| 65 | |||
| 66 | # ############################################################################## | ||
| 67 | # # E N D # | ||
| 68 | # ############################################################################## |