-
-
Save ekmixon/f674b7e36d23bf2dfbdc24fc6e2758c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a powershell commandlet equivalent of build_ui.sh for installation on Windows | |
# Generate python files based on the designer ui files. pyrcc4 should be on the path. | |
# If you need to modify the python location or pyuic path, just change the 2 variables below | |
$pythonPath = "C:\Python27\" | |
$pyuicPath = "C:\Python27\Lib\site-packages\PyQt4\uic\pyuic.py" | |
If (!(Test-Path "designer")) { | |
Write-Host "Please run this from the project root" | |
Exit | |
} | |
# Create the directory. If it already exists, nothing will happen | |
Write-Host "Creating aqt\forms" | |
New-Item "aqt\forms" -ItemType "directory" -Force > $null | |
$init = "aqt\forms\__init__.py" | |
$temp = "aqt\forms\scratch" | |
If (Test-Path $init) { | |
Write-Host "Creating $($init)" | |
Remove-Item $init | |
} | |
If (Test-Path $temp) { | |
Write-Host "Creating $($temp)" | |
Remove-Item $temp | |
} | |
Write-Output "# This file auto-generated by build_ui.sh. Don't edit." | Out-File -Encoding "UTF8" $init | |
Write-Output "__all__ = [" | Out-File -Encoding "UTF8" -Append $init | |
Write-Host "Generating forms.." | |
Get-ChildItem "designer\*.ui" | Select BaseName | Foreach-Object { | |
$base = "$($_.BaseName)" | |
Write-Host " $($base)" | |
$py = Join-Path "aqt\forms\" ($base + ".py") | |
Write-Output " '$($base)'," | Out-File -Append -Encoding "UTF8" $init | |
Write-Output "import $($base)" | Out-File -Append -Encoding "UTF8" $temp | |
if(!(Test-Path $py) -or ((Get-Item "designer\$($base).ui").LastWriteTime -gt (Get-Item $py).LastWriteTime)) { | |
Write-Host " $($py)" | |
$pythonCommand = Join-Path $pythonPath "python.exe" | |
$command = "$($pythonCommand) $($pyuicPath) ""designer\$($base).ui"" -o $($py)" | |
Invoke-Expression $command | |
# munge the output to use gettext | |
# perl -pi.bak -e 's/(QtGui\.QApplication\.)?_?translate\(".*?", /_(/; s/, None.*/))/' $py | |
# rm $py.bak | |
} | |
} | |
Write-Output "]" | Out-File -Encoding "UTF8" -Append $init | |
Cat $temp | Out-File -Encoding "UTF8" -Append $init | |
Remove-Item $temp | |
Write-Host "Building resources..." | |
pyrcc4 designer\icons.qrc -o aqt\forms\icons_rc.py | |
Write-Host "Complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment