« lib/App/SeismicUnixGui/misc/algebra_by.pm
↑ Summary
lib/App/SeismicUnixGui/misc/get_pod_run_flows.pm »
| 1 | package App::SeismicUnixGui::misc::check_buttons; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | our $VERSION = '0.0.1'; | ||
| 5 | use Tk; | ||
| 6 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 7 | my $get = L_SU_global_constants->new(); | ||
| 8 | my $var = $get->var(); | ||
| 9 | my $on = $var->{_on}; | ||
| 10 | my $off = $var->{_off}; | ||
| 11 | |||
| 12 | =head1 DOCUMENTATION | ||
| 13 | |||
| 14 | =head2 SYNOPSIS | ||
| 15 | |||
| 16 | PERL PROGRAM NAME: check_buttons.pm | ||
| 17 | AUTHOR: Juan Lorenzo | ||
| 18 | DATE: June 23 2017 | ||
| 19 | |||
| 20 | DESCRIPTION: | ||
| 21 | Create | ||
| 22 | many empty values | ||
| 23 | and empty value-entry spaces | ||
| 24 | |||
| 25 | USED FOR: | ||
| 26 | |||
| 27 | BASED ON: | ||
| 28 | |||
| 29 | NEEDS: | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | =head2 private hash references | ||
| 34 | |||
| 35 | =cut | ||
| 36 | |||
| 37 | my $check_buttons = { | ||
| 38 | |||
| 39 | _first_idx => '', | ||
| 40 | _index => '', | ||
| 41 | _length => '', | ||
| 42 | _frame_href => '', | ||
| 43 | _buttons_w_aref => '', | ||
| 44 | |||
| 45 | }; | ||
| 46 | |||
| 47 | =head2 sub make | ||
| 48 | |||
| 49 | make generic switches | ||
| 50 | print("check_buttons, make, frame widget hash: $$frame_aref\n"); | ||
| 51 | |||
| 52 | =cut | ||
| 53 | |||
| 54 | sub make { | ||
| 55 | |||
| 56 | my ( $self, $switch_aref ) = @_; | ||
| 57 | my @button_w = (); | ||
| 58 | my ( $first, $last, $frame_aref ); | ||
| 59 | my @variable; | ||
| 60 | |||
| 61 | $first = $check_buttons->{_first_idx}; | ||
| 62 | $last = $check_buttons->{_length}; | ||
| 63 | $frame_aref = $check_buttons->{_frame_href}; | ||
| 64 | @variable = @$switch_aref; | ||
| 65 | |||
| 66 | for ( my $i = $first ; $i < $last ; $i++ ) { | ||
| 67 | |||
| 68 | # print("check_buttons,make, variable is $variable[$i]\n"); | ||
| 69 | $button_w[$i] = $$frame_aref->Checkbutton( | ||
| 70 | -onvalue => $on, | ||
| 71 | -offvalue => $off, | ||
| 72 | -command => [ \&private_test, $i, \$variable[$i] ], | ||
| 73 | -variable => \$variable[$i], | ||
| 74 | -borderwidth => $var->{_no_borderwidth}, | ||
| 75 | -text => '', | ||
| 76 | -selectcolor => 'green', | ||
| 77 | -activebackground => 'red', | ||
| 78 | -background => 'red', | ||
| 79 | -relief => 'flat', | ||
| 80 | ); | ||
| 81 | } | ||
| 82 | $check_buttons->{_buttons_w_aref} = \@button_w; | ||
| 83 | } | ||
| 84 | |||
| 85 | # -command => [\&private_error_check_labelsNparams], | ||
| 86 | sub private_error_check_labelsNparams { | ||
| 87 | |||
| 88 | # print("check_buttons,private_error_check_labelsNparams, check button changed\n") | ||
| 89 | |||
| 90 | } | ||
| 91 | |||
| 92 | =head2 | ||
| 93 | TODO | ||
| 94 | =cut | ||
| 95 | |||
| 96 | sub private_test { | ||
| 97 | my ( $check_button_index, $on_or_off_ref ) = @_; | ||
| 98 | |||
| 99 | # print("check_buttons,test selected a checkbutton\n"); | ||
| 100 | # print("the current value of the button is $$on_or_off_ref -- weird\n"); | ||
| 101 | # print("the current checkbutton index = $check_button_index\n"); | ||
| 102 | return (); | ||
| 103 | } | ||
| 104 | |||
| 105 | =head2 sub set_index | ||
| 106 | |||
| 107 | which parameter is chosen for a program | ||
| 108 | |||
| 109 | =cut | ||
| 110 | |||
| 111 | sub set_index { | ||
| 112 | |||
| 113 | my ( $self, $index ) = @_; | ||
| 114 | $check_buttons->{_index} = $index; | ||
| 115 | |||
| 116 | # print("check_buttons,set_index:$check_buttons->{_index} \n"); | ||
| 117 | |||
| 118 | return (); | ||
| 119 | |||
| 120 | } | ||
| 121 | |||
| 122 | sub set_switch { | ||
| 123 | |||
| 124 | my ( $self, $on_off_aref ) = @_; | ||
| 125 | my $variable; | ||
| 126 | my @button_w = @{ $check_buttons->{_buttons_w_aref} }; | ||
| 127 | |||
| 128 | my $index = $check_buttons->{_index}; | ||
| 129 | |||
| 130 | #for (my $i = $first; $i<$last; $i++) { | ||
| 131 | $variable = @$on_off_aref[$index]; | ||
| 132 | |||
| 133 | # print("check_buttons,switches_on_off,variable $variable\n"); | ||
| 134 | $button_w[$index]->configure( -variable => \$variable, ); | ||
| 135 | |||
| 136 | #} | ||
| 137 | } | ||
| 138 | |||
| 139 | =head2 get_aref | ||
| 140 | in future | ||
| 141 | use the get_w_aref version instead | ||
| 142 | =cut | ||
| 143 | |||
| 144 | sub get_aref { | ||
| 145 | |||
| 146 | my ($self) = @_; | ||
| 147 | |||
| 148 | return ( $check_buttons->{_buttons_w_aref} ); | ||
| 149 | |||
| 150 | } | ||
| 151 | |||
| 152 | =head2 get_w_aref | ||
| 153 | |||
| 154 | =cut | ||
| 155 | |||
| 156 | sub get_w_aref { | ||
| 157 | |||
| 158 | my ($self) = @_; | ||
| 159 | |||
| 160 | return ( $check_buttons->{_buttons_w_aref} ); | ||
| 161 | |||
| 162 | } | ||
| 163 | |||
| 164 | =head2 sub specs | ||
| 165 | |||
| 166 | dimensions of the array | ||
| 167 | |||
| 168 | =cut | ||
| 169 | |||
| 170 | sub specs { | ||
| 171 | |||
| 172 | my ( $self, $specs_href ) = @_; | ||
| 173 | |||
| 174 | $check_buttons->{_first_idx} = $specs_href->{_first_entry_idx}; | ||
| 175 | $check_buttons->{_length} = $specs_href->{_length}; | ||
| 176 | |||
| 177 | } | ||
| 178 | |||
| 179 | =head2 sub frame | ||
| 180 | |||
| 181 | reference of holding widget frame for values | ||
| 182 | |||
| 183 | =cut | ||
| 184 | |||
| 185 | sub frame { | ||
| 186 | my ( $self, $frame_href ) = @_; | ||
| 187 | $check_buttons->{_frame_href} = $frame_href; | ||
| 188 | |||
| 189 | } | ||
| 190 | |||
| 191 | 1; |