跳转到主要内容

Kivy应用程序库强化版

项目描述

卡基 - Kivy的高级应用程序库

此库通过以下有见地的功能增强Kivy框架

  • 自动重新加载 kv 或 py(需要 watchdog,限于某些用例)
  • 空闲检测支持
  • 前台锁定(仅限Windows)

示例

这是一个引导程序,将

  • 自动声明模块 live.uilive/ui.py)作为 widget UI 的提供者
  • 构建应用程序 widget,并将其显示在窗口中

如果引导程序以环境变量 DEBUG=1 启动,它将启动一个 watchdog,并根据 AUTORELOADER_PATHS 监听更改。当有更改时,当前的应用程序 widget 将被清除,并在重新加载后创建一个新的实例。

from kaki.app import App
from kivy.factory import Factory

class Live(App):
    CLASSES = {
        "UI": "live.ui"
    }
    AUTORELOADER_PATHS = [
        (".", {"recursive": True}),
    ]
    def build_app(self):
        return Factory.UI()

Live().run()

应用程序类配置

#: Control either we activate debugging in the app or not
#: Defaults depend if "DEBUG" exists in os.environ
DEBUG = "DEBUG" in os.environ

#: If true, it will require the foreground lock on windows
FOREGROUND_LOCK = False

#: List of KV files under management for auto reloader
KV_FILES = []

#: List of path to watch for autoreloading
AUTORELOADER_PATHS = [
    # (".", {"recursive": False}),
]

#: List of extensions to ignore
AUTORELOADER_IGNORE_PATTERNS = [
    "*.pyc", "*__pycache__*"]

#: Factory classes managed by kaki
CLASSES = {}

#: Idle detection (if True, event on_idle/on_wakeup will be fired)
#: Rearming idle can also be done with rearm_idle()
IDLE_DETECTION = False

#: Auto install idle detection check when activated
IDLE_DETECTION_AUTO_START = True

#: Default idle timeout
IDLE_TIMEOUT = 60

#: Raise error
#: When the DEBUG is activated, it will raise any error instead
#: of showing it on the screen. If you still want to show the error
#: when not in DEBUG, put this to False
RAISE_ERROR = True

空闲管理

空闲检测功能旨在在用户在一定时间内未触摸屏幕时触发一个动作。这可以用来显示吸引屏幕、屏保或其他内容。

要启用空闲检测,请将配置项 IDLE_DETECTION 设置为 True。Kaki 将随后监听触摸按下/移动事件。如果在 IDLE_TIMEOUT 时间间隔内没有发生此类事件,或者没有调用 rearm_idle 函数,应用程序类将触发 on_idle 事件。如果在空闲模式下发生触摸事件或调用 rearm_idle,则应用程序类将触发 on_wakeup 事件。

如果您正在播放视频且不希望触发空闲检测,您可以在应用程序类中使用 rearm_idle 函数将空闲计时器重置为 0 秒。

项目详情


下载文件

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

源分布

kaki-0.1.9.tar.gz (8.9 kB 查看散列)

上传时间

构建分布

kaki-0.1.9-py2.py3-none-any.whl (7.3 kB 查看散列)

上传时间 Python 2 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面