http://www.perlmonks.org?node_id=1001586

Phinix has asked for the wisdom of the Perl Monks concerning the following question:

Greetings meisters and monks! I've lurked around this place for many years, each time I've taken on a Perl project. Sadly I was born in America and not Europe where they actually value education, and so am expected to go tens of thousands of dollars into debt to learn anything, leaving me with the internet and late fees at the public library as my only affordable or equitable path to knowledge. Recently I have been attempting a simple application that uses a Canvas to create a background image, then places some additional sized canvases around on top of it as pseudo buttons, bound to mouse events, with image backgrounds over them so that they blend in with the main canvas background. So, first I define the main canvas and background.
my $maincanvas = $mw-> Canvas(-highlightthickness => 0); my $maincanvasi = $mw-> Photo(-file => "$img.jpg"); $maincanvas->createImage(0,0, -image => $maincanvasi, -anchor => 'nw') +;
Then I make the various sub-canvas pseudo buttons (because bind wants a widget and canvas allows a background image):
my $subcanvas1 = $maincanvas-> Canvas(-width => 64, -height => 54, -hi +ghlightthickness => 0); my $subcanvas1i = $maincanvas->Photo(-file => "$button1.jpg"); $subcanvas1-> form(-left => '420', -top => '444'); $subcanvas1-> createImage(0, 0, -image => $subcanvas1i, -anchor => 'nw +');
Further down I bind these sub-canvas buttons to mouse events:
$subcanvas1-> Tk::bind('<Button-1>' => sub { dostuff } );
Later in the script I want to be able to mass-delete and formForget all of these sub-canvas objects. However, when I attempt to do this to an array containing the names of all these psuedo button canvas objects like this:
foreach (@canvasbuttons) { $_->delete('all'); $_->formForget; }
...Perl complains at me saying:
Tk::Error: Window "<yada>" is not managed by the tixForm manager... ... <ButtonRelease-1> (command bound to event)
So, my question is, how can I mass-unbind all these sub-canvas canvas psuedo buttons and unpack them?