Import in Kivy

25 views
Skip to first unread message

Aras

unread,
Aug 29, 2011, 9:36:49 PM8/29/11
to kivy-...@googlegroups.com
Hi,
I am trying to understand how imports in Kivy are working. For some modules like Widget we do:
from kivy.uix.widget import Widget
This is clear, we are importing the module from /kivy/uix/widget.py
But for some other modules like Ellipse, Rectangle, and Color I cant find any modules in the path when we import them from. For example we do:
from kivy.graphics import Color, Ellipse, Line
But when I look inside graphics folder I dont see any of these three modules. Can anyone explain (or direct me to source to read) so I can understand how these modules get imported?
Thanks!

Aras

Christopher Denter

unread,
Aug 29, 2011, 9:41:17 PM8/29/11
to kivy-...@googlegroups.com
See kivy/graphics/__init__.py

__init__.py is implicit when importing, so you wouldn't write:
from kivy.graphics.__init__ import Color # wrong!

And then that module imports the other things into its namespace and exposes them.
Some of those come from a CPython extension created via cython, i.e. you're looking at .pyx files (but actually import from .so files at runtime; pyx just contains the source.)
See the official Python tutorial for more information about modules.

Christopher
Reply all
Reply to author
Forward
0 new messages