Bitte ich brauche eure Hilfe,
ich erzeuge ein GUI dynamisch aus einer xml-Datei.
dieses Gui verfühgt über 5 buttons.
wenn man auf ein button klickt erscheint ein Checkbox mit vielen auswahlmöglichkeiten.
ich möchte ein selectall_button auf das aktuelle Checkbox erzeugen das alle auswahlmöglichkeiten checkt.
das select_allbutton funktioniert gut beim ersten button aber nicht bei den anderen.
wer kann mir bitte helfen?Code:
sub mark_children($$$)
{
# Inputs
my $parent = shift; # Button pressed -> 'Platform'
my $child = shift; # Button pressed -> 'Program'
my $description = shift; # Button pressed ->'description'
my ($count, $j, $i, $k);
my (@node_names, @node_values, $max_index);
my @selected;
$j = 0;
$count = StandLib::GetCountOfNodes($parent); # Count Platforms
for($i=0; $i<$count; $i++)
{
@node_names = StandLib::GetALLNodeNames($parent,$i); # XMLfilePlatforms in NodeNames
@node_values = StandLib::GetALLNodeValues($parent,$i); # XMLfileValues in NodeValues
$max_index = @node_names; # Max_Index of NodeNames
for ($k = 0; $k<$max_index; $k++)
{
if ($node_names[$k] eq $child)
{
if ($node_values[1] eq $description)
{
$selected[$j] = 1;
}
else
{
$selected[$j] = 0;
}
$j++;
}
}
}
return @selected;
} # sub mark_children
sub do_top($)
{
my @node_values;
my $button = shift; # input
my @check_value = {};
my (@program, $f_check, @pa);
my ($j, $i);
my ($exit, $select_all);
$continue = 0;
$exit_state = $continue;
$exits = 1;
$problem = 2;
if (! Exists($tl))
{ # checkFrame
@node_values = {};
$j = 0;
$tl = $mw->Toplevel; # New Popup Window
$f_check = $tl->Frame(-relief => 'sunken', -borderwidth => '1m');#CheckFrame
@pa = mark_children('Platform', 'Program', $button); # Checkbuttons & Call mark_children()
# Platforms = Parents, Programs = Kids
for($i=0; $i<$count_program; $i++)
{
if ($pa[$i]== 1)
{ # wenn Program = 1 ( not exists)
@node_values = StandLib::GetALLNodeValues('Program',$i);
$check_value[$i]= 0; #---checkbuttons---
$program[$i] = $f_check->Checkbutton(-text => $node_values[1],
-variable => \$checked_progs[$i])
->pack(-side => 'top', -anchor => 'w', -padx => '1c');
}
print "\nchecked_progs[$i]is: $checked_progs[$i]\n";
}
#---done_Button im Checkframe---
$exit = $f_check->Button(-text => "done",
-command => sub{$tl->destroy})
->pack(-side => 'top', -padx => '0.5c');
$f_check->pack;
###################### Test
#---select_all_Button - Checkframe---
$select_all = $f_check->Button( -text => "select all",
-command => sub{&check_all(@program);})
->pack(-side => 'top', -padx => '0.5c');
$f_check->pack;
$select_all->bind =>('<ButtonPress>'=> \&check_all());
###############################################
}
else
{
$tl->deiconify; # Exit this Window
$tl->raise ; # ignore Exceptions
}
return $exit_state
}# sub do_top
sub check_all(@)
{
my (@node_names) = @_;
print"\nnode_names: @node_names\n";
my $checkbox;
for $checkbox (@node_names)
{
$checkbox->select();
}
}
Datum: 04.06.2007-11:13
