forked from PyQt5/PyQt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
108 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
# 字体测试 | ||
# QFont | ||
|
||
### [Python3.4.4 or Python3.5][PyQt5] | ||
## 1、加载自定义字体 | ||
[运行 AwesomeFont.py](AwesomeFont.py) | ||
|
||
### 其中Roboto字体通过TTF编辑器修改了family,方便QFont加载 | ||
通过`QFontDatabase.addApplicationFont`加载字体文件 | ||
|
||
# 截图 | ||
 | ||
 | ||
 |
Binary file not shown.
File renamed without changes
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# QScrollBar | ||
|
||
## 1、滚动条样式美化 | ||
[运行 StyleScrollBar.py](StyleScrollBar.py) | ||
|
||
使用QSS和图片对滚动条进行美化(horizontal 横向、vertical 纵向) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# | ||
# QSerialPort | ||
|
||
## 1、串口调试小助手 | ||
[运行 SerialDebugAssistant.py](SerialDebugAssistant.py) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
# QThread | ||
|
||
PyQt多线程的简单使用例子 | ||
|
||
## 1、继承QThread | ||
[运行 InheritQThread.py](InheritQThread.py) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,9 @@ | |
''' | ||
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: [email protected]" | ||
|
@@ -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/")) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,12 @@ | |
@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: [email protected]" | ||
|
@@ -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 @@ def onLoadFinished(self): | |
|
||
|
||
if __name__ == "__main__": | ||
sys.excepthook = cgitb.enable(1, None, 5, '') | ||
app = QApplication(sys.argv) | ||
w = WebView() | ||
w.show() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters