-
-
Save dlon/81ca304616ee4b03c58a11581a21d048 to your computer and use it in GitHub Desktop.
This file contains hidden or 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. | |
# If you need to modify the python location or pyuic5/pyrcc5 path, just change the 2 variables below | |
$pythonPath = "C:\Python36\" | |
$pyqtScripts = Join-Path $pythonPath "\Scripts\" | |
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 "from . 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 = "$($pyqtScripts)pyuic5 --from-imports ""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..." | |
Invoke-Expression "$($pyqtScripts)pyrcc5 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