Converting tutorial code to PyQt5