[wingide-users] PyQt, pyuic4, and WingIDE

Mitchell Model dev at software-concepts.org
Tue Jun 5 21:08:45 MDT 2012

A further convenience is that you can set up a script to run pyuic4 (and pyrcc4 for icons) and make that the build command in the project's debug dialog box. The script can check for files changed since the last pyuic4 compilation and only change those. Here's a csh script I wrote a couple of years ago for a PyQt project I was doing then. (Watch out for spurious line breaks.)
I forget which tool shows the output to this, but it's someplace fairly obvious -- perhaps the
OS Commands tool. (In fact, you can make an OS Tool command that runs a script like this and run it manually as desired.)
# WingIDE build script to automatically update changed ui files
# Modify as appropriate and make the build command for your Wing project
# Mitchell L Model, dev at software-concepts.org, November 2010
# If using Python 2 remove the -py3 near the end of the script
set top = /path/to/where/the/directories/containing/your/ui/files/are

set PYBIN = /opt/local/Library/Frameworks/Python.framework/Versions/Current/bin
foreach dir (ui ui/dialog)
   cd $cdtop/$dir
   echo Updating UI files in $PWD
   foreach filnam(*.ui)
	set module_name = $filnam:r
	if (! -e ${module_name}_ui.py || -M $module_name.ui > -M ${module_name}_ui.py) then
	    /usr/local/bin/pyuic4 -x -o ${module_name}_ui.tmp1 ${module_name}.ui
	    /usr/bin/sed -e 's/import icons_rc/from icons_rc import */g' ${module_name}_ui.tmp1 >! ${module_name}_ui.tmp2
	    /usr/bin/sed -e 's/from \([a-z].*[[:>:]]\)/from .\1/g' ${module_name}_ui.tmp2 >! ${module_name}_ui.py
	    rm -f ${module_name}_ui.tmp1 ${module_name}_ui.tmp2
	    echo '    ' ${module_name}_ui.py updated `date +'%H:%M'`

cd $cdtop

if (-M Resources/icons.qrc > -M icons_rc.py) then
	${PYBIN}/pyrcc4 -py3 -o icons_rc.py Resources/icons.qrc
  echo icons_rc.py updated `date +'%H:%M'`

exit 0

More information about the wingide-users mailing list