Ai
11 Star 141 Fork 68

sunshe35/PySide6-codes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tool.py 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
sunshe35 提交于 2022-10-08 22:34 +08:00 . 修复路径问题
# -*- coding: utf-8 -*-
'''
【简介】
ui转换成py的转换工具
'''
import os
import os.path
import os
os.chdir(os.path.dirname(__file__))
# UI文件所在的路径
dir = './'
# 列出目录下的所有ui文件
def listUiFile():
list = []
files = os.listdir(dir)
for filename in files:
# print( dir + os.sep + f )
# print(filename)
if os.path.splitext(filename)[1] == '.ui':
list.append(filename)
return list
# 把后缀为ui的文件改成后缀为py的文件名
def transPyFile(filename):
return os.path.splitext(filename)[0] + '.py'
# 调用系统命令把ui转换成py
def runMain():
list = listUiFile()
for uifile in list:
pyfile = transPyFile(uifile)
# pyqt6适用
# cmd = 'pyuic6 -o {pyfile} {uifile}'.format(pyfile=pyfile, uifile=uifile)
# pyside6适用
cmd = 'pyside6-uic -o {pyfile} {uifile}'.format(pyfile=pyfile, uifile=uifile)
# print(cmd)
os.system(cmd)
###### 程序的主入口
if __name__ == "__main__":
runMain()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/sunshe35/PySide6-codes.git
git@gitee.com:sunshe35/PySide6-codes.git
sunshe35
PySide6-codes
PySide6-codes
master

搜索帮助