views:

211

answers:

1

[cross posted again to Mahalo answers]

My Perl/Tk script has an initial spreadsheet like grid displayed using the Tk::TableMatrix::Spreadsheet modules. My spreadsheet is programatically called $ss. This initial grid is wiped before the display of the first spreadsheet, with

$ss->pack('forget');

The script as it is now also adds $mw-> pack('forget');, but that's not necessary.

My question is how to open a second file from the File -> Open dialog box and it wipe out the first file displayed, just like the first file wipes out the initial grid? Right now the second file shows up as a complete new frame underneath the still displayed first spreadsheet.

Thanks for the help in advance.

+1  A: 

"pack('forget')" merely removes a widget from view. It doesn't delete it, nor does it do anything with the data displayed within it. If you fail to destroy the widget you will have, in effect, a big memory leak as you create more and more spreadsheet widgets.

The quickest solution to your problem is to destroy the old widget (using the destroy method) and recreate it with the new data. Another solution is to keep the widget but use deleteRows() to remove all the existing data before inserting the data for the new file.

Bryan Oakley