in reply to running system commands, and getting return codes/status

Please post a short runnable example of your problem.
Don't post your whole GUI code. Just create a small runnable file that demonstrates this issue.

I don't understand this: "The command gets executed before the message gets displayed in the text widget.". What?