PyQt optimization