mirror of https://github.com/kivy/kivy.git
Merge pull request #402 from pjz/master
Fixed some minor grammar errors and typos
This commit is contained in:
commit
8e6a9bb00d
|
@ -47,11 +47,11 @@ are 3 things going on here:
|
|||
3. Creating a custom callback in the ``Button`` using the ``Controller``'s
|
||||
``on_press`` method.
|
||||
|
||||
* ``root`` and ``self`` are 2 reserved keywords, useable anywhere.
|
||||
* ``root`` and ``self`` are reserved keywords, useable anywhere.
|
||||
``root`` represents the top widget in the rule and ``self`` represents
|
||||
the current widget.
|
||||
|
||||
* You can use any id declared in the rule, 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()``::
|
||||
|
||||
Button:
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
Events
|
||||
======
|
||||
|
||||
You have 2 types of events living in Kivy:
|
||||
There are two types of events in Kivy:
|
||||
|
||||
- Clock events: if you want to call a function X times per seconds, or if you
|
||||
- Clock events: if you want to call a function X times per second, or if you
|
||||
want to call a function later.
|
||||
- Widget events: if you want to call a function where something change in the
|
||||
- Widget events: if you want to call a function when something changes in the
|
||||
widget, or attach a function to a widget specific event.
|
||||
|
||||
|
||||
|
@ -31,15 +31,15 @@ a repetitive call or one-time call.
|
|||
Scheduling a repetitive event
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can call a function or a method every X times per seconds using
|
||||
You can call a function or a method every X times per second using
|
||||
:meth:`~kivy.clock.Clock.schedule_interval`. Here is an example of calling a
|
||||
function named my_callback 30 times per seconds::
|
||||
function named my_callback 30 times per second::
|
||||
|
||||
def my_callback(dt):
|
||||
print 'My callback is called', dt
|
||||
Clock.schedule_interval(my_callback, 1 / 30.)
|
||||
|
||||
You have 2 ways of unscheduling a previously scheduled event. The first would be
|
||||
You have two ways of unscheduling a previously scheduled event. The first would be
|
||||
to use :meth:`~kivy.clock.Clock.unschedule`::
|
||||
|
||||
Clock.unschedule(my_callback)
|
||||
|
@ -117,12 +117,12 @@ A widget has 2 types of events:
|
|||
Property event
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
A widget has many properties. You'll find in the doc that every property has a
|
||||
A widget has many properties. You'll find in the documentation that every property has a
|
||||
type like :class:`~kivy.properties.NumericProperty`,
|
||||
:class:`~kivy.properties.StringProperty`,
|
||||
:class:`~kivy.properties.ListProperty`.
|
||||
|
||||
Usualy, when you want to create a Python class with properties, you do something like this::
|
||||
Usually, when you want to create a Python class with properties, you do something like this::
|
||||
|
||||
class MyClass(object):
|
||||
def __init__(self):
|
||||
|
@ -184,7 +184,7 @@ If you are designing your own widget, you can create a widget event by using
|
|||
# empty handler needed
|
||||
pass
|
||||
|
||||
Then, the user can hook to it, same as the Button.on_press event. In this
|
||||
Then, the user can hook to it, the same as to the Button.on_press event. In this
|
||||
example, the event is never dispatched. Let's just add a function demonstrating
|
||||
how to dispatch a widget-defined event::
|
||||
|
||||
|
@ -195,5 +195,5 @@ how to dispatch a widget-defined event::
|
|||
def do_something(self):
|
||||
self.dispatch('on_custom_event')
|
||||
|
||||
Now, everytime you call the ``do_something()`` method, it will dispatch
|
||||
Now, every time you call the ``do_something()`` method, it will dispatch
|
||||
``on_custom_event``, and call every function attached to this event.
|
||||
|
|
|
@ -149,7 +149,7 @@ And here is your "yourwidget.py" python part::
|
|||
pass
|
||||
|
||||
Yes, not a single line of graphics code has been written in Python. You'd like
|
||||
to know how it's working, wouldn't you? Good.
|
||||
to know how it works, wouldn't you? Good.
|
||||
|
||||
The first line indicates a rule (like a CSS (Cascading Style Sheets) rule) that
|
||||
will match all the classes named by the rule's name::
|
||||
|
|
|
@ -21,7 +21,7 @@ http://code.google.com/p/kivy/downloads/list, and unzip it.
|
|||
Build in debug mode
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Inside the package, you have a tool named build.py. This is the script that will create APK for you::
|
||||
Inside the package, you have a tool named build.py. This is the script that will create the APK for you::
|
||||
|
||||
./build.py --dir <path to your app>
|
||||
--name "<title>"
|
||||
|
@ -33,18 +33,18 @@ Inside the package, you have a tool named build.py. This is the script that will
|
|||
--with-ffmpeg
|
||||
<debug|release> <installd|installr|...>
|
||||
|
||||
Starting 1.0.9, build.py have been updated to use Android SDK rev14, but is
|
||||
Starting with 1.0.9, build.py has been updated to use Android SDK rev14, but is
|
||||
still compatible with previous version:
|
||||
|
||||
- if you pass 2 last argument, it will use Android SDK rev14 (new build system)
|
||||
- if you pass only one argument, it will use older Android SDK build system
|
||||
- if you pass two last arguments, it will use Android SDK rev14 (new build system)
|
||||
- if you pass only one argument, it will use the older Android SDK build system
|
||||
|
||||
.. note::
|
||||
|
||||
The Android SDK rev14 usage is available starting Kivy 1.0.9. If you have SDK
|
||||
The Android SDK rev14 usage is available starting in Kivy 1.0.9. If you have SDK
|
||||
rev14 installed on your system, you must upgrade Kivy for android as well.
|
||||
|
||||
For example, if we imagine that touchtracer demo of Kivy is in the directory
|
||||
For example, if we imagine that the touchtracer demo of Kivy is in the directory
|
||||
~/kivy/examples/demo/touchtracer, you can do::
|
||||
|
||||
python build.py --dir ~/kivy/examples/demo/touchtracer \
|
||||
|
@ -53,7 +53,7 @@ For example, if we imagine that touchtracer demo of Kivy is in the directory
|
|||
|
||||
The debug binary will be generated in bin/KivyTouchtracer-1.0.6-debug.apk.
|
||||
|
||||
Then in later time, you can install directly to your android device by doing::
|
||||
Then, later, you can install it directly to your android device by doing::
|
||||
|
||||
adb install -r bin/KivyTouchtracer-1.0.6-debug.apk
|
||||
|
||||
|
@ -64,8 +64,8 @@ Video support
|
|||
|
||||
.. versionadded:: 1.0.8
|
||||
|
||||
By default, the produced APK don't contain any libraries for video support. You
|
||||
can add ffmpeg library on your build to activate it. The default ffmpeg
|
||||
By default, the produced APK doesn't contain any libraries for video support. You
|
||||
can add the ffmpeg library on your build to activate it. The default ffmpeg
|
||||
compiled is the "minimal support", and will increase the APK size of ~8MB.
|
||||
|
||||
The option to add on the build.py command line is `--with-ffmpeg`::
|
||||
|
@ -81,7 +81,7 @@ sign and zipalign the apk. Read the android documentation at:
|
|||
http://developer.android.com/guide/publishing/app-signing.html
|
||||
|
||||
The release binary will be generated in bin/KivyTouchtracer-1.0.6-unsigned.apk
|
||||
(for previous touchtracer example.)
|
||||
(for the previous touchtracer example.)
|
||||
|
||||
|
||||
Packaging your application for Kivy Launcher
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
Create package for MacOSX
|
||||
=========================
|
||||
|
||||
Packaging your application for MacOSX 10.6 platform can be done only inside the
|
||||
MacOSX. The following method have been tested only inside VirtualBox and
|
||||
Packaging your application for the MacOSX 10.6 platform can be done only inside
|
||||
MacOSX. The following method have only been tested inside VirtualBox and
|
||||
MacOSX 10.6, using the portable package of Kivy.
|
||||
|
||||
The package will be only for 64 bits MacOSX. We have no way to do 32 bits right
|
||||
|
@ -17,7 +17,7 @@ Requirements
|
|||
Install and configure PyInstaller
|
||||
---------------------------------
|
||||
|
||||
First, we need to setup correctly pyinstaller for 64 bits if you want to be
|
||||
First, we need to correctly setup pyinstaller for 64 bits if you want to be
|
||||
able to package your Kivy application.
|
||||
|
||||
#. Decompress the PyInstaller
|
||||
|
@ -39,8 +39,8 @@ Now, your pyinstaller installation is ready to be used !
|
|||
Create the spec file
|
||||
--------------------
|
||||
|
||||
For the example, we'll package touchtracer example, using a custom icon. The
|
||||
touchtracer is the `../kivy/examples/demo/touchtracer/` directory, and the main
|
||||
For an example, we'll package the touchtracer example, using a custom icon. The
|
||||
touchtracer is in the `../kivy/examples/demo/touchtracer/` directory, and the main
|
||||
file is named `main.py`. Replace both path/filename according to your system.
|
||||
|
||||
#. Open a console
|
||||
|
@ -51,7 +51,7 @@ file is named `main.py`. Replace both path/filename according to your system.
|
|||
|
||||
#. The specs file is located on `touchtracer/touchtracer.spec` inside the
|
||||
pyinstaller directory. Now we need to edit the spec file to add kivy hooks
|
||||
for correctly build the exe.
|
||||
to correctly build the exe.
|
||||
Open the spec file with your favorite editor and put theses lines at the
|
||||
start of the spec::
|
||||
|
||||
|
@ -60,7 +60,7 @@ file is named `main.py`. Replace both path/filename according to your system.
|
|||
|
||||
Then, you need to change the `COLLECT()` call to add the data of touchtracer
|
||||
(`touchtracer.kv`, `particle.png`, ...). Change the line to add a Tree()
|
||||
object. This Tree will search and add every files found in the touchtracer
|
||||
object. This Tree will search and add every file found in the touchtracer
|
||||
directory to your final package::
|
||||
|
||||
coll = COLLECT( exe, Tree('../kivy/examples/demo/touchtracer/'),
|
||||
|
@ -86,5 +86,5 @@ Build the spec and create DMG
|
|||
hdiutil create ./Touchtracer.dmg -srcfolder touchtracer.app -ov
|
||||
popd
|
||||
|
||||
#. You will have a Touchtracer.dmg available in `touchtracer/dist` directory
|
||||
#. You will have a Touchtracer.dmg available in the `touchtracer/dist` directory
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ Packaging your application for Windows platform can be done only inside the
|
|||
Windows OS. The following method have been tested only inside VirtualBox and
|
||||
Windows Seven, using the portable package of Kivy.
|
||||
|
||||
The package will be 32 bits, and can be runned on both 32/64 bits windows
|
||||
The package will be 32 bits, and can be run on both 32/64 bits windows
|
||||
platform.
|
||||
|
||||
Requirements
|
||||
|
@ -18,7 +18,7 @@ Install and configure PyInstaller
|
|||
---------------------------------
|
||||
|
||||
#. Decompress the PyInstaller in the Kivy portable package
|
||||
#. Double click on the Kivy.bat, a console will be open
|
||||
#. Double click on the Kivy.bat, a console will open
|
||||
#. Go to the pyinstaller directory, and run only once the Configure.py::
|
||||
|
||||
cd pyinstaller-1.5
|
||||
|
@ -31,19 +31,19 @@ For the example, we'll package touchtracer example, using a custom icon. The
|
|||
touchtracer is the `kivy/examples/demo/touchtracer/` directory, and the main
|
||||
file is named `main.py`
|
||||
|
||||
#. Double click on the Kivy.bat, a console will be open
|
||||
#. Double click on the Kivy.bat, a console will open
|
||||
#. Go to the pyinstaller directory, and create the initial specs::
|
||||
|
||||
cd pyinstaller-1.5
|
||||
python Makespec.py --name touchtracer ..\kivy\examples\demo\touchtracer\main.py
|
||||
|
||||
Alternatively, you can add an icon.ico to the main executable. If you don't have any .ico file available, you can convert your icon.png file to ico with the http://www.convertico.com/. Save the icon.ico in the touchtracer directory and do::
|
||||
Alternatively, you can add an icon.ico to the main executable. If you don't have an .ico file available, you can convert your icon.png file to ico with the http://www.convertico.com/. Save the icon.ico in the touchtracer directory and do::
|
||||
|
||||
python Makespec.py --name touchtracer --icon ..\kivy\examples\demo\touchtracer\icon.ico ..\kivy\examples\demo\touchtracer\main.py
|
||||
|
||||
#. The specs file is located on `touchtracer/touchtracer.spec` inside the
|
||||
pyinstaller directory. Now we need to edit the spec file to add kivy hooks
|
||||
for correctly build the exe.
|
||||
to correctly build the exe.
|
||||
Open the spec file with your favorite editor and put theses lines at the
|
||||
start of the spec::
|
||||
|
||||
|
@ -52,7 +52,7 @@ file is named `main.py`
|
|||
|
||||
Then, you need to change the `COLLECT()` call to add the data of touchtracer
|
||||
(`touchtracer.kv`, `particle.png`, ...). Change the line to add a Tree()
|
||||
object. This Tree will search and add every files found in the touchtracer
|
||||
object. This Tree will search and add every file found in the touchtracer
|
||||
directory to your final package::
|
||||
|
||||
coll = COLLECT( exe, Tree('../kivy/examples/demo/touchtracer/'),
|
||||
|
@ -71,5 +71,5 @@ Build the spec
|
|||
cd pyinstaller-1.5
|
||||
python Build.py touchtracer\\touchtracer.spec
|
||||
|
||||
#. The package will be the `touchtracer\\dist\\touchtracer` directory !
|
||||
#. The package will be in the `touchtracer\\dist\\touchtracer` directory !
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
Widget tree
|
||||
===========
|
||||
|
||||
Like most of GUI toolkit, Kivy have a tree for handling a hierarchy of widgets.
|
||||
The top level widget is called "root". Each widget can be connected to others
|
||||
Like most GUI toolkits, Kivy has a tree for handling a hierarchy of widgets.
|
||||
The top level widget is called "root". Each widget can be connected to other
|
||||
widgets, as a parent or as a child.
|
||||
|
||||
You cannot add into the widget tree something that is not a
|
||||
|
@ -45,16 +45,16 @@ If you want to clear all the children inside a widget, use
|
|||
Never manipulate the children list yourself, if you don't know what you are
|
||||
doing. The widget tree is associated to a graphic tree. For example, if you
|
||||
add a widget into the children list without adding his canvas to the
|
||||
graphics tree, the widget will be a children yes, but nothing will be drawed
|
||||
on the screen. More than that, you might have issue on further call of
|
||||
graphics tree, the widget will be a children yes, but nothing will be drawn
|
||||
on the screen. More than that, you might have issues on further calls of
|
||||
add_widget, remove_widget and clear_widgets.
|
||||
|
||||
|
||||
Traversing the tree
|
||||
-------------------
|
||||
|
||||
The widget class have a :data:`~kivy.uix.widget.Widget.children` list property
|
||||
that contain all the children. You can easily traverse the tree by doing ::
|
||||
The widget class has a :data:`~kivy.uix.widget.Widget.children` list property
|
||||
that contains all the children. You can easily traverse the tree by doing ::
|
||||
|
||||
root = BoxLayout()
|
||||
# ... add widgets to root ...
|
||||
|
@ -62,11 +62,11 @@ that contain all the children. You can easily traverse the tree by doing ::
|
|||
print child
|
||||
|
||||
However, this must be used carefuly. If you intend to modify the children list
|
||||
with one of the methods showed in the previous section, you must use a copy of
|
||||
with one of the methods shown in the previous section, you must use a copy of
|
||||
the list like this::
|
||||
|
||||
for child in root.children[:]:
|
||||
# manipulate the tree. For example here, remove all widget that have a
|
||||
# manipulate the tree. For example here, remove all widgets that have a
|
||||
# width < 100
|
||||
if child.width < 100:
|
||||
root.remove_widget(child)
|
||||
|
|
|
@ -5,7 +5,7 @@ Installation
|
|||
|
||||
We try not to reinvent the wheel but bring something innovative to the
|
||||
market. As a consequence, we're focused on our own code and use already
|
||||
existing, high-qualitative third-party libraries where possible.
|
||||
existing, high-quality third-party libraries where possible.
|
||||
For the rich set of features that Kivy offers, several other libraries are
|
||||
required. If you do not use a specific feature (e.g. video playback) you
|
||||
don't need the corresponding dependency, however.
|
||||
|
|
Loading…
Reference in New Issue