I want to move my code from Tcl/tk to Perl/Tk. I am trying to embed
an array of buttons in a text window.
In the TCL/TK i had something like this
for loop
{
button .b$i ---------
}
and used cget to obtain the information of which button was activated
but in perl i want to use an array of buttons, if somebody could just
provide a small snippet of code
or a procedure on how i can do it , it would be really helpful. I
tried creating an array of widgets
and accessing them using the command
print "@arry_widget[0]" but i am not getting the object reference
value (some tips here please). I might be doing it completely wrong
but i want to create an array of widgets without manually writing the
variable names (like in a for loop)
Thanks for your time,
Vinay
my @button;
for (1..10) {
push @button, $parent->Button(...)->pack(...);
}
Done that quite a lot of times.
> tried creating an array of widgets
> and accessing them using the command
> print "@arry_widget[0]" but i am not getting the object reference
ITYM "print $arry_widget[0];" (@array_widget[0] is an "array slice", not
the first element), but why do you want to *print* the widget? You can
*manipulate* it:
$button[0]->configure(...);
> value (some tips here please). I might be doing it completely wrong
> but i want to create an array of widgets without manually writing the
> variable names (like in a for loop)
Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef M�llers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html
Read the perldoc on arrays. You want $, not @.
) I might be doing it completely wrong
) but i want to create an array of widgets without manually writing the
) variable names (like in a for loop)
Use map:
my @buttons = map { ... } qw/name1 name2 name3 name4/;
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT