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

天津大寺网站建设打开网页

天津大寺网站建设,打开网页,wordpress app下载失败,企业做网站要注意哪些前言 由于需要使用不同的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/510359/

相关文章:

  • 太原建站网页建设街道网站建设
  • 物流企业网站建设策划书6石家庄新闻头条
  • 建设网站怎么输入分子式如何做网站网页免费
  • 蓟县网站建设网页界面设计中表单的组成部分有哪些提示信息
  • 东莞做网站的公司做外贸需要网站
  • 利用ps做兼职的网站天空台108网站找手工活带回家做
  • 如何网站网站做代理成都淮洲新城建设投资有限公司网站
  • 专业网站定制报价什么是网络营销服务?网络营销服务有哪些特点?
  • 知名网站建设制作怎样在微信上开发小程序
  • 房屋设计网站有哪些建行app官方下载
  • 电商网站建设模板网站错位
  • 网站需要怎么做的wordpress apache
  • 网站建设与实践佛山智能网站建设地址设计
  • 春播网站是谁做的wordpress文章形式图标
  • 收钱码合并的网站怎么做济南做网站比较好的公司有哪些
  • 高唐网站制作网络科技网站排名
  • 定制网站开发都提供那些东西灵璧有做公司网站的吗
  • 百度指数不高的网站怎么优化杭州做网站的公司排行
  • 免费搭建业务网站微信小程序开发平台官网登录
  • 网站页面排名优化网站设计规划报告
  • 网站支付宝接口代码荆州市住房和城乡建设厅官方网站
  • 如何选择番禺网站建设安陆网站设计
  • 网站500拱墅区哪里有网站建设
  • 中山站群网站建设购物网站开发需求分析
  • 厦门外贸建站学做网站零基础
  • 做网站的关键词怎么判断好不好邯郸个人做网站
  • 做网站需要多少钱一年视频网站建设公司
  • 建设网站的申请整站seo排名外包
  • 佛山做外贸网站代理商网站模板如何使用
  • 外网网站建设网站怎么做筛选