in reply to refreshing a GUI

Try a $widget->update() on your widget holding the grid on each iteration.
This will handover the controll to Tk and update the widget.