pyside2的

import wingapi
import subprocess pyside2_uic = "pyside2-uic"
pyside2_qrc = "pyside2-rcc" def Pyside2_uic():
count_wait = 0
count_done = 0
for i in wingapi.gApplication.GetCurrentFiles():
if ".ui" in i:
count_wait += 1
p = subprocess.Popen([pyside2_uic, i, "-o", i.replace(".ui", "_ui.py"), "-x"])
p.wait()
if p.returncode == 0:
count_done += 1
else:
print(i.split("\\")[-1] + " FAILED")
print("{0} ui files need to be converted.".format(count_wait))
print("{0} SUCESSFULLY".format(count_done)) def Pyside2_rcc():
count_wait = 0
count_done = 0
for i in wingapi.gApplication.GetCurrentFiles():
if ".qrc" in i:
print(i)
count_wait += 1
p = subprocess.Popen([pyside2_qrc, i, "-o", i.replace(".qrc", "_rc.py")])
p.wait()
if p.returncode == 0:
count_done += 1
else:
print(i.split("\\")[-1] + " FAILED")
print("{0} qrc files need to be converted.".format(count_wait))
print("{0} SUCESSFULLY".format(count_done)) def Pyside2_pcq():
def readUi(uiPath):
import xml.dom.minidom as xmldom
uiDict = {}
domObj = xmldom.parse(uiPath)
elementObj = domObj.documentElement
windowName = elementObj.getElementsByTagName("widget")
uiDict["class"] = windowName[0].getAttribute("class")
uiDict["name"] = "Ui_" + windowName[0].getAttribute("name")
uiDict["connections"] = []
connections = elementObj.getElementsByTagName("connection")
for i in connections:
connection = {}
sender = i.getElementsByTagName("sender")
connection["sender"] = sender[0].firstChild.data
signal = i.getElementsByTagName("signal")
connection["signal"] = signal[0].firstChild.data
receiver = i.getElementsByTagName("receiver")
connection["receiver"] = "Ui_" + receiver[0].firstChild.data
slot = i.getElementsByTagName("slot")
connection["slot"] = slot[0].firstChild.data
uiDict["connections"].append(connection)
return uiDict def logUi(uiPath, uiDict):
from datetime import datetime
with open(uiPath.replace(".ui", ".log"), "w") as f:
content = []
content.extend(["Updated Time:" + str(datetime.now()) + "\n\n"])
content.extend(["class=" + uiDict["class"] + "\n"])
content.extend(["name =" + uiDict["name"] + "\n"])
for i in uiDict["connections"]:
content.extend(["______________________________________\n"])
content.extend(["sender :" + i["sender"] + "\n"])
content.extend(["signal :" + i["signal"] + "\n"])
content.extend(["receiver :" + i["receiver"] + "\n"])
content.extend(["slot :" + i["slot"] + "\n"])
f.write("".join(content)) def generatePy(uiPath, uiDict): def importGen():
from datetime import datetime
return("# -*- coding: utf-8 -*-\n"
"#Generated by [pyside2 pcq]\n"
"#Created By Lulu\n"
"#Updated Time:{2}\n"
"#WARNING! All changes made in this file will be lost!\n"
"from PySide2 import QtWidgets\n"
"from {0} import {1} as Parent"
"\n\n".format(uiPath.split("\\")[-1].replace(".ui", "_ui"), uiDict["name"], datetime.now())) def classGen():
return("class {0}(QtWidgets.{1},Parent):\n"
"\n"
" def __init__(self):\n"
" '''Constructor'''\n"
" super().__init__()\n"
" self.setupUi(self)\n"
" \n\n".format(uiDict["name"].replace("Ui_", "Win_"), uiDict["class"])) def slotGen():
slotContent = []
slots = []
for i in uiDict["connections"]:
slots.extend([i["slot"]])
slots = list(set(slots))
for i in slots:
slotContent.extend([
" def {0}(self):\n"
" \n"
" pass\n\n".format(i[:-2])])
return "".join(slotContent) def mainGen():
return(
'if __name__ == "__main__": \n'
' import sys\n'
' app = QtWidgets.QApplication(sys.argv)\n'
' {0} = {1}()\n'
' {0}.show()\n'
' sys.exit(app.exec_())\n'.format(uiDict["name"].replace("Ui_", "Win_").lower(), uiDict["name"].replace("Ui_", "Win_")))
with open(uiPath.replace(".ui", "_Win.py"), "w") as f:
f.write(importGen() + classGen() + slotGen() + mainGen()) for i in wingapi.gApplication.GetCurrentFiles():
if ".ui" in i:
uiDict = readUi(i)
logUi(i, uiDict)
generatePy(i, uiDict) Pyside2_uic.contexts = [
wingapi.kContextProject(),
]
Pyside2_rcc.contexts = [
wingapi.kContextProject(),
]
Pyside2_pcq.contexts = [
wingapi.kContextProject(),
]

