Hello all, looking for some guidance using Radiobuttons in a program im creating.
Heres the scoop.
I have a sql-table; id, type, file and path ('type' is used as a "flag" to determine if the file is an 'Install' file or an 'Update' file (which is where the Radio buttons come in)).
Im dynamically create a bunch of Radio-buttons with the code below (image included).
What i would like is to have rows of "install/update" buttons with a label to the right of the two RadioButtons (which ive been successful in doing), but im having a problem with toggling the buttons.
Ive tried a bunch of things, placing the r-buttons in frames, not in frames, changing the RadioButtons 'value' and 'variable'. No matter what ive tried, i can not get the buttons to toggle correctly and display correclty.
When toggling, ether
all the 'install' buttons become selected when only selecting one, or only a single buttons is selected and not toggling anything, or selecting 'install' on a row will select both buttons on that row, but never toggling each row correctly.
When the buttons are first displayed, none of them are 'selected', all buttons are 'deselected'.
All the arrays are being filled correctly, used 'print' to double check. The r-button '-command =>' works correctly and sets the correct information in the sub it calls.
Heres the code
sub setExensionFilesChk{
my $index1 = $_[0] || return ;
$index1 = ($index1 -1);
my $extNameIs = "$extensionNames[$index1][0]";
#print "* $extNameIs *\n";
@extensionFiles=();
@extensionFileBothInstall=();
my $q = $db->query("SELECT filelist_id, filelist_type, filelist_pa
+th, filelist_file FROM filelist WHERE filelist_extension = '$extNameI
+s'");
while (my $ref = $q->fetchrow_hashref() ) {
#print "$$ref{'filelist_file'}\n";
push @extensionFiles, [ $$ref{'filelist_id'}, $$ref{'filelist_
+type'}, $$ref{'filelist_path'}, $$ref{'filelist_file'} ];
push @extensionFileBothInstall, [ $$ref{'filelist_id'}, $$ref{
+'filelist_type'} ];
}
$extFileFrame->destroy if $extFileFrame;
$extFileFrame = $fileListPane -> Frame();
$extFileFrame->configure( -width=>500, -height=>400 );
$extFileFrame -> grid(-row=>1,-column=>1,-columnspan=>3,-sticky=>"
+nw");
my $names;
my $i = 0;
my $rdb;
for $names ( @extensionFiles ) {
$i++;
if("@$names[1]" eq "both"){
#print "@$names[3]\n";
my $FileFrame = $extFileFrame -> Frame();
$FileFrame -> grid(-row=>($i + 1),-column=>1,-columnspan=>
+3,-sticky=>"nw");
$rdb = $FileFrame -> Radiobutton(-text=>"Both", -value=>"@
+$names[0]", -variable=>"@$names[1]", -command => [ \&setFileBothInsta
+ll, "@$names[0]", 'both' ]);
$rdb -> select();
$rdb -> grid(-row=>(1),-column=>0, -sticky=>"w");
$rdb = $FileFrame -> Radiobutton(-text=>"Install", -value=
+>"@$names[0]", -variable=>"@$names[1]", -command => [ \&setFileBothIn
+stall, "@$names[0]", 'install' ]);
$rdb -> deselect();
$rdb -> grid(-row=>(1),-column=>1, -sticky=>"w");
my $lab = $FileFrame -> Label(-text=>" - @$names[2]@$names
+[3]");
$lab -> grid(-row=>(1),-column=>2, -sticky=>"w");
} else {
}
}
my $lbl_extName = $extFileFrame -> Label(-text=>"($i) Extension Fi
+les:");
$lbl_extName -> grid(-row=>1,-column=>0,-columnspan=>3);
$extensionsFilesWindow->update;
}
And an image to get a visual, the five r-buttons on the left are used to call the sub posted above which will retrieve the file names & paths from the sql-table and display them to the list on the right, which is where the problem is.
http://thewwwaddress.com/AddExtensonFileToSQL.jpg
Thanks for any help with this...
--------------------------
The following will explane what im doing with the program, if you care to know.
I have developed a couple of Mediawiki extensions.
Now i would like to create a general perl app to create two .tar files, one will be the Full install (with config, language and image files) the second will be be for Updates (with-out config, language and image files) along with the appropriate Install and Update SQL info.
The code above is only a small part of the program, the "input stage" for my local dbase which will hold info (SQL table names and files names & paths). There is another window in the program which i can select and scan a dir and its sub folders, collect the file names and paths, save them to my local dbase along with acouple 'if' checks on the files extensions to be able to "flag" them 'Install' or 'Both' ('both' meaning the file is used for the Install and the Update).
Theres a problem, while "inputting" these file names to my local dbase, there are some files which are not flagged correctly and thats where the sub routine above comes in. Instead of manually changing the flag in the dbase, i thought i would go about it with the code above. When one of the Radiobuttons above is toggled, it will call a 'sub' and update the 'flag' for that file (using the setFileBothInstall() routine (
not posted here) passing 'filelist_id', 'install' or 'both' depending on which radio button is toggled) in my local dbase.
So theres the story :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.