PyQt5UI file is converted to the corresponding version of the py file

 PyQt5 UI files into the corresponding versions of the py file

. 1  # Coding. 8 = UTF- 
2  '' ' 
. 3  PyQt5 the UI version of the document into corresponding document py
 . 4  Python -m PyQt5.uic.pyuic untitled.ui -o untitled.py
 . 5  ' '' 
. 6  Import OS
 . 7  
. 8  # Related path is the path at the UI file storage 
. 9 path R & lt = ' D: \ Desktop \ the Tickets ' 
10  
. 11  # number of file records a successful conversion 
12 is COUNT = 0
 13 is  for the root, dirs, files in os.walk (path):
 14      = filename []
 15      for File in Files:
 16         if file.endswith('.py'):
17             filename2 = file.split('.')[0]
18             filename.append(filename2)
19   
20     for file in files:
21         if file.endswith('.ui'):
22             filename1 = file.split('.')[0]
23             filename5 = filename1 + "_qt5"
24             try:
25                 iffilename.count (filename5) == 0:
 26 is                      the os.system ( ' Python -m PyQt5.uic.pyuic -o% s.py% s.ui -d ' % (path + ' \\ ' + filename5, path + ' \\ ' + filename1))
 27                      COUNT =. 1 +
 28              the except Exception AS E:
 29                  Print ( " file conversion error, check whether an installation instruction corresponding to the correct PyQt " )
 30                  The raise E
 31 is  iF COUNT == 0:
 32      Print ( " no need to convert the file UI ")
 33 is  the else :
 34 is      Print ( ' conversion is complete, please check this common conversion! ' + STR (COUNT) + ' files ' )

 

Guess you like

Origin www.cnblogs.com/xenli/p/12468780.html