pyqt5的

import wingapi
import subprocess pyuic5 = "pyuic5"
pyrcc5 = "pyrcc5" def PyQt5_uic():
count_wait = 0
count_done = 0
for i in wingapi.gApplication.GetCurrentFiles():
if ".ui" in i:
count_wait += 1
p = subprocess.Popen([pyuic5, i, "-o", i.replace(".ui", "_ui.py"), "-x"])
p.wait()
if p.returncode == 0:
count_done += 1
else:
print(i.split("\\")[-1] + " FAILED")
print("{0} ui files need to be converted.".format(count_wait))
print("{0} SUCESSFULLY".format(count_done)) def PyQt5_rcc():
count_wait = 0
count_done = 0
for i in wingapi.gApplication.GetCurrentFiles():
if ".qrc" in i:
print(i)
count_wait += 1
p = subprocess.Popen([pyrcc5, i, "-o", i.replace(".qrc", "_rc.py")])
p.wait()
if p.returncode == 0:
count_done += 1
else:
print(i.split("\\")[-1] + " FAILED")
print("{0} qrc files need to be converted.".format(count_wait))
print("{0} SUCESSFULLY".format(count_done)) def PyQt5_pcq():
def readUi(uiPath):
import xml.dom.minidom as xmldom
uiDict = {}
domObj = xmldom.parse(uiPath)
elementObj = domObj.documentElement
windowName = elementObj.getElementsByTagName("widget")
uiDict["class"] = windowName[0].getAttribute("class")
uiDict["name"] = "Ui_" + windowName[0].getAttribute("name")
uiDict["connections"] = []
connections = elementObj.getElementsByTagName("connection")
for i in connections:
connection = {}
sender = i.getElementsByTagName("sender")
connection["sender"] = sender[0].firstChild.data
signal = i.getElementsByTagName("signal")
connection["signal"] = signal[0].firstChild.data
receiver = i.getElementsByTagName("receiver")
connection["receiver"] = "Ui_" + receiver[0].firstChild.data
slot = i.getElementsByTagName("slot")
connection["slot"] = slot[0].firstChild.data
uiDict["connections"].append(connection)
return uiDict def logUi(uiPath, uiDict):
from datetime import datetime
with open(uiPath.replace(".ui", ".log"), "w") as f:
content = []
content.extend(["Updated Time:" + str(datetime.now()) + "\n\n"])
content.extend(["class=" + uiDict["class"] + "\n"])
content.extend(["name =" + uiDict["name"] + "\n"])
for i in uiDict["connections"]:
content.extend(["______________________________________\n"])
content.extend(["sender :" + i["sender"] + "\n"])
content.extend(["signal :" + i["signal"] + "\n"])
content.extend(["receiver :" + i["receiver"] + "\n"])
content.extend(["slot :" + i["slot"] + "\n"])
f.write("".join(content)) def generatePy(uiPath, uiDict): def importGen():
from datetime import datetime
return("# -*- coding: utf-8 -*-\n"
"#Generated by [PyQt5 pcq]\n"
"#Created By Lulu\n"
"#Updated Time:{2}\n"
"#WARNING! All changes made in this file will be lost!\n"
"from PyQt5 import QtWidgets\n"
"from {0} import {1} as Parent"
"\n\n".format(uiPath.split("\\")[-1].replace(".ui", "_ui"), uiDict["name"], datetime.now())) def classGen():
return("class {0}(QtWidgets.{1},Parent):\n"
"\n"
" def __init__(self):\n"
" '''Constructor'''\n"
" super().__init__()\n"
" self.setupUi(self)\n"
" \n\n".format(uiDict["name"].replace("Ui_", "Win_"), uiDict["class"])) def slotGen():
slotContent = []
slots = []
for i in uiDict["connections"]:
slots.extend([i["slot"]])
slots = list(set(slots))
for i in slots:
slotContent.extend([
" def {0}(self):\n"
" \n"
" pass\n\n".format(i[:-2])])
return "".join(slotContent) def mainGen():
return(
'if __name__ == "__main__": \n'
' import sys\n'
' app = QtWidgets.QApplication(sys.argv)\n'
' {0} = {1}()\n'
' {0}.show()\n'
' sys.exit(app.exec_())\n'.format(uiDict["name"].replace("Ui_", "Win_").lower(), uiDict["name"].replace("Ui_", "Win_")))
with open(uiPath.replace(".ui", "_Win.py"), "w") as f:
f.write(importGen() + classGen() + slotGen() + mainGen()) for i in wingapi.gApplication.GetCurrentFiles():
if ".ui" in i:
uiDict = readUi(i)
logUi(i, uiDict)
generatePy(i, uiDict) PyQt5_uic.contexts = [
wingapi.kContextProject(),
]
PyQt5_rcc.contexts = [
wingapi.kContextProject(),
]
PyQt5_pcq.contexts = [
wingapi.kContextProject(),
]

