import sys root tk(root title('summer grid'if len(sys argv! sumgrid(rootpack(grid(works here too elserowscols eval(sys argv[ ])eval(sys argv[ ]sumgrid(rootrowscolspack(mainloop(notice that this module' sumgrid class is careful not to either grid or pack itself in order to be attachable to containers where other widgets are being gridded or packedit leaves its own geometry management ambiguous and requires callers to pack or grid its instances it' ok for containers to pick either scheme for their own children because they effectively seal off the pack-or-grid choice but attachable component classes that aim to be reused under both geometry managers cannot manage themselves because they cannot predict their parent' policy this is fairly long example that doesn' say much else about gridding or widgets in generalso 'll leave most of it as suggested reading and just show what it does figure - shows the initial window created by this script after changing the last column and requesting summake sure the directory containing the pp examples root is on your module search path ( pythonpathfor the package import by defaultthe class makes the grid herebut we can pass in other dimensions to both the class constructor and the script' command line when you press the load buttonyou get the standard file selection dialog we met earlier on this tour (figure - the datafile grid-data txt contains seven rows and six columns of datac:\pp \gui\tour\gridtype grid -data txt loading this file' data into our gui makes the dimensions of the grid change accordingly--the class simply reruns its widget construction logic after erasing all the old entry widgets with the grid_forget method the grid_forget method unmaps gridded widgets and so effectively erases them from the display also watch for the pack_forget widget and window withdraw methods used in the after event "alarmexamples of the next section for other ways to erase and redraw gui components once the gui is erased and redrawn for the new datafigure - captures the scene after the file load and new sum have been requested by the user in the gui grids