类固醇上的 Kivy 应用程序库
项目描述
Kaki - Kivy 的高级应用程序库
这个库增强了 Kivy 框架,具有一些自以为是的功能,例如:
- 自动重新加载 kv 或 py(
watchdog必需,仅限于某些用例) - 空闲检测支持
- 前景锁定(仅限 Windows)
例子
这是一个引导程序,它将:
- 自动将模块
live.ui(live/ui.py) 声明为小部件的提供者UI - 构建应用程序小部件,并将其显示到窗口
如果 bootstrap 使用环境变量DEBUG=1启动,它将启动一个看门狗,并根据AUTORELOADER_PATHS. 当某些事情发生变化时,当前的应用程序小部件将被清除,并在重新加载后实例化一个新的小部件。
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
#: 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,那么它会自动监听着陆/移动。当没有事件发生时,IDLE_TIMEOUT几秒钟后,它将触发on_idle应用程序类上的事件。一旦发生触摸事件,on_wakeup就会在应用程序类上触发事件。
如果您在播放视频时不想触发空闲检测,rearm_idle请在应用程序类上使用从 0 秒开始重新启用检测。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
kaki-0.1.5.tar.gz
(8.8 kB
查看哈希)
内置分布
kaki-0.1.5-py2.py3-none-any.whl
(7.0 kB
查看哈希)