代码分屏插件

import wingapi

def split_horizontally():
wingapi.gApplication.ExecuteCommand("split-horizontally") def split_vertically():
wingapi.gApplication.ExecuteCommand("split-vertically") def join_all_split():
wingapi.gApplication.ExecuteCommand("unsplit") split_horizontally.contexts = [
wingapi.kContextEditor(),
]
split_vertically.contexts = [
wingapi.kContextEditor(),
]
join_all_split.contexts = [
wingapi.kContextEditor(),
]

最新文章

  1. div中设置滚动条的问题
  2. mysql的多实例安装
  3. Xamarin Android自学和实践步骤
  4. Matlab中数组元素引用——三种方法
  5. 2016huasacm暑假集训训练三 C - Til the Cows Come Home
  6. Linux高级编程--06.进程概述
  7. weblogic 12C 数据源配置出错的解决办法
  8. 批量更改int类型的timestamp字段to datetime
  9. 基于AppCan MAS系统,如何轻松实现移动应用数据服务?
  10. ServletContext和ServletConfig
  11. Js设置所有连接是触发/swt/的代码
  12. PHP使用正则表达式验证电话号码(手机和固定电话)
  13. Linux实战教学笔记25:自动化运维工具之ansible (一)
  14. scrapy爬取全部知乎用户信息
  15. 循环队列和链式队列(C++实现)
  16. 关于Struts2的通配方法、转发重定向
  17. Javascript高级编程学习笔记(3)—— JS中的数据类型(1)
  18. 011 Spark应用构成结构
  19. 《大话设计模式》c++实现 原型模式
  20. ASP.NET Core2.1 中如何使用 Cookie和Session

热门文章

  1. P1919 FFT加速高精度乘法
  2. codeforces 1194F (组合数学)
  3. slim的中间件
  4. DEVOPS技术实践_13:使用Jenkins持续传送设计-CD基础
  5. DEVOPS技术实践_10:安装部署Artifactory
  6. 使用Theia——创建扩展包
  7. 我的代码真的没有bug,稍等,先试试小黄鸭调试法
  8. SpringBoot 2.X整合Mybatis
  9. (二)unittst用例操作
  10. red note8 pro谷歌套件