Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
892768447 committed Feb 20, 2021
0 parents commit 7377205
Show file tree
Hide file tree
Showing 142 changed files with 39,327 additions and 0 deletions.
148 changes: 148 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[co]
*$py.class

debug
release
.qmake.stash
Makefile
Makefile.Debug
Makefile.Release

Tmp
Tmp/*

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

.idea
.settings
.project
.pydevproject
*.pyc
Tmps/*
logs/*
cache/*
errors/*
dist/Launcher*
build/*
*.pydevproject
log.txt
/tmp/
/tmp/*
/Tmps
/Tmps/*
cache/*
cache/
/tmp/Material
/tmp/Material/*
*.pyc
.setting
.setting/
.setting/*
/.setting/
/.setting/*
tmp
.spec
.project
.pydevproject
.README.md.html
README.md.html
shape_predictor_68_face_landmarks.dat
74 changes: 74 additions & 0 deletions Client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Created on 2021/2/18
@author: Irony
@site: https://github.com/PyQt5
@email: [email protected]
@file: Client
@description:
"""
import cgitb
import json
import sys
from random import randint
from threading import Thread
from time import sleep

from PyQt5.QtWidgets import QApplication, QWidget

from SplashScreen import SplashScreen

UseHtml = randint(0, 10) % 2


def formatText(text, color, progress=0):
text = '<font color={0}>{1}</font>'.format(color, text) if UseHtml else text
return json.dumps({'text': text, 'progress': progress}) + '\n'


def initData():
# 模拟后台初始化其他数据
SplashScreen.sendMessage(formatText('初始化其他数据', 'red'))
sleep(2)

for i in range(1, 101):
SplashScreen.sendMessage(
formatText('加载模型中...{0}%'.format(i), 'green', i))
sleep(0.1)


class Window(QWidget):

def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
# 模拟界面初始化
sleep(2)
SplashScreen.sendMessage(formatText('UI初始化完成', 'white'))
sleep(2)

# 模拟加载其它数据
t = Thread(target=initData, daemon=True)
t.start()
t.join()

# 加载完成发送退出
SplashScreen.sendMessage(
json.dumps({'text': 'exit', 'progress': 0}) + '\n')
SplashScreen.disconnect()


if __name__ == '__main__':
cgitb.enable(format='text')

SplashScreen.connect(True)
SplashScreen.sendMessage(formatText('初始化中...', 'white'))

app = QApplication(sys.argv)

# 创建界面
w = Window()
w.show()

sys.exit(app.exec_())
44 changes: 44 additions & 0 deletions Launcher1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Created on 2021/2/20
@author: Irony
@site: https://github.com/PyQt5
@email: [email protected]
@file: Launcher1
@description:
"""

import cgitb
import os
import sys

from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QWidget

import Resource_rc
from SplashScreen import SplashScreen
from UiFiles.Ui_AdobeBottom import Ui_AdobeBottom


class AdobeBottom(QWidget, Ui_AdobeBottom):

def __init__(self):
super(AdobeBottom, self).__init__()
self.setupUi(self)


if __name__ == '__main__':
cgitb.enable(format='text')
Resource_rc.qInitResources()

executable = 'Client'
if sys.argv[0].find('.py') > -1:
# 调试时用
sys.argv.append(os.path.abspath('Client.py'))
executable = sys.executable

SplashScreen.start(
executable, ':/Resources/Splash2015Background.png',
AdobeBottom, above=True, color=QColor(43, 204, 249))
44 changes: 44 additions & 0 deletions Launcher2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Created on 2021/2/20
@author: Irony
@site: https://github.com/PyQt5
@email: [email protected]
@file: Launcher1
@description:
"""

import cgitb
import os
import sys

from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QWidget

import Resource_rc
from SplashScreen import SplashScreen
from UiFiles.Ui_AdobeCenter import Ui_AdobeCenter


class AdobeCenter(QWidget, Ui_AdobeCenter):

def __init__(self):
super(AdobeCenter, self).__init__()
self.setupUi(self)


if __name__ == '__main__':
cgitb.enable(format='text')
Resource_rc.qInitResources()

executable = 'Client'
if sys.argv[0].find('.py') > -1:
# 调试时用
sys.argv.append(os.path.abspath('Client.py'))
executable = sys.executable

SplashScreen.start(
executable, ':/Resources/Splash2013Background.png',
AdobeCenter, above=True, color=QColor(43, 204, 249))
35 changes: 35 additions & 0 deletions Launcher3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Created on 2021/2/20
@author: Irony
@site: https://github.com/PyQt5
@email: [email protected]
@file: Launcher1
@description:
"""

import cgitb
import os
import sys
from random import randint

import Resource_rc
from SplashScreen import SplashScreen


if __name__ == '__main__':
cgitb.enable(format='text')
Resource_rc.qInitResources()

executable = 'Client'
if sys.argv[0].find('.py') > -1:
# 调试时用
sys.argv.append(os.path.abspath('Client.py'))
executable = sys.executable

SplashScreen.start(
executable,
':/Resources/Splash{0}.gif'.format(randint(1, 2)),
single=True, above=True)
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# PyQtSplashScreen

原本考虑使用C++ Qt编写,但需要编译个版本比较麻烦,这里使用Python编写,并编译为独立的Launcher进程

启动界面采用独立进程(考虑相同进程繁忙时可能导致界面不更新,故分离出来)。并使用`QLocalSocket`来作为通信传递消息

ScreenShot

![Launcher1](ScreenShot/Launcher1.gif)

![Launcher2](ScreenShot/Launcher2.gif)

![Launcher3-1](ScreenShot/Launcher3-1.gif)

![Launcher3-2](ScreenShot/Launcher3-2.gif)
9 changes: 9 additions & 0 deletions Resource.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<RCC>
<qresource prefix="/">
<file>Resources/Splash2013Background.png</file>
<file>Resources/Splash2015Background.png</file>
<file>Resources/Splash2019Background.png</file>
<file>Resources/Splash1.gif</file>
<file>Resources/Splash2.gif</file>
</qresource>
</RCC>
Loading

0 comments on commit 7377205

Please sign in to comment.