update
This commit is contained in:
parent
9feec8fe34
commit
c84d2181e8
15 changed files with 108 additions and 20 deletions
|
@ -1,4 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//Demo/AutoRestart.py=utf-8
|
||||
encoding//Demo/EmbedWindow.py=utf-8
|
||||
encoding//Demo/FacePoints.py=utf-8
|
||||
encoding//Demo/FollowWindow.py=utf-8
|
||||
|
@ -36,7 +37,9 @@ encoding//QSlider/QssQSlider.py=utf-8
|
|||
encoding//QSplitter/RewriteHandle.py=utf-8
|
||||
encoding//QThread/moveToThread.py=utf-8
|
||||
encoding//QTreeWidget/ParsingJson.py=utf-8
|
||||
encoding//QWebEngineView/GetCookie.py=utf-8
|
||||
encoding//QWebView/DreamTree.py=utf-8
|
||||
encoding//QWebView/GetCookie.py=utf-8
|
||||
encoding//QWidget/Lib/CustomPaintWidget.py=utf-8
|
||||
encoding//QWidget/Lib/CustomWidget.py=utf-8
|
||||
encoding//QWidget/WidgetStyle.py=utf-8
|
||||
|
|
|
@ -13,18 +13,48 @@ Created on 2017年3月31日
|
|||
from optparse import OptionParser
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from PyQt5.QtWidgets import QApplication, QPushButton, QWidget, QHBoxLayout
|
||||
|
||||
|
||||
canRestart = True
|
||||
|
||||
|
||||
def restart(twice):
|
||||
os.execl(sys.executable, sys.executable, *[sys.argv[0], "-t", twice])
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Window, self).__init__(*args, **kwargs)
|
||||
self.resize(400, 400)
|
||||
layout = QHBoxLayout(self)
|
||||
|
||||
self.buttonRestart = QPushButton(
|
||||
"app start...%s...twice\napp pid: %s\n点击按钮重启...\n" %
|
||||
(options.twice, os.getpid()), self)
|
||||
self.buttonRestart.clicked.connect(self.close)
|
||||
|
||||
self.buttonExit = QPushButton('退出', self, clicked=self.doExit)
|
||||
|
||||
layout.addWidget(self.buttonRestart)
|
||||
layout.addWidget(self.buttonExit)
|
||||
|
||||
def doExit(self):
|
||||
global canRestart
|
||||
canRestart = False
|
||||
self.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser(usage="usage:%prog [optinos] filepath")
|
||||
parser.add_option("-t", "--twice", type="int", dest="twice", default=1, help="运行次数")
|
||||
parser.add_option("-t", "--twice", type="int",
|
||||
dest="twice", default=1, help="运行次数")
|
||||
options, _ = parser.parse_args()
|
||||
print("app start...%s...twice\n" % options.twice)
|
||||
print("app pid: ",os.getpid())
|
||||
print("3秒后自动重启...\n")
|
||||
time.sleep(3)
|
||||
app = QApplication(sys.argv)
|
||||
w = Window()
|
||||
w.show()
|
||||
app.exec_()
|
||||
if canRestart:
|
||||
restart(str(options.twice + 1))
|
||||
|
|
0
QAxWidget/README.en.md
Normal file
0
QAxWidget/README.en.md
Normal file
0
QChart/README.en.md
Normal file
0
QChart/README.en.md
Normal file
|
@ -1,9 +1,8 @@
|
|||
# 字体测试
|
||||
# QFont
|
||||
|
||||
### [Python3.4.4 or Python3.5][PyQt5]
|
||||
## 1、加载自定义字体
|
||||
[运行 AwesomeFont.py](AwesomeFont.py)
|
||||
|
||||
### 其中Roboto字体通过TTF编辑器修改了family,方便QFont加载
|
||||
通过`QFontDatabase.addApplicationFont`加载字体文件
|
||||
|
||||
# 截图
|
||||
![截图](ScreenShot/1.png)
|
||||
![截图](ScreenShot/2.png)
|
||||
![AwesomeFont](ScreenShot/AwesomeFont.png)
|
Binary file not shown.
Before Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 127 KiB |
0
QMenu/README.en.md
Normal file
0
QMenu/README.en.md
Normal file
|
@ -1,6 +1,7 @@
|
|||
# QScrollBar
|
||||
|
||||
## 1、滚动条样式美化
|
||||
[运行 StyleScrollBar.py](StyleScrollBar.py)
|
||||
|
||||
使用QSS和图片对滚动条进行美化(horizontal 横向、vertical 纵向)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#
|
||||
# QSerialPort
|
||||
|
||||
## 1、串口调试小助手
|
||||
[运行 SerialDebugAssistant.py](SerialDebugAssistant.py)
|
||||
|
|
0
QSplitter/README.en.md
Normal file
0
QSplitter/README.en.md
Normal file
|
@ -1,7 +1,5 @@
|
|||
# QThread
|
||||
|
||||
PyQt多线程的简单使用例子
|
||||
|
||||
## 1、继承QThread
|
||||
[运行 InheritQThread.py](InheritQThread.py)
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ Created on 2017年12月10日
|
|||
'''
|
||||
import sys
|
||||
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtCore import QUrl, QByteArray
|
||||
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtWidgets import QApplication, QTextEdit
|
||||
|
||||
|
||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||
|
@ -28,14 +28,41 @@ class WebEngineView(QWebEngineView):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(WebEngineView, self).__init__(*args, **kwargs)
|
||||
self.cookieView = QTextEdit()
|
||||
self.cookieView.resize(800, 400)
|
||||
self.cookieView.move(400, 400)
|
||||
self.cookieView.setWindowTitle('Cookies')
|
||||
self.cookieView.show()
|
||||
# 绑定cookie被添加的信号槽
|
||||
QWebEngineProfile.defaultProfile().cookieStore(
|
||||
).cookieAdded.connect(self.onCookieAdd)
|
||||
self.loadFinished.connect(self.onLoadFinished)
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.cookieView.close()
|
||||
super(WebEngineView, self).closeEvent(event)
|
||||
|
||||
def bytestostr(self, data):
|
||||
if isinstance(data, str):
|
||||
return data
|
||||
if isinstance(data, QByteArray):
|
||||
data = data.data()
|
||||
if isinstance(data, bytes):
|
||||
data = data.decode(errors='ignore')
|
||||
else:
|
||||
data = str(data)
|
||||
return data
|
||||
|
||||
def onLoadFinished(self):
|
||||
print("*****AllDomainCookies:", self.getAllDomainCookies())
|
||||
print("*****AllPathCookies:", self.getAllPathCookies())
|
||||
self.cookieView.append(
|
||||
"AllDomainCookies: " + self.bytestostr(self.getAllDomainCookies()))
|
||||
self.cookieView.append('')
|
||||
self.cookieView.append(
|
||||
"AllPathCookies: " + self.bytestostr(self.getAllPathCookies()))
|
||||
self.cookieView.append('')
|
||||
|
||||
print("*****pyqt5.com cookie:", self.getDomainCookies(".pyqt5.com"))
|
||||
print("*****pyqt5.com / path cookie:",
|
||||
self.getPathCookies(".pyqt5.com/"))
|
||||
|
|
|
@ -9,11 +9,12 @@ Created on 2017年12月10日
|
|||
@file: GetCookie
|
||||
@description:
|
||||
'''
|
||||
import cgitb
|
||||
import sys
|
||||
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtCore import QUrl, QByteArray
|
||||
from PyQt5.QtWebKitWidgets import QWebView
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtWidgets import QApplication, QTextEdit
|
||||
|
||||
|
||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||
|
@ -25,13 +26,40 @@ class WebView(QWebView):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(WebView, self).__init__(*args, **kwargs)
|
||||
self.cookieView = QTextEdit()
|
||||
self.cookieView.resize(800, 400)
|
||||
self.cookieView.move(400, 400)
|
||||
self.cookieView.setWindowTitle('Cookies')
|
||||
self.cookieView.show()
|
||||
self.loadFinished.connect(self.onLoadFinished)
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.cookieView.close()
|
||||
super(WebView, self).closeEvent(event)
|
||||
|
||||
def bytestostr(self, data):
|
||||
if isinstance(data, str):
|
||||
return data
|
||||
if isinstance(data, QByteArray):
|
||||
data = data.data()
|
||||
if isinstance(data, bytes):
|
||||
data = data.decode(errors='ignore')
|
||||
else:
|
||||
data = str(data)
|
||||
return data
|
||||
|
||||
def onLoadFinished(self):
|
||||
allCookies = self.page().networkAccessManager().cookieJar().allCookies()
|
||||
print("allCookies:", allCookies)
|
||||
for cookie in allCookies:
|
||||
# if cookie.domain() == ".pyqt5.com":
|
||||
self.cookieView.append(
|
||||
"domain: " + self.bytestostr(cookie.domain()))
|
||||
self.cookieView.append("path: " + self.bytestostr(cookie.path()))
|
||||
self.cookieView.append("name: " + self.bytestostr(cookie.name()))
|
||||
self.cookieView.append(
|
||||
"value: " + self.bytestostr(cookie.value()))
|
||||
self.cookieView.append('')
|
||||
print("domain:", cookie.domain())
|
||||
print("path:", cookie.path())
|
||||
print("name:", cookie.name())
|
||||
|
@ -40,6 +68,7 @@ class WebView(QWebView):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.excepthook = cgitb.enable(1, None, 5, '')
|
||||
app = QApplication(sys.argv)
|
||||
w = WebView()
|
||||
w.show()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
## 1、梦幻树
|
||||
[运行 DreamTree.py](DreamTree.py)
|
||||
|
||||
在桌面上显示透明html效果,使用`QWebkit`加载html实现,采用窗口背景透明和穿透方式
|
||||
|
||||
![DreamTree](ScreenShot/DreamTree.png)
|
||||
|
|
Loading…
Reference in a new issue