Download Text file on press of the button

I need to know, how text file generated can be downloaded directly on the press of an button.
Any reference to the method and code along with it will be a great help.

You can generate the text file by using a Report. If you want to print it with a button you can execute the report action on the button using the button_action decorator.

Hope it helps!