forked from shunfu/python-beat-detector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_ui2py.pyw
39 lines (32 loc) · 908 Bytes
/
_ui2py.pyw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# IMPORTANT: USE FILE NAMING "ui_about.ui"
# USE HIGHESET LEVEL OBJECT NAMING "ui_about" (IDENTICAL)
import glob
import os
out="""
import sys
from PyQt4 import QtCore, QtGui
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
### SET-UP WINDOWS
"""
showit=""
for pyc in glob.glob("*.pyc"):
os.system("del %s"%pyc)
for ui in glob.glob("*.ui"):
os.system ("pyuic4 -x %s -o %s"%(ui,ui.replace(".ui",".py")))
out="import %s\n"%(ui.split(".")[0])+out
uiname=ui.split("_")[1].split(".")[0]
out+="""
# WINDOW ~
win_~ = ui_~.QtGui.QMainWindow()
ui~ = ui_~.Ui_win_~()
ui~.setupUi(win_~)\n""".replace("~",uiname)
showit+=" win_~.show()\n".replace("~",uiname)
out+="\n ### DISPLAY WINDOWS\n"+showit
out+="""
#WAIT UNTIL QT RETURNS EXIT CODE
sys.exit(app.exec_())"""
f=open("ui.py",'w')
f.write(out)
f.close()
print "DONE"