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. IDE介绍之——CLion

    CLion是JetBrains公司旗下发布的一款跨平台C/C++IDE开发工具. 使用CLion上最好要会手写CMake.要先安装编译器套件(一般安装MinGW就行). 对C++标准的支持:基本上Cl ...

  2. JMeter数据库测试计划

    在系统上安装数据库服务器之后. 按着这些次序: 创建名为testdb的数据库. 创建表 - tb_user. 将记录插入到tb_user表中. 下图显示了创建的数据库及其记录. 注意:您需要将相应的J ...

  3. SSL/TLS 配置

    Quick Start 下列说明将使用变量名 $CATALINA_BASE 来表示多数相对路径所基于的基本目录.如果没有为 Tomcat 多个实例设置 CATALINA_BASE 目录,则 $CATA ...

  4. MySQL的读写分离与主从同步数据一致性

    有没有做MySQL读写分离?如何实现mysql的读写分离?MySQL主从复制原理的是啥?如何解决mysql主从同步的延时问题? 高并发这个阶段,那肯定是需要做读写分离的,啥意思?因为实际上大部分的互联 ...

  5. Java并发编程系列-(9) JDK 8/9/10中的并发

    9.1 CompletableFuture CompletableFuture是JDK 8中引入的工具类,实现了Future接口,对以往的FutureTask的功能进行了增强. 手动设置完成状态 Co ...

  6. 聊一聊 MySQL 中的事务及其实现原理

    说到数据库,那就一定会聊到事务,事务也是面试中常问的问题,我们先来一个面试场景: 面试官:"事务的四大特性是什么?" 我:"ACID,即原子性(Atomicity).隔离 ...

  7. 【题解】[NOI2019Route](70分)

    占坑 做法是拆掉所有式子,拆完式子看一下,如果A=0,发现边被分为了终点走向n的边和不走向n的边.所以边就有了新的边权,并且可以相加.然后通过网络流建模的套路建模使得满足时间的限制,然后由于有负边,所 ...

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

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

  9. 「学习笔记」 FHQ Treap

    FHQ Treap FHQ Treap (%%%发明者范浩强年年NOI金牌)是一种神奇的数据结构,也叫非旋Treap,它不像Treap zig zag搞不清楚(所以叫非旋嘛),也不像Splay完全看不 ...

  10. 看完这篇HTTP,跟面试官扯皮就没问题了

    我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟.醍醐灌顶的感觉. 最初在有 ...