Skip to main content

动画加载屏幕

项目描述

py加载屏幕

Python 模块 - 动画加载屏幕使用的模块:

  1. 异步
  2. 数学
  3. 时间.睡眠
  4. PyQt5.QtCore、PyQt5.QtWidgets、PyQt5.QtGui

在 python 上测试:3.7.4,windows:x32,x64

安装:

$ pip install py-loading-screen

进口:

$ from pyLoadingScreen import LoadingScreen

如果由于某种原因你没有 python 解释器 - 你可以看到编译的演示应用程序(windows):'example\compiled'

LoadingScreen(PyQt5.QtWidgets.QFrame)

参数:

texts = ['Loading', 'Loading.', 'Loading..', 'Loading...'],
textUpdateDelay = 0.75,

parentWidget = None,
windowSize = (350, 350),
mainStyleSheet = "background-color: black; color: rgb(80, 0, 255);",
mainFrameWidth = 3,
textLabelStyleSheet = "background-color: black; color: white; font: bold 18px;",

animationType = "RoundRobin",       # Animation types available: "RoundRobin", "RibbonDance"
animationDetailРЎoefficient = 20,
animationRGBColor = (255, 0, 0),
animationColorRainbow = True,
animationColorRainbowStep = 2,
animationColorRainbowMinValues = (0, 0, 0),
animationColorRainbowMaxValues = (255, 255, 255),
animationLineWidth = 3,
animationScale = 0.95,
animationCountStepsPerRound = 1440

笔记:

1. I recommend running this in a new thread. Anyway, you need to create instance of LoadingScreen at main thread, then start worker function in any thread.
    If you want to start in new 'clear' thread - use 'worker' function, else if you wont to create task with asyncio - use 'worker_asyncio' coroutine.

    !!! Variable with LoadingScreen instance must exist all time while script is running !!!

    - New thread start full example:
    "
        from pyLoadingScreen import LoadingScreen
        from threading import Thread
        from PyQt5 import QtWidgets

        app = QtWidgets.QApplication([])
        screen = LoadingScreen()

        thread = Thread(target=screen.worker)
        thread.start()

        app.exec()
     "
    - Asyncio create task example (in this case, you still can’t use main thread for loop, becouse it will be busy by app.exec() loop (see above)):
    "
        ...
        self.screen = LoadingScreen()
        loop = asyncio.get_event_loop()
        asyncio.gather(self.screen.worker_async(), loop=loop)
        ...
    "

2. To stop work use 'exit' attribute of LoadingScreen instance or create attribute 'exit_' in 'worker' or 'worker_async' function.
    Work is stop after some time after signal to exit. You can check LoadingScreen instance state by 'isRunning' attribute.
    Example:
    "
        from pyLoadingScreen import LoadingScreen
        from threading import Thread
        from PyQt5 import QtWidgets
        from time import sleep

        def kill_after_5_seconds(screenInstance: object):
            sleep(5)
            screenInstance.exit = True
            screenInstance.worker.__dict__['exit_'] = True
                    # Equivalent to 'self.screen.exit = True'
            screenInstance.worker_async.__dict__['exit_'] = True
                    # Equivalent to 'self.screen.exit = True',
                    # but in this case - it will not take any effect,
                    # because 'worker' is using instead ('thread = Thread(target=screen.worker)')

            while True:
                if screenInstance.isRunning:
                    print("LoadingScreen is still running")
                else:
                    print("LoadingScreen is not running now!")
                    print()
                    input("Press ENTER to exit.")
                    break

        app = QtWidgets.QApplication([])
        screen = LoadingScreen()

        thread = Thread(target=screen.worker)
        thread.start()

        threadMonitoring = Thread(target=kill_after_5_seconds, args=(screen,))
        threadMonitoring.start()

        app.exec()
    "


3. If you set parentWidget - don't forget add LoadingScreen to parentWidget's layout!
    Example:
    "
        ...
        self.screen = LoadingScreen(parentWidget=self.ui.myParentWidget)
        self.ui.myParentWidget.layout().addWidget(self.screen)
        ...
    "
4. If animationColorRainbow == True, then param 'animationRGBColor' ignored

5. If animationColorRainbow == False, then params ignored:
    animationColorRainbowStep,
    animationColorRainbowMinValues,
    animationColorRainbowMaxValues

6. animationCountStepsPerRound - speed of rotation. animationCountStepsPerRound increases - rotation speed decreases

7. By some reason i can't create instance of LoadingScreen in Spyder (Anaconda, Python 3.7.4), but in outer program this work fine.

版本:

v1.1.6:

  • Bug修复
  • 说明已补充

v1.1.5:

  • 重新设计了“RibbonDance”动画。

v1.1.4:

  • 添加了第 2 种动画类型 - “RibbonDance”。现在提供 2 种动画类型:“RoundRobin”(默认)和“RibbonDance”
  • 在示例应用程序中添加了动画类型的选择
  • 通过使用浮点类型坐标而不是整数类型提高了动画质量
  • 将参数“animationFacesCount”重命名为“animationDetailРЎoefficient”

v1.0.3:

  • Bug修复

v1.0.2:

  • 在 PyPI 上发布,现在可以使用 pip 使用模块:'pip install py-loading-screen'

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

内置分布

py_loading_screen-1.1.6-py3-none-any.whl (21.0 kB 查看哈希

已上传 py3