Skip to content

Commit

Permalink
support PySide2
Browse files Browse the repository at this point in the history
  • Loading branch information
892768447 committed Jul 13, 2021
1 parent e397db8 commit 48ef9a5
Show file tree
Hide file tree
Showing 220 changed files with 2,460 additions and 2,545 deletions.
16 changes: 9 additions & 7 deletions Demo/AutoRestart.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
"""
Created on 2017年3月31日
@author: Irony."[讽刺]
@site: https://pyqt5.com , https://github.com/892768447
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: AutoRestart
@description:
'''
"""

from optparse import OptionParser
import os
import sys
from optparse import OptionParser

from PyQt5.QtWidgets import QApplication, QPushButton, QWidget, QHBoxLayout

try:
from PyQt5.QtWidgets import QApplication, QPushButton, QWidget, QHBoxLayout
except ImportError:
from PySide2.QtWidgets import QApplication, QPushButton, QWidget, QHBoxLayout

canRestart = True

Expand Down
37 changes: 19 additions & 18 deletions Demo/BubbleTips.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
"""
Created on 2018年1月27日
@author: Irony."[讽刺]
@site: https://pyqt5.com , https://github.com/892768447
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: BubbleTips
@description:
'''
"""
import sys

from PyQt5.QtCore import QRectF, Qt, QPropertyAnimation, pyqtProperty, \
QPoint, QParallelAnimationGroup, QEasingCurve
from PyQt5.QtGui import QPainter, QPainterPath, QColor, QPen
from PyQt5.QtWidgets import QLabel, QWidget, QVBoxLayout, QApplication,\
QLineEdit, QPushButton


__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
try:
from PyQt5.QtCore import QRectF, Qt, QPropertyAnimation, pyqtProperty, \
QPoint, QParallelAnimationGroup, QEasingCurve
from PyQt5.QtGui import QPainter, QPainterPath, QColor, QPen
from PyQt5.QtWidgets import QLabel, QWidget, QVBoxLayout, QApplication, \
QLineEdit, QPushButton
except ImportError:
from PySide2.QtCore import QRectF, Qt, QPropertyAnimation, Property as pyqtProperty, \
QPoint, QParallelAnimationGroup, QEasingCurve
from PySide2.QtGui import QPainter, QPainterPath, QColor, QPen
from PySide2.QtWidgets import QLabel, QWidget, QVBoxLayout, QApplication, \
QLineEdit, QPushButton


class BubbleLabel(QWidget):

BackgroundColor = QColor(195, 195, 195)
BorderColor = QColor(150, 150, 150)

Expand Down Expand Up @@ -133,10 +134,10 @@ def setWindowOpacity(self, opacity):
opacity = pyqtProperty(float, windowOpacity, setWindowOpacity)


class TestWidget(QWidget):
class Window(QWidget):

def __init__(self, *args, **kwargs):
super(TestWidget, self).__init__(*args, **kwargs)
super(Window, self).__init__(*args, **kwargs)
layout = QVBoxLayout(self)
self.msgEdit = QLineEdit(self, returnPressed=self.onMsgShow)
self.msgButton = QPushButton("显示内容", self, clicked=self.onMsgShow)
Expand All @@ -158,6 +159,6 @@ def onMsgShow(self):

if __name__ == "__main__":
app = QApplication(sys.argv)
w = TestWidget()
w = Window()
w.show()
sys.exit(app.exec_())
19 changes: 9 additions & 10 deletions Demo/CallVirtualKeyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
"""
Created on 2019年5月22日
@author: Irony
@site: https://pyqt5.com https://github.com/892768447
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: Demo.CallVirtualKeyboard
@description: 调用系统虚拟键盘
"""
import glob

from PyQt5.QtCore import QProcess, QSysInfo
from PyQt5.QtWidgets import QWidget, QTextEdit, QVBoxLayout, QPushButton


__Author__ = 'Irony'
__Copyright__ = 'Copyright (c) 2019 Irony'
__Version__ = 1.0
try:
from PyQt5.QtCore import QProcess, QSysInfo
from PyQt5.QtWidgets import QApplication, QWidget, QTextEdit, QVBoxLayout, QPushButton
except ImportError:
from PySide2.QtCore import QProcess, QSysInfo
from PySide2.QtWidgets import QApplication, QWidget, QTextEdit, QVBoxLayout, QPushButton


