viewer.py : Refactored painting functionality from gui.py