Skip to content

Commit 223ce20

Browse files
committed
doc: tweaks and standardized layout to uix/behaviors/knspace.py
1 parent 5c6bb3b commit 223ce20

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

kivy/uix/behaviors/knspace.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
This code is still experimental, and its API is subject to change in a
99
future version.
1010
11-
Provides namespace functionality for Kivy objects. It allows kivy objects
12-
to be named and then accessed using the namespace.
11+
The :class:`KNSpaceBehavior` `mixin <https://en.wikipedia.org/wiki/Mixin>`_
12+
class provides namespace functionality for Kivy objects. It allows kivy objects
13+
to be named and then accessed using namespaces.
1314
1415
:class:`KNSpace` instances are the namespaces that store the named objects
1516
in Kivy :class:`~kivy.properties.ObjectProperty` instances.
@@ -18,11 +19,10 @@
1819
namespace and will point to a :attr:`~kivy.uix.widget.proxy_ref` of the
1920
derived object.
2021
21-
2222
Basic examples
2323
--------------
2424
25-
By default, there's only a single namespace; the :attr:`knspace` namespace. The
25+
By default, there's only a single namespace: the :attr:`knspace` namespace. The
2626
simplest example is adding a widget to the namespace:
2727
2828
.. code-block:: python
@@ -31,8 +31,8 @@
3131
widget = Widget()
3232
knspace.my_widget = widget
3333
34-
This adds an kivy :class:`~kivy.properties.ObjectProperty` with `rebind=True`
35-
and `allownone=True` to the :attr:`knspace` namespace with property name
34+
This adds a kivy :class:`~kivy.properties.ObjectProperty` with `rebind=True`
35+
and `allownone=True` to the :attr:`knspace` namespace with a property name
3636
`my_widget`. And the property now also points to this widget.
3737
3838
This can be done automatically with:
@@ -68,7 +68,7 @@ class MyWidget(KNSpaceBehavior, Widget):
6868
Setting the namespace
6969
---------------------
7070
71-
One can also create their own namespace rather than using the default
71+
One can also create ones own namespace rather than using the default
7272
:attr:`knspace` by directly setting :attr:`KNSpaceBehavior.knspace`:
7373
7474
.. code-block:: python
@@ -83,7 +83,7 @@ class MyWidget(KNSpaceBehavior, Widget):
8383
Initially, `my_widget` is added to the default namespace, but when the widget's
8484
namespace is changed to `my_new_namespace`, the reference to `my_widget` is
8585
moved to that namespace. We could have also of course first set the namespace
86-
to `my_new_namespace` and then named the widget as `my_widget`, thereby
86+
to `my_new_namespace` and then have named the widget `my_widget`, thereby
8787
avoiding the initial assignment to the default namespace.
8888
8989
Similarly, in kv:
@@ -100,7 +100,7 @@ class MyWidget(KNSpaceBehavior, Widget):
100100
------------------------
101101
102102
In the previous example, we directly set the namespace we wished to use.
103-
In the following example we inherit it from our parent, so we only have to set
103+
In the following example, we inherit it from the parent, so we only have to set
104104
it once:
105105
106106
.. code-block:: kv
@@ -128,7 +128,7 @@ class MyWidget(KNSpaceBehavior, Widget):
128128
use. If none are found, it uses the default :attr:`knspace`.
129129
130130
When `MyComplexWidget` is created, it still used the default namespace.
131-
However, when we assigned to the root widget its new_namespace, all its
131+
However, when we assigned the root widget its new namespace, all its
132132
children switched to using that new namespace as well. So `new_knspace` now
133133
contains `label1` and `label2` as well as `my_complex`.
134134
@@ -196,7 +196,7 @@ class MyWidget(KNSpaceBehavior, Widget):
196196
197197
Further, because both the namespace :class:`~kivy.properties.ObjectProperty`
198198
references, and :atrr:`KNSpaceBehavior.knspace` have `rebind=True`, the
199-
text of the `MyComplexWidget` label is rebind to match the text of
199+
text of the `MyComplexWidget` label is rebound to match the text of
200200
`MyPrettyWidget` when either the root's namespace changes or when the
201201
`root.knspace.pretty` property changes, as expected.
202202
@@ -379,11 +379,12 @@ def fork(self):
379379

380380

381381
class KNSpaceBehavior(object):
382-
'''Inheriting from this class allows naming of the inherited object, which
383-
is then added to the associated namespace :attr:`knspace` and accessible
382+
'''Inheriting from this class allows naming of the inherited objects, which
383+
are then added to the associated namespace :attr:`knspace` and accessible
384384
through it.
385385
386-
See :mod:`~kivy.uix.behaviors.knspace` for details.
386+
Please see the :mod:`knspace behaviors module <kivy.uix.behaviors.knspace>`
387+
documentation for more information.
387388
'''
388389

389390
_knspace = ObjectProperty(None, allownone=True)

0 commit comments

Comments
 (0)