PyQt 5-uiファイルをpycodeに変換

700 ワード

# coding:utf-8
#          ui     pycode
import os
import os.path

# Ui      
dir = './'

#         ui  
def listUiFile():
	list = []
	files = os.listdir(dir)
	for filename in files:
		if os.path.splitext(filename)[1] == '.ui':
			list.append(filename)
	return list

#     .ui     .py
def transPyFile(filename):
	return os.path.splitext(filename)[0] + '.py'

def runMain():
	for uifile in listUiFile():
		pyfile = transPyFile(uifile)
		cmd = 'pyuic5.exe {uifile} -o {pyfile}'.format(uifile = uifile, pyfile = pyfile) # windows         , mac  PyQt5   pyuic5.exe     pyuic  
		os.system(cmd) 

if __name__ == "__main__":
	runMain()