I know this question has been asked a lot but i have not really found a suitable solution for my problem. I have tried to implement
python myScript.py 2> errorlog.txt > logfile.txt
which also works but I don't want to run my code again since it should be implemented inside a GUI where when running it will execute some simulations and semi heavy calculations and I want the terminal output to be written/logged when you exit the GUI.
Hope someone can help me on my way.