This is an open-source drag and drop solution for people using Qt Designer and PyQt5.
- Ease of use!!!!
- Just unzip Ui2Py.py
- Drag your .ui file onto it, and presto!
Please comment below if you have anymore questions.
import sys | |
import os | |
try: | |
droppedFile = sys.argv[1] | |
input("Press any button begin conversion.") | |
print(f"Attempting to convert file located at {droppedFile}") | |
if droppedFile.endswith(".ui"): | |
fileName = os.path.basename(droppedFile) | |
asPy = f"{fileName[:-3]}.py" | |
for file in os.listdir("."): | |
if file == asPy: | |
print(f"\nThere is already a file named {asPy}") | |
answer = input("Do you wish to overwrite it?\nY/N\n") | |
if answer.lower() == "y": | |
os.system(f"pyuic5 -o {fileName[:-3]}.py {droppedFile}") | |
print(f"\n{fileName[:-3]} has been converted...\n") | |
else: | |
print("\nIncorrect file type.\nMust be a Qt Designer .ui file.\n") | |
input("Press any button to close this window") | |
except: | |
print("No file dropped...") | |
input("Press any button to close this window.") | |
# raw code that this basically accomplishes | |
# pyuic5 -o window.py untitled.ui |