class Window(QWidget):
Expand Down Expand Up @@ -50,7 +49,7 @@ def _onOpenKeyboard(self):
self.resultEdit.append('start osk error: %s' % e)
elif kernelType == 'darwin':
pass
# elif kernelType=='linux':
# elif kernelType=='linux':
else:
ret = QProcess.startDetached('florence')
self.resultEdit.append('start florence: %s' % ret)
Expand All @@ -62,7 +61,7 @@ def _onOpenKeyboard(self):

if __name__ == '__main__':
import sys
from PyQt5.QtWidgets import QApplication

app = QApplication(sys.argv)
w = Window()
w.show()
Expand Down
36 changes: 20 additions & 16 deletions Demo/CircleLine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
Created on 2019年3月19日
@author: Irony
@site: https://pyqt5.com https://github.com/892768447
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: CircleLine
@description:
Expand All @@ -14,13 +14,14 @@
from random import random, randint
from time import time

from PyQt5.QtCore import QTimer, Qt
from PyQt5.QtGui import QColor, QPainter, QPainterPath, QPen
from PyQt5.QtWidgets import QWidget


__Author__ = 'Irony'
__Copyright__ = 'Copyright (c) 2019'
try:
from PyQt5.QtCore import QTimer, Qt
from PyQt5.QtGui import QColor, QPainter, QPainterPath, QPen
from PyQt5.QtWidgets import QWidget, QApplication
except ImportError:
from PySide2.QtCore import QTimer, Qt
from PySide2.QtGui import QColor, QPainter, QPainterPath, QPen
from PySide2.QtWidgets import QWidget, QApplication

# 最小和最大半径、半径阈值和填充圆的百分比
radMin = 10
Expand Down Expand Up @@ -60,18 +61,21 @@
circleExpSp = 0.00004
circlePulse = False


# 生成随机整数 a<=x<=b


def randint(a, b):
return floor(random() * (b - a + 1) + a)


# 生成随机小数


def randRange(a, b):
return random() * (b - a) + a


# 生成接近a的随机小数


Expand All @@ -88,7 +92,7 @@ def __init__(self, background, width, height):
self.radius = hyperRange(radMin, radMax)
self.filled = (False if randint(
0, 100) > concentricCircle else 'full') if self.radius < radThreshold else (
False if randint(0, 100) > concentricCircle else 'concentric')
False if randint(0, 100) > concentricCircle else 'concentric')
self.color = colors[randint(0, len(colors) - 1)]
self.borderColor = colors[randint(0, len(colors) - 1)]
self.opacity = 0.05
Expand Down Expand Up @@ -233,29 +237,29 @@ def renderPoints(self, painter, circles):
# otherwise we connect them only if the dist is < linkDist
if dist < self.linkDist:
xi = (1 if circles[i].x < circles[j].x else -
1) * abs(circles[i].radius * deltax / dist)
1) * abs(circles[i].radius * deltax / dist)
yi = (1 if circles[i].y < circles[j].y else -
1) * abs(circles[i].radius * deltay / dist)
1) * abs(circles[i].radius * deltay / dist)
xj = (-1 if circles[i].x < circles[j].x else 1) * \
abs(circles[j].radius * deltax / dist)
abs(circles[j].radius * deltax / dist)
yj = (-1 if circles[i].y < circles[j].y else 1) * \
abs(circles[j].radius * deltay / dist)
abs(circles[j].radius * deltay / dist)
path = QPainterPath()
path.moveTo(circles[i].x + xi, circles[i].y + yi)
path.lineTo(circles[j].x + xj, circles[j].y + yj)
# samecolor = circles[i].color == circles[j].color
# samecolor = circles[i].color == circles[j].color
c = QColor(circles[i].borderColor)
c.setAlphaF(min(circles[i].opacity, circles[j].opacity)
* ((self.linkDist - dist) / self.linkDist))
painter.setPen(QPen(c, (
lineBorder * backgroundMlt if circles[i].background else lineBorder) * (
(self.linkDist - dist) / self.linkDist)))
(self.linkDist - dist) / self.linkDist)))
painter.drawPath(path)


