_window.py refactoring