资源简介
选择要转换的ui文件和资源文件(qrc)所在的目录,在对应的下拉列表中按下回车键即可自动添加要转换的源文件,选择好输出目录,双击或者点击转换按钮即可完成转换。脚本用python3.6+pyqt5编写,使用时需要安装pyqt5和python3.6。
代码片段和文件信息
from PyQt5.QtWidgets import QApplication QWidget QFileDialog\
QGridLayout QLabel QTableWidget QAbstractItemView QComboBox QPushButton\
QHeaderView QSizePolicy QMessageBox QTableWidgetItem QMenu
from PyQt5.Qt import QDir QFileInfo QVariant QBrush QColor QDesktopServices\
QUrl
from PyQt5.QtCore import Qt
import os
import sys
def findFiles(path extension fileList):
currentDir = QDir(path)
prefix = path + ‘/‘
patternList = [extension]
for match in currentDir.entryList(patternList QDir.Files | QDir.NoSymlinks | QDir.NoDotAndDotDot):
item = prefix + match
fileList.add(item)
def openFile(fileName):
QDesktopServices.openUrl(QUrl.fromLocalFile(fileName))
def fileNameOfItem(item):
return item.data(Qt.UserRole + 1)
def convertUiFileToPy(uiFileName pyFileName outDir):
cmd = ‘pyuic5 -o {:s}{:s} {:s}‘.format(outDir pyFileName uiFileName)
os.system(cmd)
def convertQrcFileToPy(qrcFileName pyFileName outDir):
cmd = ‘pyrcc5 -o {:s}{:s} {:s}‘.format(outDir pyFileName qrcFileName)
os.system(cmd)
class Window(QWidget):
fileList = set()
def __init__(self):
super().__init__()
self.__initUI()
def __initUI(self):
mainLayout = QGridLayout()
self.convertButton = self.__createButton(‘全部转换‘)
self.convertButton.clicked.connect(self.__convertButtonclicked)
self.uiBrowseButton = QPushButton(‘ui...‘)
self.uiBrowseButton.clicked.connect(self.__uiBrowseButtonclicked)
self.qrcBrowseButton = QPushButton(‘qrc...‘)
self.qrcBrowseButton.clicked.connect(self.__qrcBrowseButtonclickde)
self.outBrowseButton = QPushButton(‘py...‘)
self.outBrowseButton.clicked.connect(self.__outBrowseButtonclicked)
self.uiDirCombobox = self.__createCombobox(QDir.toNativeSeparators(QDir.currentPath()))
self.uiDirCombobox.lineEdit().returnPressed.connect(self.__findUiFiles)
self.qrcDirCombobox = self.__createCombobox(QDir.toNativeSeparators(QDir.currentPath()))
self.qrcDirCombobox.lineEdit().returnPressed.connect(self.__findQrcFiles)
self.outputDirCombobox = self.__createCombobox(QDir.toNativeSeparators(QDir.currentPath()))
self.fileFoundLabel = QLabel()
self.__createFilesTable()
mainLayout.addWidget(self.__createLabel(‘ui目录:‘) 0 0)
mainLayout.addWidget(self.uiDirCombobox 0 1 1 2)
mainLayout.addWidget(self.uiBrowseButton 0 3 )
mainLayout.addWidget(self.__createLabel(‘qrc目录:‘) 1 0)
mainLayout.addWidget(self.qrcDirCombobox 1 1 1 2)
mainLayout.addWidget(self.qrcBrowseButton 1 3)
mainLayout.addWidget(self.__createLabel(‘输出目录:‘) 2 0)
mainLayout.addWidget(self.outputDirCombobox 2 1 1 2)
mainLayout.addWidget(self.outBrowseButton 2 3 1 1)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 379 2017-10-16 09:12 QtRes2Py\.project
文件 435 2017-10-16 09:12 QtRes2Py\.pydevproject
文件 9386 2017-11-08 16:23 QtRes2Py\src\main.py
目录 0 2017-10-18 16:46 QtRes2Py\.settings
目录 0 2017-11-08 16:19 QtRes2Py\src
目录 0 2017-11-08 16:19 QtRes2Py
----------- --------- ---------- ----- ----
10200 6
- 上一篇:python人脸检测源代码
- 下一篇:python数据离差标准化
相关资源
- python+pyqt5+百度AI+车牌识别.rar
- Python3.x+Pyqt5实现界面编程浏览网页
- Python-用pyqt5和parametrics实现很酷的动画
- PyQt5 Python 桌面应用程序源码.zip
- python pyqt5 计时器源代码
- pyqt5_python_Gui入门教程.docx
- 利用摄像头拍照并保存照片程序pyth
- QT5 Python GUI Programming Cookbook - 2018
- Python3.4 PyQt5 32位安装版PyQt5-5.5.1-gpl-
- PyQt5 5.3.2 gpl Py3.4 Qt5.3.1 x32.exe
- PyQt5-5.12-5.12.1_a-cp35.cp36.cp37.cp38-none-w
- Serial assistant.rar
- PyQt5快速开发与实战pdf+源码.zip
- 创建画板,手写体实时在线识别
- PyQt5_Tools-5.7.dev1-py3-none-any.whl
- PyQt5快速开发与实战.zip
- PyQt5-5.4-gpl-Py3.4-Qt5.4.0-x64
- Python + PyQt5 + MySQL模拟QQ的聊天与娱乐
- 创建画板,实时在线手写体识别
- PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32
- pyqt5实现自动获取IP软件
- python-vlc二次封装,可用于pyqt
- tesseract V2.0()
- python聊天室---pyqt5+socket+Thread聊天室
- Pyqt5 按钮事件绘制图形
-
PyQ5 Mtaplotlib Datafr
ame画一条随鼠标移 - python实时读取串口数据并自动保存至
- pyqt5做一个一个时钟demo(python3)
-
pyQt5_wavepla
yer python计算声音分贝 语 - 实现小学三年级口算题生成器
评论
共有 条评论