if __name__ == '__main__':
import sys
from PyQt5.QtWidgets import QApplication

app = QApplication(sys.argv)
w = CircleLineWindow()
w.resize(800, 600)
Expand Down
22 changes: 11 additions & 11 deletions Demo/CustomProperties.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
"""
Created on 2017年4月12日
@author: Irony."[讽刺]
@site: https://pyqt5.com , https://github.com/892768447
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: 自定义属性测试
@description:
'''
"""
from random import randint

from PyQt5.QtCore import pyqtProperty, pyqtSignal
from PyQt5.QtWidgets import QPushButton


__version__ = "0.0.1"
try:
from PyQt5.QtCore import pyqtProperty, pyqtSignal
from PyQt5.QtWidgets import QPushButton, QApplication
except ImportError:
from PySide2.QtCore import Property as pyqtProperty, Signal as pyqtSignal
from PySide2.QtWidgets import QPushButton, QApplication


class Window(QPushButton):

bgChanged = pyqtSignal(str, str)

def __init__(self):
Expand Down Expand Up @@ -56,7 +56,7 @@ def setTextColor(self, c):

if __name__ == "__main__":
import sys
from PyQt5.QtWidgets import QApplication

app = QApplication(sys.argv)
w = Window()
w.setStyleSheet(
Expand Down
24 changes: 13 additions & 11 deletions Demo/EmbedWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@
"""
Created on 2018年3月1日
@author: Irony
@site: https://pyqt5.com , https://github.com/892768447
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: EmbedWindow
@description: 嵌入外部窗口
"""

__Author__ = 'By: Irony\nQQ: 892768447\nEmail: 892768447@qq.com'
__Copyright__ = 'Copyright (c) 2018 Irony'
__Version__ = 1.0

import win32con
import win32gui
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QWindow
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QListWidget, \
QLabel

try:
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QWindow
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QListWidget, \
QLabel, QApplication
except ImportError:
from PySide2.QtCore import Qt
from PySide2.QtGui import QWindow
from PySide2.QtWidgets import QWidget, QVBoxLayout, QPushButton, QListWidget, \
QLabel, QApplication


class Window(QWidget):
Expand Down Expand Up @@ -113,8 +116,7 @@ def _enumWindows(self, hwnd, _):
import sys
import cgitb

cgitb.enable(format='txt')
from PyQt5.QtWidgets import QApplication
cgitb.enable(format='text')

app = QApplication(sys.argv)
w = Window()
Expand Down
30 changes: 16 additions & 14 deletions Demo/FacePoints.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
"""
Created on 2018年1月29日
@author: Irony."[讽刺]
@site: https://pyqt5.com , https://github.com/892768447
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: FacePoints
@description: 人脸特征点
'''
from bz2 import BZ2Decompressor
"""
import cgitb
import os
import sys
from bz2 import BZ2Decompressor

from PyQt5.QtCore import QTimer, QUrl, QFile, QIODevice
from PyQt5.QtGui import QImage, QPixmap
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt5.QtWidgets import QLabel, QMessageBox, QApplication
import cv2 # @UnresolvedImport
import dlib
import numpy


__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
__Copyright__ = "Copyright (c) 2018 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
try:
from PyQt5.QtCore import QTimer, QUrl, QFile, QIODevice
from PyQt5.QtGui import QImage, QPixmap
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt5.QtWidgets import QLabel, QMessageBox, QApplication
except ImportError:
from PySide2.QtCore import QTimer, QUrl, QFile, QIODevice
from PySide2.QtGui import QImage, QPixmap
from PySide2.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PySide2.QtWidgets import QLabel, QMessageBox, QApplication

DOWNSCALE = 4
URL = 'http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2'
Expand Down Expand Up @@ -163,7 +165,7 @@ def onCapture(self):


if __name__ == "__main__":
cgitb.enable(1, None, 5, '')
cgitb.enable(format='text')
app = QApplication(sys.argv)
w = OpencvWidget()
w.show()
Expand Down
Loading

0 comments on commit 48ef9a5

Please sign in to comment.