more corrections to docs

This commit is contained in:
Dominik Kozaczko 2012-08-09 13:50:05 +02:00
parent e68d68d1ac
commit d1eefab851
3 changed files with 32 additions and 17 deletions

View File

@ -2,7 +2,7 @@
# #
# You can set these variables from the command line. # You can set these variables from the command line.
PYTHON = python2 PYTHON = python
SPHINXOPTS = -W SPHINXOPTS = -W
#SPHINXOPTS = #SPHINXOPTS =
SPHINXBUILD = sphinx-build SPHINXBUILD = sphinx-build

View File

@ -27,8 +27,9 @@ create the UI around the ``Controller`` class in a file named `controller.kv`,
which will be loaded when we run the ``ControllerApp``. How this is done and which will be loaded when we run the ``ControllerApp``. How this is done and
what files are loaded is described in the :func:`kivy.app.App.load_kv` method. what files are loaded is described in the :func:`kivy.app.App.load_kv` method.
.. include:: ../../../examples/guide/designwithkv/controller.kv .. literalinclude:: ../../../examples/guide/designwithkv/controller.kv
:literal: :language: kv
:linenos:
One label and one button in a vertical ``BoxLayout``. Seems very simple. There One label and one button in a vertical ``BoxLayout``. Seems very simple. There
are 3 things going on here: are 3 things going on here:
@ -52,7 +53,9 @@ are 3 things going on here:
the current widget. the current widget.
* You can use any id declared in the rule the same as ``root`` and * You can use any id declared in the rule the same as ``root`` and
``self``. For example, you could do this in the ``on_press()``:: ``self``. For example, you could do this in the ``on_press()``:
.. code-block:: kv
Button: Button:
on_press: root.do_action(); my_custom_label.font_size = 18 on_press: root.do_action(); my_custom_label.font_size = 18

View File

@ -74,8 +74,9 @@ called ``pong.kv`` in the same directory that will be automatically loaded
when the application is run. So create a new file called ``*pong.kv*`` and add when the application is run. So create a new file called ``*pong.kv*`` and add
the following contents. the following contents.
.. include:: ../../../examples/tutorials/pong/steps/step2/pong.kv .. literalinclude:: ../../../examples/tutorials/pong/steps/step2/pong.kv
:literal: :language: kv
:linenos:
If you run the app now, you should see a vertical bar in the middle, and two If you run the app now, you should see a vertical bar in the middle, and two
zeros where the player scores will be displayed. zeros where the player scores will be displayed.
@ -127,7 +128,9 @@ child widgets that will be automatically added, or a `canvas` section in
which you can add Graphics instructions that define how the widget itself is which you can add Graphics instructions that define how the widget itself is
rendered. rendered.
The first block inside the ``<PongGame>`` rule we have is a canvas block:: The first block inside the ``<PongGame>`` rule we have is a canvas block:
.. code-block:: kv
<PongGame>: <PongGame>:
canvas: canvas:
@ -150,10 +153,12 @@ score once we have the logic for that implemented. But the labels already
look good, since we set a bigger font_size, and positioned them relatively look good, since we set a bigger font_size, and positioned them relatively
to the root widget. The ``root`` keyword can be used inside child block to to the root widget. The ``root`` keyword can be used inside child block to
refer back to the parent/root widget the rule applies to (``PongGame`` in this refer back to the parent/root widget the rule applies to (``PongGame`` in this
case):: case):
.. code-block:: kv
<PongGame>: <PongGame>:
... # ...
Label: Label:
font_size: 70 font_size: 70
@ -207,7 +212,9 @@ Here is the python code for the PongBall class::
self.pos = Vector(*self.velocity) + self.pos self.pos = Vector(*self.velocity) + self.pos
And here is the kv rule used to draw the ball as a white circle:: And here is the kv rule used to draw the ball as a white circle:
.. code-block:: kv
<PongBall>: <PongBall>:
size: 50, 50 size: 50, 50
@ -232,8 +239,9 @@ Here is the entire updated python code and kv file for this step:
:literal: :literal:
pong.kv: pong.kv:
.. include:: ../../../examples/tutorials/pong/steps/step3/pong.kv .. literalinclude:: ../../../examples/tutorials/pong/steps/step3/pong.kv
:literal: :language: kv
:linenos:
Adding ball animation Adding ball animation
@ -308,7 +316,9 @@ inside the ``update`` method and even make it bounce of the edges::
self.ball.velocity_x *= -1 self.ball.velocity_x *= -1
Don't forget to hook it up in the kv file, by giving the child widget an id Don't forget to hook it up in the kv file, by giving the child widget an id
and setting the games property to that id:: and setting the games property to that id:
.. code-block:: kv
<PongGame>: <PongGame>:
ball: pong_ball ball: pong_ball
@ -337,8 +347,9 @@ Here is the entire code for this step:
:literal: :literal:
pong.kv: pong.kv:
.. include:: ../../../examples/tutorials/pong/steps/step4/pong.kv .. literalinclude:: ../../../examples/tutorials/pong/steps/step4/pong.kv
:literal: :language: kv
:linenos:
Connect input event Connect input event
------------------- -------------------
@ -401,8 +412,9 @@ And here it is in context. Pretty much done:
pong.kv: pong.kv:
.. include:: ../../../examples/tutorials/pong/steps/step5/pong.kv .. literalinclude:: ../../../examples/tutorials/pong/steps/step5/pong.kv
:literal: :language: kv
:linenos:
Where to go now? Where to go now?