Thanks for the feed back.
Ive tried the following (as posted above)...
-value=>"@$names[0]" ($names[0] = ID for that file)
When toggling, each row will stay independent, but selecting one button will also select the other, both working together and not toggling back and forth, per row.
-value=>"one"
-value=>"two"
Toggling "Install" will select all 'install' buttons for all rows, toggling "update" will de-select the "install" rows and select all 'update' rows (being 'one' and 'two' are now constants ??).
-value=>"both_@$names[0]"
-value=>"install_@$names[0]"
($names[0] = ID for that file)
Makes all buttons independent, no matter what row is selected, the buttons will toggle to that single button.
In the while-loop, i have my $FileFrame = $extFileFrame -> Frame(); Doesnt that create a new "instance" of a frame which will be placed in the "parent" container/frame '$extFileFrame' ?
If so, by placing the two radio buttons (install and update) with $rdb = $FileFrame -> Radiobutton() they are being placed in there own container, and since each container is a new row, rows should not effect each other ???
Only reason im tring to go with this route now, is because i cant get it working ;) and being new to perl i would like to learn what im doing wrong.
An alternative which would fit my needs is just create a label with the 'type' flag in it so i can visualy see if the file is for Install or for Update and then place two "normal" cmd_Buttons next to the row, it does not have to be nice and pritty, but i would like to know what im doing wrong with the code above.
_
| [reply] [d/l] [select] |
Radiobuttons that have the same -value and -variable are effectively the same button, even if there are dozens of instances.
Putting Radiobuttons in different Frames does not group them; they are grouped by sharing the same -variable and distinguished within the group by different -values.
The -variable for the Radiobutton should be a reference to a scalar, e.g. \$something, \$hash{key}, \$array[6], etc. When the Radiobutton is selected - by the user or by calling $rdb->select - the -variable assigned to it is set to its -value. The reverse is also true: if the code sets the $something to a value matching a Radiobutton's -value, that Radiobutton becomes selected.
use strict;
use warnings;
use Tk;
use Tk::Radiobutton;
my $mw = Tk::MainWindow->new;
my $rb_value; # undef, no Radiobutton selected
$mw->Radiobutton(-text=>'first',-value=>'one',-variable=>\$rb_value)->
+pack(-anchor=>'w');
$mw->Radiobutton(-text=>'second',-value=>'one',-variable=>\$rb_value)-
+>pack(-anchor=>'w');
$mw->Radiobutton(-text=>'third',-value=>'three',-variable=>\$rb_value)
+->pack(-anchor=>'w');
$mw->Label(-text=>'------------------------')->pack;
my $other_value = '0000ff'; # preset blue
$mw->Radiobutton(-text=>'RED',-value=>'ff0000',-variable=>\$other_valu
+e)->pack(-anchor=>'w');
$mw->Radiobutton(-text=>'GREEN',-value=>'00ff00',-variable=>\$other_va
+lue)->pack(-anchor=>'w');
$mw->Radiobutton(-text=>'BLUE',-value=>'0000ff',-variable=>\$other_val
+ue)->pack(-anchor=>'w');
MainLoop;
print 'rb:',$rb_value,$/;
print 'other:',$other_value,$/;
| [reply] [d/l] [select] |
Thanks so much Keszler, you've been a great help and also to you, stefbv, for posting the example code (added to my own code bank for future posting for others).
With the code im posting in this post, everything is working correctly and im pretty sure i understand whats going on :)
By doing the following (@$names[0] = unique file ID)...
-value=>"both_@$names[0]", -variable=>"both_@$names[0]"
-value=>"install_@$names[0]", -variable=>"both_@$names[0]"
The 'variable' is grouping the two buttons for each row because it is using the files unique ID along with the same prefix.
Since the 'value' is also using the files unique ID along with the same prefix(s) "defined/available" in the 'variable', it will attach itself to the correct r-buttons and toggle correctly.
Am i understanding that correctly ?
Here's the 'sub', revised and cleaned up a little if any one is interested.
sub setExensionFilesChk{
my $extensionNameIndex = $_[0] || return ;
$extensionNameIndex = ($extensionNameIndex -1);
my $extNameIs = "$extensionNames[$extensionNameIndex][0]";
$extFileFrame->destroy if $extFileFrame;
$extFileFrame = $fileListPane -> Frame();
$extFileFrame->configure( -width=>575, -height=>400 );
$extFileFrame -> grid(-row=>1,-column=>1,-columnspan=>4,-sticky=>"
+nw");
my $rowIndex = 1; # start with 1 so that 'row' 0 is empty and resu
+rved for the "total count label"
my ($rdb1,$rdb2,$but,$lab);
my @tmpFiles = getExtensionsFiles("$extNameIs");
for my $names ( @tmpFiles ) {
$rowIndex++;
# add 'Delete' button...
$but = $extFileFrame -> Button(-text=>"x", -command => [ \&set
+FileType_BothOrInstall_Or_Delete, "@$names[0]", 'delete', \$extension
+NameIndex ]);
$but -> grid(-row=>$rowIndex,-column=>0, -sticky=>"w");
# Radio Buttons...
$rdb1 = $extFileFrame -> Radiobutton(-text=>"Both", -value=>"b
+oth_@$names[0]", -variable=>"both_@$names[0]", -command => [ \&setFil
+eType_BothOrInstall_Or_Delete, "@$names[0]", 'both' ]);
$rdb1 -> grid(-row=>($rowIndex),-column=>1, -sticky=>"w");
$rdb2 = $extFileFrame -> Radiobutton(-text=>"Install", -value=
+>"install_@$names[0]", -variable=>"both_@$names[0]", -command => [ \&
+setFileType_BothOrInstall_Or_Delete, "@$names[0]", 'install' ]);
$rdb2 -> grid(-row=>($rowIndex),-column=>2, -sticky=>"w");
if("@$names[1]" eq "both"){
$rdb1 -> select();
$rdb2 -> deselect();
} else {
$rdb1 -> deselect();
$rdb2 -> select();
}
# label with file path and file name...
$lab = $extFileFrame -> Label(-text=>" - @$names[2]@$names[3]"
+);
$lab -> grid(-row=>($rowIndex),-column=>3, -sticky=>"w");
}
@tmpFiles=();
my $lbl_extCount = $extFileFrame -> Label(-text=>"($rowIndex) Exte
+nsion Files:");
$lbl_extCount -> grid(-row=>1,-column=>3,-columnspan=>1, -sticky=>
+"w");
$extensionsFilesWindow->update;
}
| [reply] [d/l] [select] |