Refactor MainFrame.py