Kivy Event 在哪里?
kivy 程序都是都需要继承APP基类
而App类在Lib\site-packages\kivy\app.py文件定义
from kivy.event import EventDispatcher
class App(EventDispatcher):
pass
找到Lib\site-packages\kivy\event.py 里面是这样定义的
import kivy._event
__doc__ = kivy._event.__doc__
EventDispatcher = kivy._event.EventDispatcher
ObjectWithUid = kivy._event.ObjectWithUid
Observable = kivy._event.Observable
又引用了Lib\site-packages\kivy_event.pxd , 而pxd文件只是个类似c里的头文件(接口声明), 真正的代码实现在
Lib\site-packages\kivy_event.cp36-win32.pyd (pxd描述参考)[https://cloud.tencent.com/developer/news/180987]
那为什么在pycharm 里查看时定义处时为什么会跳转到.PyCharm2018.3\system\python_stubs\498501734\kivy_event.py 文件呢,
答案在这里:
https://stackoverflow.com/questions/24266114/pycharm-what-is-python-stubs
写就是说这个文件时pycahrm为我们根据pyd文件生成的,为方便调试代码, 在.PyCharm2018.3\system\python_stubs\498501734\kivy\_event.py
文件都已经
有详细的说明了:
# encoding: utf-8
# module kivy._event
# from xxxx\lib\site-packages\kivy\_event.cp36-win32.pyd
# by generator 1.146
"""
Event dispatcher
================
All objects that produce events in Kivy implement the :class:`EventDispatcher`
which provides a consistent interface for registering and manipulating event
handlers.
.. versionchanged:: 1.0.9
Property discovery and methods have been moved from the
:class:`~kivy.uix.widget.Widget` to the :class:`EventDispatcher`.
"""