Without seeing it all I can only be general -
Firstly, move the GridPanel creation to the init method of your form, and assign it to self.gp
so you can reference it everywhere.
Then you can add it by doing self.add_component(self.gp)
and in your change event, clear the grid panel by self.gp.clear()
But - maybe you don’t want to do this in the change event of a text box. I’m not 100% sure when that event fires, but it could be on keypresses (I’ve not checked the docs). If so, it may fire when you’re half way through entering a multidigit value such as 10.
Probably better to either process the value on the enter_pressed event or have a “go” button next to the text box.