@Rameshwar

@J-Hilk has given you the necessary code to start from. That's why people type in answers to questions. First try that and verify it works.

Then change it so that it writes on your mainwindow or whatever you want instead.

Only after that, write back if you can't get what you want working.