使用Python写的WingPro7 Pyside2 和 PyQt5插件
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(),
]
使用Python写的WingPro7 Pyside2 和 PyQt5插件的更多相关文章
- Python写各大聊天系统的屏蔽脏话功能原理
Python写各大聊天系统的屏蔽脏话功能原理 突然想到一个视频里面弹幕被和谐的一满屏的*号觉得很有趣,然后就想用python来试试写写看,结果还真玩出了点效果,思路是首先你得有一个脏话存放的仓库好到时 ...
- python写红包的原理流程包含random,lambda其中的使用和见简单介绍
Python写红包的原理流程 首先来说说要用到的知识点,第一个要说的是扩展包random,random模块一般用来生成一个随机数 今天要用到ramdom中unifrom的方法用于生成一个指定范围的随机 ...
- Python写地铁的到站的原理简易版
Python地铁的到站流程及原理(个人理解) 今天坐地铁看着站牌就莫名的想如果用Python写其工作原理 是不是很简单就小试牛刀了下大佬们勿喷纯属小弟个人理解 首先来看看地铁上显示的站牌如下: 就想这 ...
- 用Python写一个简单的Web框架
一.概述 二.从demo_app开始 三.WSGI中的application 四.区分URL 五.重构 1.正则匹配URL 2.DRY 3.抽象出框架 六.参考 一.概述 在Python中,WSGI( ...
- 读书笔记汇总 --- 用Python写网络爬虫
本系列记录并分享:学习利用Python写网络爬虫的过程. 书目信息 Link 书名: 用Python写网络爬虫 作者: [澳]理查德 劳森(Richard Lawson) 原版名称: web scra ...
- Python写UTF8文件,UE、记事本打开依然乱码的问题
Python写UTF8文件,UE.记事本打开依然乱码的问题 Leave a reply 现象:使用codecs打开文件,写入UTF-8文本,正常无错误.用vim打开正常,但记事本.UE等打开乱码. 原 ...
- python 写的http后台弱口令爆破工具
今天来弄一个后台破解的Python小程序,哈哈,直接上代码吧,都有注释~~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ...
- python写xml文件
为了便于后续的读取处理,这里就将信息保存在xml文件中,想到得到的文件如下: 1 <?xml version="1.0" encoding="utf-8" ...
- Python之美[从菜鸟到高手]--一步一步动手给Python写扩展(异常处理和引用计数)
我们将继续一步一步动手给Python写扩展,通过上一篇我们学习了如何写扩展,本篇将介绍一些高级话题,如异常,引用计数问题等.强烈建议先看上一篇,Python之美[从菜鸟到高手]--一步一步动手给Pyt ...
随机推荐
- Android利用Fiddler进行网络数据抓包,手机抓包工具汇总,使用mono运行filddler
Fiddler抓包工具 Fiddler抓包工具很好用的,它可以干嘛用呢,举个简单例子,当你浏览网页时,网页中有段视频非常好,但网站又不提供下载,用迅雷下载你又找不到下载地址,这个时候,Fiddler抓 ...
- 027.MFC_映射消息
映射消息MFC中的消息映射宏 DECLARE_MESSAGE_MAP BEGIN_MEASSAGE_MAP END_MESSAGE_MAP向导自动映射消息手动添加映射消息 MFC会帮我们自动映射大部分 ...
- Visio流程图表
基本流程图: 流程图类别 基本流程图的四种类型 打开基本流程图 注意页面内引用跟跨页引用 就是两个按钮的作用 就是一个按钮的作用 点击跳转 按钮设置好之后可以输入数字 方便区分跳转 下面是跨职能流程图 ...
- 利用Redis实现集群或开发环境下SnowFlake自动配置机器号
前言: SnowFlake 雪花ID 算法是推特公司推出的著名分布式ID生成算法.利用预先分配好的机器ID,工作区ID,机器时间可以生成全局唯一的随时间趋势递增的Long类型ID.长度在17-19位. ...
- 跟我一起学QT_QT标准对话框_文件对话框
标准对话框 QT的标准对话框分为以下几种 颜色对话框 文件对话框 字体对话框 输入对话框 消息对话框 进度对话框 错误信息对话框 向导对话框 文件对话框 QT中的文件对话框QFileDialog类提供 ...
- $Poj1723/AcWing123\ Soldiers$ 排序
$Poj$ $AcWing$ $Description$ $Sol$ 分别处理$x$坐标和$y$坐标.$y$坐标显然很好处理,就是排个序然后取中位数就好了.$x$没有$y$那么直接叭.所以我首先写了个 ...
- 日期格式化使用 YYYY-MM-dd 的潜在问题
昨天在v站上看到这个关于YYYY-MM-dd的使用而出现Bug的帖子(v2ex.com/t/633650)非常有意思,所以拿过来分享一下. 在任何编程语言中,对于时间.数字等数据上,都存在很多类似这种 ...
- 在nginx里面部署node.js本地服务器
我一个前端,为啥要搞服务器呢?因为公司就招了一个后端啊,后端忙不过来,就叫我这个萌新前端去搞后端的东西,我太难了. 直接进入正题吧,因为公司需求,要我在nginx服务器上面搭一个node.js服务器, ...
- 1040 有几个PAT (25 分)C语言
字符串 APPAPT 中包含了两个单词 PAT,其中第一个 PAT 是第 2 位§,第 4 位(A),第 6 位(T):第二个 PAT 是第 3 位§,第 4 位(A),第 6 位(T). 现给定字符 ...
- linux中的ldd命令简介
转载自:http://blog.csdn.net/stpeace/article/details/47069215 在linux中, 有些命令是大家通用的, 比如ls, rm, mv, cp等等, 这 ...