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. Java 学习笔记(14)—— 文件操作

    java文件操作主要封装在Java.io.File中,而文件读写一般采用的是流的方式,Java流封装在 java.io 包中.Java中流可以理解为一个有序的字符序列,从一端导向到另一端.建立了一个流 ...

  2. asp.net core web api 发布到iis失败 错误500.19

    找了很久,发现是没有装DotNetCore.2.0.0-WindowsHosting.exe的原因. 还是官方文档最给力.部署时遇到问题的朋友可以参考官方文档 https://docs.microso ...

  3. The fourth day of Crawler learning

    爬取58同城 from bs4 import BeautifulSoupimport requestsurl = "https://qd.58.com/diannao/35200617992 ...

  4. JVM系列(二):JVM的内存模型

    深入理解JVM内存模型    Java虚拟机在执行Java程序的过程中,把它所管理里的内存划分了不同的数据类型区域,作为一名开发者,我们需要了解jvm的内存分配机制以及这些不同的数据区域各自的作用. ...

  5. 软件包查询-rpm查询常用命令

    软件包查询 〇.测试环境[root@osker ~]# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core)[root@osker ...

  6. C# event 事件-2

    本次是对第一篇事件随笔的补充笔记,涉及题目依然使用上一篇的习题.上一篇地址:https://www.cnblogs.com/FavoriteMango/p/11685702.html 1.事件的定义 ...

  7. IE框架表单遍历

    // HtmlWeb.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <atlbase.h> #include ...

  8. jib-maven-plugin构建镜像

    序言 在本次期末设计当中,应为需要做部署脚本,我们采用的是dockerfile+docker-compose的部署方式,这种方式对vue项目是没有问题的,因为vue下载依赖与打包是分离开来的,即使修改 ...

  9. HDFS的HA集群原理分析

    1.简单hdfs集群中存在的问题 不能存在两个NameNode 单节点问题   单节点故障转移 2.解决单节点问题 找额外一个NameNode备份原有的数据 会出现脑裂 脑裂:一个集群中多个管理者数据 ...

  10. Linux-Cacti监控{Verson:1.2.8}

    首先需要一个LAMP平台 或LNMP平台 yum -y install httpd mariadb php mariadb-server mariadb-devel zlib freetype lib ...