the Canvas “flashes” since it is created and immediately after the program finishes: this is expected and understood.
A general trick to delay the exit of a python program (for example to inspect/modify a plot) is to add something like
The default if you do “python myscript.py” is to run the script and then exit. If you want to be left with the Python interpreter after the script is done, you need to add the “-i” option, like this: “python -i myscript.py”.