Limit text string in blender game

Hello everyone.

I encounter a problem to tell python to stop the text input when it arrives at the edge of the frame.
This is to enter the player’s name. If you have any tips to give me I would be delighted. I’m all new with python. Thanks in advance M.B

Nobody for help me ?