noshankus
asked on
Perl/tk listbox delete specific element
Hi,
I have some tk code like:
$lb_src = $f->Scrolled('Listbox', -scrollbars => "osoe")->pack(-side => "left");
foreach(@directoryInListin g) {chomp $_;
$listbox_src->insert("end" , $_);
}
Grand. Then I have a specific element that I want to delete from the listbox. Order changes everytime (so that rules out ->delete(#, #)) - unless I run yet another check to find the correct ordering. But I'm sure there must be a simpler way to do this.
I want to write something like:
$var = "foo";
$listbox_src->delete('acti ve'); or
$listbox_src->delete('$var ');
Is this not possible??
Seems like there is so much room for improvement in tk =)
Thanks for your help.
Best regards,
I have some tk code like:
$lb_src = $f->Scrolled('Listbox', -scrollbars => "osoe")->pack(-side => "left");
foreach(@directoryInListin
$listbox_src->insert("end"
}
Grand. Then I have a specific element that I want to delete from the listbox. Order changes everytime (so that rules out ->delete(#, #)) - unless I run yet another check to find the correct ordering. But I'm sure there must be a simpler way to do this.
I want to write something like:
$var = "foo";
$listbox_src->delete('acti
$listbox_src->delete('$var
Is this not possible??
Seems like there is so much room for improvement in tk =)
Thanks for your help.
Best regards,
An easier way to count each element into a hash is
@ohGodHash{@directoryInLis ting}=(0.. $#director yInListing };
@ohGodHash{@directoryInLis
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah nice. Close to what I was hoping for, and works well.
Thanks =)
Thanks =)
Glad it worked out.
ASKER
foreach(@directoryInListin
$lb_src->insert("end", $_);
$ohGodHash{$_} = $ohGodNumber;
$ohGodNumber++;
}
cos I can do that =) Just wondering if there is an easier way.