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插件的更多相关文章

  1. Python写各大聊天系统的屏蔽脏话功能原理

    Python写各大聊天系统的屏蔽脏话功能原理 突然想到一个视频里面弹幕被和谐的一满屏的*号觉得很有趣,然后就想用python来试试写写看,结果还真玩出了点效果,思路是首先你得有一个脏话存放的仓库好到时 ...

  2. python写红包的原理流程包含random,lambda其中的使用和见简单介绍

    Python写红包的原理流程 首先来说说要用到的知识点,第一个要说的是扩展包random,random模块一般用来生成一个随机数 今天要用到ramdom中unifrom的方法用于生成一个指定范围的随机 ...

  3. Python写地铁的到站的原理简易版

    Python地铁的到站流程及原理(个人理解) 今天坐地铁看着站牌就莫名的想如果用Python写其工作原理 是不是很简单就小试牛刀了下大佬们勿喷纯属小弟个人理解 首先来看看地铁上显示的站牌如下: 就想这 ...

  4. 用Python写一个简单的Web框架

    一.概述 二.从demo_app开始 三.WSGI中的application 四.区分URL 五.重构 1.正则匹配URL 2.DRY 3.抽象出框架 六.参考 一.概述 在Python中,WSGI( ...

  5. 读书笔记汇总 --- 用Python写网络爬虫

    本系列记录并分享:学习利用Python写网络爬虫的过程. 书目信息 Link 书名: 用Python写网络爬虫 作者: [澳]理查德 劳森(Richard Lawson) 原版名称: web scra ...

  6. Python写UTF8文件,UE、记事本打开依然乱码的问题

    Python写UTF8文件,UE.记事本打开依然乱码的问题 Leave a reply 现象:使用codecs打开文件,写入UTF-8文本,正常无错误.用vim打开正常,但记事本.UE等打开乱码. 原 ...

  7. 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 ...

  8. python写xml文件

    为了便于后续的读取处理,这里就将信息保存在xml文件中,想到得到的文件如下: 1 <?xml version="1.0" encoding="utf-8" ...

  9. Python之美[从菜鸟到高手]--一步一步动手给Python写扩展(异常处理和引用计数)

    我们将继续一步一步动手给Python写扩展,通过上一篇我们学习了如何写扩展,本篇将介绍一些高级话题,如异常,引用计数问题等.强烈建议先看上一篇,Python之美[从菜鸟到高手]--一步一步动手给Pyt ...

随机推荐

  1. Team Foundation Server 2015使用教程【4】:默认团队权限说明

  2. Avram Joel Spolsky给计算机系学生的建议

    Avram Joel Spolsky给计算机系的学生给了如下建议:     (1)毕业前练好写作     (2)毕业前学好C语言     (3)毕业前学好微观经济学     (4)不要因为枯燥就不选修 ...

  3. IntelliJ IDEA+springboot+jdbctemplet+easyui+maven+oracle搭建简易开发框架(一)

    前言: 这两天为了巩固easyui的各个控件用法,搭建了一个简易的框架用于开发,大家可以用来参考,如果发现文章中有哪些不正确不合理的地方,也请各位不吝赐教,感激不尽.文章最下面有源码,可以用于参考.整 ...

  4. 学习linux命令,看这篇2w多字的linux命令详解

    用心分享,共同成长 没有什么比每天进步一点点更重要了 本文已收录到我的github:https://github.com/midou-tech/articles/tree/master/docs/li ...

  5. 「模拟赛 2018-11-02」T3 老大 解题报告

    老大 题目描述 因为 OB 今年拿下 4 块金牌,学校赞助扩建劳模办公室为劳模办公室群,为了体现 OI 的特色,办公室群被设计成了树形(n 个点 n − 1 条边的无向连通图),由于新建的办公室太大以 ...

  6. 在Git的PR(Pull Request)提示冲突无法merge合并的解决方案

    问题 假设有一个分支A,向master分支提交PR,然后发生无法自动解决的冲突,PR提示不能执行merge合并. 解决方案1 本地checkout检出并切换到A分支,pull拉取更新到最新代码 在本地 ...

  7. 微服务统计,分析,图表,监控一体化的HttpReports项目在.Net Core 中的使用

    简单介绍 HttpReports 是 .Net Core 下的一个Web项目, 适用于WebAPI,Ocelot网关应用,MVC项目,非常适合针对微服务应用使用,通过中间件的形式集成到您的项目中,可以 ...

  8. C++中重载、重写(覆盖)和隐藏的区别

    转载自:https://blog.csdn.net/zx3517288/article/details/48976097 基本概念: 重载:是指同一可访问区内被声明的几个具有不同参数列(参数的类型,个 ...

  9. 快速开发一个npm包(轮子)

    动机 很多人都想写一个自己的轮子,可是开始动手的时候你总会遇到以下问题 一个基本的 js 库应该如何编写 基本的前端项目都要哪些文件 又要怎么打包发布到 npm 上 你的 es6 语法如何才能让别人识 ...

  10. docker发布.net core程序的坑

    docker发布遇到的两个问题 1:Could not resolve CoreCLR path. For more details, enable tracing by setting COREHO ...