How to hide the purple cube in 3D view using Python scripting?

With some searching in the forum you can usually find existing solutions that can help directly or indirectly with finding what you need.

For example see this post that mentions about the box in the 3D view.

Also consult the Slicer script repository for examples of common tasks that can help guide you even if it is not exactly what you desire. For example here is how to change the box color, but changing box visibility could be inferred from that example.

https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#change-box-color-in-3d-view