在eclipse中添加external tools来将.ui编译成.py

1. Create a pyuicrename.py under:
C:\Python27\Lib\site-packages\PyQt4\uic

首先新建一个.py文件,可自定义名字,并把它放在你认为比较合适的一个位置。

pyuicrename.py has the following content:
这里我将它命名为pyuicrename.py 内容如下:
import sys,os  
if len(sys.argv) <=1:  
    print("no input .ui file found!")  
    sys.exit()  
uifile = sys.argv[1]  
outfile = uifile.replace(".","_")+".py"
print(uifile)
print(outfile)
cmdstr = "pyuic4 "  
os.system(cmdstr + uifile + ">" + outfile)

2. Eclipse external tools configurations
第二部配置eclipse的external tools

location:
C:\Python27\python.exe
你的python的安装位置

arguments:
"C:\Python27\Lib\site-packages\PyQt4\uic\pyuicrename.py"  "${resource_loc}"
前面创建的pyuicremane.py的保存位置


剩下的步骤都一样啦
Change to the 'Build' tab and uncheck 'Build before launch'
Change to the 'Refresh' tab and check 'Refresh resources upon
completion'
Click 'Apply' then 'Run' 
 
 
 
http://blog.csdn.net/eplaylity/article/details/6415892

posted on 2012-07-13 11:40  山上明月  阅读(1457)  评论(0编辑  收藏  举报