Why doesn't Perl / Tk wipe my table?

[cross-reference again to Mahalo's answers]

My Perl / Tk script has an initial table like a grid rendered using modules Tk::TableMatrix::Spreadsheet

. My spreadsheet is programmatically named $ss

. This initial grid is wiped off before displaying the first spreadsheet with

$ss->pack('forget');

      

script as it now adds as well $mw-> pack('forget');

, but this is optional.

My question is how do I open the second file from the File -> Open dialog box and it will destroy the first displayed file, just like the first file destroys the initial grid? Currently, the second file is displayed as a full new frame below the still displayed first table.

Thanks for the help in advance.

0


source to share


1 answer


pack ('forget') simply removes the widget from the view. It does not delete it and does nothing with the data displayed in it. If you fail to destroy the widget, you will, in fact, have a large memory leak as you create more and more spreadsheet widgets.



The fastest 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 delete all existing data before inserting data for the new file.

+1


source







All Articles