Problem with terminal widget

Sorry I’m not going to write your code for you because it’s only a snippet, I would need the full function and would need to know exactly what you are trying to achieve.

But if you look at this thread/post:

Then you should be able to work out what you need to do.