# -*- coding: utf-8 -*- from PyQt5 import uic import os ui_path = os.path.dirname(os.path.abspath(__file__)) for root, folders, files in os.walk(ui_path): if "site-packages" in root: continue if ".history" in folders: folders.remove(".history") for file in files: file = os.path.join(root, file) outfile, ext = os.path.splitext(file) if ext == ".ui": outfile = outfile + ".py" print(file, "->", outfile) with open(outfile, "w") as fh_out: uic.compileUi(file, fh_out, from_imports=True)