mirror of https://github.com/kivy/kivy.git
update/fixes to guide2 doc
This commit is contained in:
parent
399c64f73c
commit
7fe72d759e
|
@ -6,10 +6,11 @@ Basic Kivy
|
|||
Installation of Kivy environment
|
||||
--------------------------------
|
||||
|
||||
Kivy depends on multiples dependencies, such as pygame, gstreamer, PIL, cairo,
|
||||
and more. All of them are not required, but depending the platform you're
|
||||
working on, it can be a pain to install them. For Windows and MacOSX, we
|
||||
provide a portable package that you can just unzip and use.
|
||||
Kivy depends on multiples dependencies, such as pygame, gstreamer, PIL,
|
||||
cairo, and more. All of them are not required, but depending the
|
||||
platform you're working on, it can be a pain to install them. For
|
||||
Windows and MacOSX, we provide a portable package that you can just
|
||||
unzip and use.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
@ -18,29 +19,31 @@ provide a portable package that you can just unzip and use.
|
|||
/installation/installation-macosx.rst
|
||||
/installation/installation-linux.rst
|
||||
|
||||
If you want to install everything yourself, ensure that you have at least
|
||||
`Cython <http://cython.org>`_, `Pygame <http://pygame.org>`. A typical pip
|
||||
If you want to install everything yourself, ensure that you have at
|
||||
least `Cython <http://cython.org>`_, `Pygame <http://pygame.org>`. A
|
||||
typical pip
|
||||
installation look like::
|
||||
|
||||
pip install cython
|
||||
pip install hg+http://bitbucket.org/pygame/pygame
|
||||
pip install kivy
|
||||
|
||||
The `development version <https://github.com/kivy/kivy>`_ can be installed with
|
||||
git::
|
||||
The `development version <https://github.com/kivy/kivy>`_ can be
|
||||
installed with git::
|
||||
|
||||
git clone https://github.com/kivy/kivy
|
||||
make
|
||||
|
||||
|
||||
Create an application
|
||||
---------------------
|
||||
|
||||
Creating a kivy application is as simple as:
|
||||
|
||||
- subclassing the :cls:`kivy.app.App` class,
|
||||
- implementing its :meth:`kivy.app.App.build` method so it returns a :cls:`kivy.uix.Widget` instance (the root of your widget tree)
|
||||
- instanciating this class, and call its :meth:`kiyv.app.App.run` method.
|
||||
- subclassing the :class:`kivy.app.App` class
|
||||
- implementing its :meth:`kivy.app.App.build` method so it returns a
|
||||
:class:`kivy.uix.Widget` instance (the root of your widget tree) -
|
||||
instanciating this class, and call its :meth:`kiyv.app.App.run`
|
||||
method.
|
||||
|
||||
here is an example of such a minimum application::
|
||||
|
||||
|
|
|
@ -7,31 +7,31 @@ Events and Properties
|
|||
Events are a big part of kivy programming, that may not be surprising to those
|
||||
having done GUI development before, but it's an important concept to get for
|
||||
newcomers, and the specifics of how to use these in kivy. Once you understand
|
||||
how events and ways to bind to them, are everywhere in kivy, it becomes easy
|
||||
to build about whatever you want with kivy.
|
||||
how events and ways to bind to them, are everywhere in kivy, it becomes easy to
|
||||
build about whatever you want with kivy.
|
||||
|
||||
Introduction to Event Dispatcher
|
||||
--------------------------------
|
||||
|
||||
One of the most important base class of the framework is the
|
||||
:cls:`kivy.event.EventDispatcher` class, this class allows to register event
|
||||
One of the most important base classes of the framework is the
|
||||
:class:`kivy.event.EventDispatcher` class, this class allows to register event
|
||||
types, and to dispatch them to interrested parties (usually other event
|
||||
dispatchers). :cls:`kivy.uix.widget.Widget`, :cls:`kivy.animation.Animation`
|
||||
and :obj:`kivy.clock.Clock` for example are event dispatchers.
|
||||
dispatchers). :class:`kivy.uix.widget.Widget`,
|
||||
:class:`kivy.animation.Animation` and :obj:`kivy.clock.Clock` for example are
|
||||
event dispatchers.
|
||||
|
||||
Creating custom events
|
||||
----------------------
|
||||
|
||||
To create an event dispatcher with custom events, you need to register
|
||||
the name of the event in the class, and to create a method of the same
|
||||
name.
|
||||
To create an event dispatcher with custom events, you need to register the name
|
||||
of the event in the class, and to create a method of the same name.
|
||||
|
||||
See the following example::
|
||||
|
||||
class MyEventDispatcher(EventDispatcher):
|
||||
def __init__(self, **kwargs):
|
||||
super(MyEventDispatcher, self).__init__(**kwargs)
|
||||
self.register_event_type('on_test')
|
||||
super(MyEventDispatcher, self).__init__(**kwargs)
|
||||
|
||||
def test(self, value):
|
||||
# when test is called, the 'on_test' event will be
|
||||
|
@ -71,14 +71,15 @@ Properties are an awesome way to define events and bind to them, it basically
|
|||
produce events when the attributes to your object changes, so you can bind
|
||||
actions to the change of these values.
|
||||
|
||||
There are different kind of properties to describe the type of data you want to describe.
|
||||
There are different kind of properties to describe the type of data you want to
|
||||
describe.
|
||||
|
||||
:cls:`kivy.properties.StringProperty`
|
||||
:cls:`kivy.properties.NumericProperty`
|
||||
:cls:`kivy.properties.ObjectProperty`
|
||||
:cls:`kivy.properties.ListProperty`
|
||||
:cls:`kivy.properties.ObjectProperty`
|
||||
:cls:`kivy.properties.AliasProperty`
|
||||
- :class:`kivy.properties.StringProperty`
|
||||
- :class:`kivy.properties.NumericProperty`
|
||||
- :class:`kivy.properties.ObjectProperty`
|
||||
- :class:`kivy.properties.ListProperty`
|
||||
- :class:`kivy.properties.ObjectProperty`
|
||||
- :class:`kivy.properties.AliasProperty`
|
||||
|
||||
Declaration of a Property
|
||||
-------------------------
|
||||
|
|
|
@ -6,20 +6,19 @@ Widgets
|
|||
Introduction to Widget
|
||||
----------------------
|
||||
|
||||
A `:cls:kivy.uix.widget.Widget` is the basic component of the interface,
|
||||
it can display things at places, and recieve touch (and other) events,
|
||||
and react to them. It's representation and behaviour.
|
||||
A :class:`kivy.uix.widget.Widget` is the basic component of the interface, it
|
||||
can display things at places, and recieve touch (and other) events, and react to
|
||||
them. It's representation and behaviour.
|
||||
|
||||
Manipulating the Widget tree
|
||||
----------------------------
|
||||
|
||||
Widgets are organized in Trees, your application usually
|
||||
have a root widget, which have children, which can
|
||||
have children on their own. Childrens of a widget are
|
||||
represented as a :cls:`kivy.properties.ListProperty`
|
||||
:attr:`kivy.uix.widget.Widget.children`. The way to add a children to a
|
||||
widget is to call :meth:`kivy.uix.widget.Widget.add_widget`, likely, to
|
||||
remove a widget, you use :meth:`kivy.uix.widget.Widget.remove_widget`.
|
||||
Widgets are organized in Trees, your application have a root widget, which
|
||||
usually have children, which can have children on their own. Children of a
|
||||
widget are represented as a :class:`kivy.properties.ListProperty`
|
||||
:attr:`kivy.uix.widget.Widget.children`. The way to add a children to a widget
|
||||
is to call :meth:`kivy.uix.widget.Widget.add_widget`, likely, to remove a
|
||||
widget, you use :meth:`kivy.uix.widget.Widget.remove_widget`.
|
||||
|
||||
Organize with Layouts
|
||||
---------------------
|
||||
|
@ -27,16 +26,14 @@ Organize with Layouts
|
|||
Layouts are a special kind of widget that allows automatic control of the size
|
||||
and position of their children. There are different kind of layouts, allowing
|
||||
for different automatic organisation. A common caracteristic of layouts is that
|
||||
they use (even if differently) of the
|
||||
:attr:`kivy.uix.widget.Widget.size_hint` and
|
||||
:attr:`kivy.uix.widget.Widget.pos_hint` properties. Those properties allow to
|
||||
define size and pos of the widget relatively to the parent layout.
|
||||
they use (even if differently) of the :attr:`kivy.uix.widget.Widget.size_hint`
|
||||
and :attr:`kivy.uix.widget.Widget.pos_hint` properties. Those properties allow
|
||||
to define size and pos of the widget relatively to the parent layout.
|
||||
|
||||
Seperate with Screen Manager
|
||||
----------------------------
|
||||
|
||||
If your application is composed of various screens, you likely want an
|
||||
easy way to navigate from one to another, fortunately, there is the
|
||||
:cls:`kivy.uix.screenmanager.ScreenManager` class, that allows you
|
||||
to define screens separatly, and to set the transitions from one to
|
||||
another.
|
||||
If your application is composed of various screens, you likely want an easy way
|
||||
to navigate from one to another, fortunately, there is the
|
||||
:class:`kivy.uix.screenmanager.ScreenManager` class, that allows you to define
|
||||
screens separatly, and to set the transitions from one to another.
|
||||
|
|
Loading…
Reference in New Issue