当前位置: 首页 > news >正文

建设共享经济网站的可行性浙江城乡建设信息港

建设共享经济网站的可行性,浙江城乡建设信息港,wordpress home插件,网站后台更新的内容出不来前言 由于需要使用不同的qt环境(PySide,PyQt)所以写了这个脚本,使用找到的随便一个uic命令去转换ui文件,然后将导入模块换成qtpy这个通用库(支持pyside2-6,pyqt5-6),老版本的是Qt.py(支持pysid…

前言

由于需要使用不同的qt环境(PySide,PyQt)所以写了这个脚本,使用找到的随便一个uic命令去转换ui文件,然后将导入模块换成qtpy这个通用库(支持pyside2-6,pyqt5-6),老版本的是Qt.py(支持pyside0-2~pyqt4-5)你可以自己改

使用

将内容保存为 ui2py.ps1 放置到后缀 ui 文件的同目录下
在拥有环境的powershell中运行 .\ui2py

<#
.SYNOPSIS
Convert all ui files in the same directory to py files for Python to use.DESCRIPTION
It needs to be used on terminals that have a Python environment, making sure that pyuic* or pyside*-uic is present
This script replaces the import 'from PyQt*' or 'from PySide*' in the py file with the 'from qtpy' module after compilation.EXAMPLE
PS> .\MyScript.ps1
Run directly, no parameters required.LINK
https://blog.csdn.net/weixin_42579717/article/details/137279306#>
# Check whether the uic command exists
$_commands = @("pyuic5", "pyside2-uic", "pyuic6", "pyside6-uic", "pyside-uic", "pyuic")
$command = $null
foreach ($cmd in $_commands)
{$command = Get-Command $cmd -ErrorAction SilentlyContinueif ($command){break}
}
if (-not$command)
{Write-Host "Command not found."exit 1
}
$command = $command.Name
Write-Output "Use command: $command"# Gets the folder where the current script is located
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition# Perform conversion operations for all *.ui files in the folder
Get-ChildItem -Path $scriptDirectory -Filter *.ui | ForEach-Object {$uiFile = $_.FullName$pyFile = $_.BaseName + ".py"$pyFilePath = Join-Path $scriptDirectory $pyFileWrite-Host $uiFileWrite-Host $pyFilePath# Convert '.ui' to '.py'& $command -o $pyFilePath $uiFile# Check whether the file is successfully convertedif (Test-Path $pyFilePath){# Replace import module(Get-Content $pyFilePath -Encoding UTF8) -replace "from (PyQt[456]?|PySide[26]?)", "from qtpy" | Set-Content $pyFilePath -Encoding UTF8Write-Host "Files have been converted and modified successfully: $pyFile"}else{Write-Host "convert failed: $uiFile"}
}

如果你的项目是有结构的比如下图
目录结构
需要将ui转出的py文件放置到上层的ui目录中的话,可以修改以下内容
添加父文件夹$parentDirectory = Split-Path -Parent $scriptDirectory


# Gets the folder where the current script is located
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
$parentDirectory = Split-Path -Parent $scriptDirectory# Perform conversion operations for all *.ui files in the folder
Get-ChildItem -Path $scriptDirectory -Filter *.ui | ForEach-Object {$uiFile = $_.FullName$pyFile = $_.BaseName + ".py"$pyFilePath = Join-Path $parentDirectory ("ui/" + $pyFile)

PS

  • qrc转py同理 可以看看另一篇文章 qrc2py
http://www.yayakq.cn/news/524181/

相关文章:

  • iis配网站网站建设公司薪资
  • 如何利用网站来提升企业形象网站开发浏览器的使用
  • 做外贸网站咨询系统开发需要的技术
  • 专业的广州手机网站建设泰安网站建设公司
  • zencart网站管理 1.5免费网站模板 怎么用
  • 网站开发 页面功能布局云游戏网站在线玩
  • 曲靖网站建设公司靖网站建设旅游网站 分析
  • 购物网站建设 成都成都高端网站开发
  • 专业整站优化手机淘宝网页版
  • 网站开发公司上海wordpress主题投稿
  • 营销型网站名词解释国外对旅游网站的建设
  • 网站内容通过服务器会不会被更改茂名网站开发
  • 手机网站开发html黑帽seo优化软件
  • p2p网站 开发dedecms能制作几个网站
  • 临沂网站制怎样做网站seo
  • 商城网站建站方案网站建设管理工作的意见
  • 湛江公司做网站营销推广案例
  • 网站主机是服务器吗iis6添加网站
  • 网站建设公司+长春开发一个网站要学什么软件
  • 盐城网站开发代理北京网站建设成都公司
  • 注册公司需要多久seo求职
  • 宁波网站建设接单wordpress用户文档
  • 小公司网站建设费用怎样做永久网站二维码
  • 南城网站建设公司策划网络服务的重要性?
  • 婚庆影楼型网站开发怎么样在网络上赚钱
  • 电子商务 做网站咸阳网站建设培训学校
  • 网站主题有哪些第三方开放平台有哪些
  • 网站建设首选公司网站开发岗位
  • 茂名网站建设优化seo网站开发的在线支付功能
  • 服装公司网站建设网站美工难做吗