mirror of https://github.com/kivy/kivy.git
Merge branch 'master' into ios-support
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
This commit is contained in:
commit
63eeeadbbe
1
Makefile
1
Makefile
|
@ -70,6 +70,7 @@ clean:
|
|||
-rm .coverage
|
||||
-rm .noseids
|
||||
-rm -rf kivy/tests/build
|
||||
-find kivy -iname '*.so' -exec rm {} \;
|
||||
-find kivy -iname '*.pyc' -exec rm {} \;
|
||||
-find kivy -iname '*.pyo' -exec rm {} \;
|
||||
|
||||
|
|
11
doc/Makefile
11
doc/Makefile
|
@ -2,7 +2,9 @@
|
|||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
PYTHON = python
|
||||
SPHINXOPTS = -W
|
||||
#SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
|
||||
|
@ -28,12 +30,14 @@ clean:
|
|||
|
||||
html:
|
||||
mkdir -p build/html build/doctrees
|
||||
$(PYTHON) autobuild.py
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in build/html."
|
||||
|
||||
gettext:
|
||||
mkdir -p build/html build/doctrees_gettext
|
||||
$(PYTHON) autobuild.py
|
||||
$(SPHINXBUILD) -b gettext $(ALLSPHINXOPTSGT) build/gettext
|
||||
@echo
|
||||
@echo "Build finished. The Gettext pages are in build/gettext."
|
||||
|
@ -41,6 +45,7 @@ gettext:
|
|||
|
||||
pickle:
|
||||
mkdir -p build/pickle build/doctrees
|
||||
$(PYTHON) autobuild.py
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files or run"
|
||||
|
@ -51,6 +56,7 @@ web: pickle
|
|||
|
||||
htmlhelp:
|
||||
mkdir -p build/htmlhelp build/doctrees
|
||||
$(PYTHON) autobuild.py
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
|
@ -58,6 +64,7 @@ htmlhelp:
|
|||
|
||||
latex:
|
||||
mkdir -p build/latex build/doctrees
|
||||
$(PYTHON) autobuild.py
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in build/latex."
|
||||
|
@ -66,12 +73,14 @@ latex:
|
|||
|
||||
changes:
|
||||
mkdir -p build/changes build/doctrees
|
||||
$(PYTHON) autobuild.py
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
|
||||
@echo
|
||||
@echo "The overview file is in build/changes."
|
||||
|
||||
linkcheck:
|
||||
mkdir -p build/linkcheck build/doctrees
|
||||
$(PYTHON) autobuild.py
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
Kivy - Documentation
|
||||
====================
|
||||
|
||||
You can access to the API documentation on web :
|
||||
You can access the API documentation on web :
|
||||
* last released version : http://kivy.org/docs/api
|
||||
* trunk version, nightly updated : http://kivy.org/docs/api-trunk/
|
||||
* trunk version, updated nightly : http://kivy.org/docs/api-trunk/
|
||||
|
||||
|
||||
How to build the documentation
|
||||
|
@ -13,10 +13,7 @@ You need to install :
|
|||
* Python Sphinx (apt-get install python-sphinx)
|
||||
* Latest kivy
|
||||
|
||||
Run autobuild.py :
|
||||
python autobuild.py
|
||||
|
||||
And generate documentation
|
||||
Generate documentation using make::
|
||||
make html
|
||||
|
||||
Documentation will be accessible in build/html/
|
||||
|
|
|
@ -61,8 +61,13 @@ examples_framework_dir = os.path.join(base_dir, '..', 'examples', 'framework')
|
|||
|
||||
def writefile(filename, data):
|
||||
global dest_dir
|
||||
print 'write', filename
|
||||
# avoid to rewrite the file if the content didn't change
|
||||
f = os.path.join(dest_dir, filename)
|
||||
print 'write', filename
|
||||
if os.path.exists(f):
|
||||
with open(f) as fd:
|
||||
if fd.read() == data:
|
||||
return
|
||||
h = open(f, 'w')
|
||||
h.write(data)
|
||||
h.close()
|
||||
|
|
|
@ -708,3 +708,22 @@ dl.api-level dt {
|
|||
float: left;
|
||||
margin-right: 22px;
|
||||
}
|
||||
|
||||
/** Fix list within dt
|
||||
*/
|
||||
table.field-list dt {
|
||||
margin: 0px;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
table.field-list dl {
|
||||
margin-top: 0px;
|
||||
}
|
||||
table.field-list td.field-body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
table.field-list th.field-name {
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,12 +62,8 @@ release = kivy.__version__
|
|||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of documents that shouldn't be included in the build.
|
||||
#unused_docs = []
|
||||
|
||||
# List of directories, relative to source directories, that shouldn't be searched
|
||||
# for source files.
|
||||
#exclude_dirs = []
|
||||
# suppress exclusion warnings
|
||||
exclude_patterns = ['gettingstarted/*', 'guide/layouts.rst']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
|
|
@ -6,6 +6,7 @@ and why you'd want to use it.
|
|||
It goes on with a discussion of the architecture and shows you how to create
|
||||
stunning applications in short time using the framework.
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
|
|
@ -58,6 +58,30 @@ your contribution won't be forgotten or lost. Also, your name will always be
|
|||
associated with the change you made, which basically means eternal fame in our
|
||||
code history (you can opt-out if you don't want that).
|
||||
|
||||
|
||||
Coding style
|
||||
~~~~~~~~~~~~
|
||||
|
||||
- If you didn't do it yet, read the
|
||||
`PEP8 <http://www.python.org/dev/peps/pep-0008/>`_ about coding style in python.
|
||||
|
||||
- Activate pep8 check on git commit like this::
|
||||
|
||||
make hook
|
||||
|
||||
This will pass the code added to git staging zone (about to be committed)
|
||||
thought a pep8 checker program when you do a commit, and check that you didn't
|
||||
introduce pep8 errors, if so, the commit will be rejected, correct the errors,
|
||||
and try again.
|
||||
|
||||
Performances
|
||||
~~~~~~~~~~~~
|
||||
|
||||
- take care of performance issues, read
|
||||
`Python performance tips <http://wiki.python.org/moin/PythonSpeed/PerformanceTips>`_
|
||||
- cpu intensive parts of Kivy are written in cython, if you are doing a lot of
|
||||
computation, consider using it too.
|
||||
|
||||
Git & GitHub
|
||||
~~~~~~~~~~~~
|
||||
|
||||
|
@ -91,9 +115,12 @@ but the fork you create with the following steps:
|
|||
#. Compile and set up PYTHONPATH or install (see :ref:`dev-install`).
|
||||
#. Install our pre-commit hook that ensures your code doesn't violate our
|
||||
styleguide by executing `make hook` from the root directory of your
|
||||
clone. This will run our styleguide check whenever you do a commit,
|
||||
and if there are violations in the parts that you changed, your commit
|
||||
clone. This will run our styleguide check whenever you do a commit,
|
||||
and if there are violations in the parts that you changed, your commit
|
||||
will be aborted. Fix & retry.
|
||||
#. Add kivy repo as a remote source::
|
||||
|
||||
git remote add kivy https://github.com/kivy/kivy.git
|
||||
|
||||
Now, whenever you want to create a patch, you follow the following steps:
|
||||
|
||||
|
@ -102,7 +129,10 @@ Now, whenever you want to create a patch, you follow the following steps:
|
|||
#. Create a new, appropriately named branch in your local repository for
|
||||
that specific feature or bugfix.
|
||||
(Keeping a new branch per feature makes sure we can easily pull in your
|
||||
changes without pulling any other stuff that is not supposed to be pulled.)
|
||||
changes without pulling any other stuff that is not supposed to be pulled.)::
|
||||
|
||||
git checkout -b new_feature
|
||||
|
||||
#. Modify the code to do what you want (e.g., fix it).
|
||||
#. Test the code. Try to do this even for small fixes. You never know
|
||||
whether you have introduced some weird bug without testing.
|
||||
|
@ -114,8 +144,14 @@ Now, whenever you want to create a patch, you follow the following steps:
|
|||
not familiar with the matter get a good idea of what you changed.
|
||||
#. Once you are satisfied with your changes, merge with our upstream
|
||||
repository. We can pull your stuff, but since you know best what you
|
||||
changed, you should do the merge.
|
||||
#. Push to your remote repository on GitHub.
|
||||
changed, you should do the merge::
|
||||
|
||||
git pull kivy master
|
||||
|
||||
#. Push to your remote repository on GitHub::
|
||||
|
||||
git push
|
||||
|
||||
#. Send a *Pull Request* with a description of what you changed via the button
|
||||
in the GitHub interface of your repository. (This is why we forked
|
||||
initially. Your repository is linked against ours.)
|
||||
|
@ -145,6 +181,75 @@ hassle just to correct a single typo. For more complex contributions, please
|
|||
consider following the suggested workflow though.
|
||||
|
||||
|
||||
Docstrings
|
||||
~~~~~~~~~~
|
||||
|
||||
Every module/class/method/function need a docstring, use the following keyword
|
||||
when relevant
|
||||
|
||||
- ``.. versionadded::`` to mark the version the feature was added.
|
||||
- ``.. versionchanged::`` to mark the version behaviour of the feature was
|
||||
changed.
|
||||
- ``.. note::`` to add additional info about how to use the feature or related
|
||||
feature.
|
||||
- ``.. warning::`` to indicate a potential issue the user might run into using
|
||||
the feature.
|
||||
|
||||
Examples::
|
||||
|
||||
def my_new_feature(self, arg):
|
||||
"""
|
||||
New feature is awesome
|
||||
|
||||
.. versionadded:: 1.1.4
|
||||
|
||||
.. note:: This new feature will likely blow your mind
|
||||
|
||||
.. warning:: Please take a seat before trying this feature
|
||||
"""
|
||||
|
||||
Will result in:
|
||||
|
||||
def my_new_feature(self, arg):
|
||||
"""
|
||||
New feature is awesome
|
||||
|
||||
.. versionadded:: 1.1.4
|
||||
|
||||
.. note:: This new feature will likely blow your mind
|
||||
|
||||
.. warning:: Please take a seat before trying this feature
|
||||
|
||||
"""
|
||||
|
||||
|
||||
When refering to other parts of the api use:
|
||||
|
||||
- ``:mod:`~kivy.module``` to refer to a module
|
||||
- ``:class:`~kivy.module.Class``` to refer to a class
|
||||
- ``:meth:`~kivy.module.Class.method``` to refer to a method
|
||||
- ``:doc:`api-kivy.module``` to refer to the documentation of a module (same
|
||||
for a class and a method)
|
||||
|
||||
Obviously replacing `module` `class` and `method` with their real name, and
|
||||
using using '.' to separate modules refering to imbricated modules, e.g::
|
||||
|
||||
:mod:`~kivy.uix.floatlayout`
|
||||
:class:`~kivy.uix.floatlayout.FloatLayout`
|
||||
:meth:`~kivy.core.window.WindowBase.toggle_fullscreen`
|
||||
:doc:`/api-kivy.core.window`
|
||||
|
||||
Will result in:
|
||||
|
||||
:mod:`~kivy.uix.floatlayout`
|
||||
:class:`~kivy.uix.floatlayout.FloatLayout`
|
||||
:meth:`~kivy.core.window.WindowBase.toggle_fullscreen`
|
||||
:doc:`/api-kivy.core.window`
|
||||
|
||||
`:doc:` and `:mod:` are essentially the same, except for an anchor in the url,
|
||||
this makes `:doc:` prefered, for the cleaner url.
|
||||
|
||||
|
||||
Unit tests contributions
|
||||
------------------------
|
||||
|
||||
|
|
|
@ -6,23 +6,23 @@ Diving in
|
|||
|
||||
To further get into kivy take a look at :doc:`/index`
|
||||
|
||||
Kivy comes with a set of :doc:`examples` in the ``examples`` directory.
|
||||
Kivy comes with a set of :doc:`examples` in the ``kivy_installation/examples`` directory.
|
||||
You should try modifying/improving/adapting them to your needs.
|
||||
|
||||
Browse the `snippet wiki <http://wiki.kivy.org>`_ . You can even add your snippet in the user snippets section.
|
||||
|
||||
Understand the basics about `kivy graphics <http://kivy.org/docs/api-kivy.graphics.html#module-kivy.graphics>`_
|
||||
Understand the basics about :mod:`kivy graphics <kivy.graphics>`
|
||||
|
||||
Take a look at the built-in `widgets <http://kivy.org/docs/api-kivy.uix.html>`_
|
||||
Take a look at the built-in :mod:`widgets <kivy.uix>`
|
||||
|
||||
Follow the `programming guide <http://kivy.org/docs/guide-index.html>`_ to get even more familiar with kivy.
|
||||
Follow the :doc:`/guide-index` to get even more familiar with kivy.
|
||||
|
||||
See how to use different `Modules <http://kivy.org/docs/api-kivy.modules.html>`_ like the Inspector for live inspection in the modules section.
|
||||
See how to use different :mod:`Modules <kivy.modules>` like the Inspector for live inspection in the modules section.
|
||||
|
||||
Learn how to handle custom `Input <http://kivy.org/docs/api-kivy.input.html>`_
|
||||
Learn how to handle custom :mod:`Input <kivy.input>`
|
||||
|
||||
See how kivy has been extended with `extensions <http://kivy.org/docs/api-kivy.ext.html#module-kivy.ext>`_ support.
|
||||
See how kivy has been extended with :mod:`extensions <kivy.ext>` support.
|
||||
|
||||
Familiarize yourself with the `kivy framework <http://kivy.org/docs/api-kivy.html#module-kivy>`_
|
||||
Familiarize yourself with the :mod:`kivy framework <kivy>`
|
||||
|
||||
Kivy is open source so you can **contribute** , take a look at :doc:`/contribute` section to see the guidelines.
|
||||
|
|
|
@ -17,4 +17,4 @@ In both cases the canvas of the MyWidget is re-drawn whenever the ``position`` o
|
|||
|
||||
You can use **canvas.before** or **canvas.after** . This allows you to separate your instructions based on when you want them to happen.
|
||||
|
||||
For an in-depth look at how Kivy's graphics are handled, look `here. <http://kivy.org/docs/api-kivy.graphics.html>`_
|
||||
For an in-depth look at how Kivy's graphics are handled, look :mod:`here. <kivy.graphics>`
|
||||
|
|
|
@ -57,7 +57,7 @@ Going further
|
|||
|
||||
Another thing to note is that if you override an event, you become responsible
|
||||
for implementing all its behaviour previously handled by the base class. The
|
||||
easiest way to do this is to call `super()`: ::
|
||||
easiest way to do this is to call `super()`::
|
||||
|
||||
def on_touch_down(self, touch):
|
||||
if super(OurClassName, self).on_touch_down(touch):
|
||||
|
|
|
@ -58,7 +58,7 @@ Examples
|
|||
.. |tws_dir| replace:: ./examples/frameworks/twisted
|
||||
.. |tws_file| replace:: echo_client_app.py
|
||||
.. |tws_file2| replace:: echo_server_app.py
|
||||
.. |tws_desc| replace:: A clent and server app using `twisted-inside-kivy <http://kivy.org/docs/guide/other-frameworks.html?highlight=twisted#using-twisted-inside-kivy>`__
|
||||
.. |tws_desc| replace:: A clent and server app using :doc:`Twisted inside Kivy </guide/other-frameworks>`
|
||||
|
||||
.. |gst_dir| replace:: ./examples/gestures
|
||||
.. |gst_file| replace:: gesture_board.py
|
||||
|
@ -66,7 +66,7 @@ Examples
|
|||
|
||||
.. |kv_dir| replace:: ./examples/guide/designwithkv
|
||||
.. |kv_file| replace:: main.py
|
||||
.. |kv_desc| replace:: Programming Guide examples on how to `design with kv lang <http://kivy.org/docs/guide/designwithkv.html>`__.
|
||||
.. |kv_desc| replace:: Programming Guide examples on how to :doc:`design with kv lang </guide/designwithkv>`
|
||||
|
||||
.. |fwd_dir| replace:: ./examples/guide/firstwidget
|
||||
.. |fwd_file| replace:: 1_skeleton.py
|
||||
|
@ -75,11 +75,11 @@ Examples
|
|||
.. |fwd_file4| replace:: 4_draw_line.py
|
||||
.. |fwd_file5| replace:: 5_random_colors.py
|
||||
.. |fwd_file6| replace:: 6_button.py
|
||||
.. |fwd_desc| replace:: Programming Guide examples `Your first widget <http://kivy.org/docs/guide/firstwidget.html>`__ .
|
||||
.. |fwd_desc| replace:: Programming Guide examples :doc:`Your first widget </guide/firstwidget>`
|
||||
|
||||
.. |qst_dir| replace:: ./examples/guide/quickstart
|
||||
.. |qst_file| replace:: main.py
|
||||
.. |qst_desc| replace:: Programming Guide `guide/quickstart <http://kivy.org/docs/guide/quickstart.html>`__ example.
|
||||
.. |qst_desc| replace:: Programming Guide :doc:`guide/quickstart </guide/quickstart>` example.
|
||||
|
||||
.. |kin_dir| replace:: ./examples/kinect
|
||||
.. |kin_file| replace:: main.py
|
||||
|
|
|
@ -15,12 +15,12 @@ Non-widget stuff
|
|||
|
||||
.. |atlas_text| replace:: :class:`Atlas <kivy.atlas.Atlas>` is a class for managing texture maps, i.e. packing multiple textures into one image. Using it allows you to reduce the number of images to load and speed up the application start.
|
||||
|
||||
.. |clock_text| replace:: :class:`Clock <kivy.clock.Clock>` provides you with a convenient way to do jobs at set time intervals and is preferred over *sleep()* which would block the kivy Event Loop. These intervals can be set relative to the OpenGL Drawing instructions, :ref:`before <schedule-before-frame>` or :ref:`after <schedule-after-frame>` frame. Clock also provides you with a way to create :ref:`triggered events <triggered-events>` that are grouped together and only called once before the next frame.
|
||||
.. |clock_text| replace:: :class:`Clock <kivy.clock.Clock>` provides you with a convenient way to do jobs at set time intervals and is preferred over *sleep()* which would block the kivy Event Loop. These intervals can be set relative to the OpenGL Drawing instructions, :ref:`before <schedule-before-frame>` or :ref:`after <schedule-before-frame>` frame. Clock also provides you with a way to create :ref:`triggered events <triggered-events>` that are grouped together and only called once before the next frame.
|
||||
|
||||
.. |sched_once| replace:: `Clock.schedule_once <http://kivy.org/docs/api-kivy.clock.html?highlight=clock#kivy.clock.ClockBase.schedule_once>`__
|
||||
.. |sched_intrvl| replace:: `Clock.schedule_interval <http://kivy.org/docs/api-kivy.clock.html?highlight=clock#kivy.clock.ClockBase.schedule_interval>`__
|
||||
.. |unsched| replace:: `Clock.unschedule <http://kivy.org/docs/api-kivy.clock.html?highlight=clock#kivy.clock.ClockBase.unschedule>`__
|
||||
.. |trigger| replace:: `Clock.create_trigger <http://kivy.org/docs/api-kivy.clock.html?highlight=clock#kivy.clock.ClockBase.create_trigger>`__
|
||||
.. |sched_once| replace:: :meth:`~kivy.clock.ClockBase.schedule_once`
|
||||
.. |sched_intrvl| replace:: :meth:`~kivy.clock.ClockBase.schedule_interval`
|
||||
.. |unsched| replace:: :meth:`~kivy.clock.ClockBase.unschedule`
|
||||
.. |trigger| replace:: :meth:`~kivy.clock.ClockBase.create_trigger`
|
||||
.. |urlreq| replace:: :class:`UrlRequest <kivy.network.urlrequest.UrlRequest>` is useful to do asynchronous requests without blocking the event loop, and manage the result and progress with callbacks.
|
||||
|
||||
+------------------+------------------+
|
||||
|
|
|
@ -5,11 +5,12 @@ Layouts
|
|||
|
||||
Arranging Your Widgets
|
||||
|
||||
Layouts are used to arrange widgets in a perticular manner. ::
|
||||
Layouts are used to arrange widgets in a perticular manner::
|
||||
|
||||
AnchorLayout: widgets can be anchored to 'top', 'bottom', 'left', 'right', 'center'
|
||||
BoxLayout: widgets are arranged in a box in either 'vertical' or 'horizontal' orientation
|
||||
FloatLayout: Widgets are essentially unrestricted
|
||||
RelativeLayout: Child widgets are positioned relative to the layout.
|
||||
GridLayout: widgets are arranged in a grid defined by `rows` and `cols` properties
|
||||
StackLayout: widgets are stacked in `lr-tb` (left to right then top to bottom) or `tb-lr` order
|
||||
|
||||
|
@ -20,8 +21,9 @@ size_hint and pos_hint are used to calculate widget's size and position only if
|
|||
However one can set these to None and provide direct values in screen coordinates.
|
||||
|
||||
For a detailed look at how you can arrange widgets using layouts look in
|
||||
`AnchorLayout <http://kivy.org/docs/api-kivy.uix.anchorlayout.html>`_
|
||||
`BoxLayout <http://kivy.org/docs/api-kivy.uix.boxlayout.html>`_
|
||||
`FloatLayout <http://kivy.org/docs/api-kivy.uix.floatlayout.html>`_
|
||||
`GridLayout <http://kivy.org/docs/api-kivy.uix.gridlayout.html>`_
|
||||
`StackLayout <http://kivy.org/docs/api-kivy.uix.stacklayout.html>`_
|
||||
:mod:`AnchorLayout <kivy.uix.anchorlayout>`
|
||||
:mod:`BoxLayout <kivy.uix.boxlayout>`
|
||||
:mod:`FloatLayout <kivy.uix.floatlayout>`
|
||||
:mod:`GridLayout <kivy.uix.gridlayout>`
|
||||
:mod:`StackLayout <kivy.uix.stacklayout>`
|
||||
:mod:`RelativeLayout <kivy.uix.relativelayout>`
|
||||
|
|
|
@ -33,15 +33,15 @@ provides an ``on_<propertyname>`` event that is called whenever the property's
|
|||
state/value changes .
|
||||
|
||||
Kivy provides the following properties:
|
||||
`NumericProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.NumericProperty>`_,
|
||||
`StringProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.StringProperty>`_,
|
||||
`ListProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.ListProperty>`_,
|
||||
`ObjectProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.ObjectProperty>`_,
|
||||
`BooleanProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.BooleanProperty>`_,
|
||||
`BoundedNumericProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.BoundedNumericProperty>`_,
|
||||
`OptionProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.OptionProperty>`_,
|
||||
`ReferenceListProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.ReferenceListProperty>`_,
|
||||
`AliasProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.AliasProperty>`_,
|
||||
`DictProperty <http://kivy.org/docs/api-kivy.properties.html?highlight=properties#kivy.properties.DictProperty>`_,
|
||||
:mod:`~kivy.properties.NumericProperty`,
|
||||
:mod:`~kivy.properties.StringProperty`,
|
||||
:mod:`~kivy.properties.ListProperty`,
|
||||
:mod:`~kivy.properties.ObjectProperty`,
|
||||
:mod:`~kivy.properties.BooleanProperty`,
|
||||
:mod:`~kivy.properties.BoundedNumericProperty`,
|
||||
:mod:`~kivy.properties.OptionProperty`,
|
||||
:mod:`~kivy.properties.ReferenceListProperty`,
|
||||
:mod:`~kivy.properties.AliasProperty`,
|
||||
:mod:`~kivy.properties.DictProperty`,
|
||||
|
||||
For an in-depth explaination, look at :doc:`/api-kivy.properties`
|
||||
|
|
|
@ -17,4 +17,3 @@ Programming Guide
|
|||
guide/designwithkv
|
||||
guide/other-frameworks
|
||||
guide/packaging
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ Input management
|
|||
================
|
||||
|
||||
Input architecture
|
||||
-----------------
|
||||
------------------
|
||||
|
||||
Kivy is able to handle most types of input: mouse, touchscreen, accelerometer,
|
||||
gyroscope, etc. It handles the native multitouch protocols on the following
|
||||
|
@ -96,7 +96,7 @@ profile exists::
|
|||
if 'angle' in touch.profile:
|
||||
print 'The touch angle is', touch.a
|
||||
|
||||
You can find a list of available profiles in the :doc:`api-kivy.input.motionevent`
|
||||
You can find a list of available profiles in the :mod:`api-kivy.input.motionevent`
|
||||
documentation.
|
||||
|
||||
Touch events
|
||||
|
|
|
@ -25,8 +25,9 @@ BoxLayout:
|
|||
.. image:: ../images/boxlayout.gif
|
||||
|
||||
GridLayout:
|
||||
Arrange widgets in a grid, you must specifiy at least one dimension of the
|
||||
grid, so kivy can comput size of the elements and how to arrange them
|
||||
Arrange widgets in a grid. You must specifiy at least one dimension of the
|
||||
grid so kivy can compute the size of the elements and how to arrange them.
|
||||
|
||||
`pos_hint` not honored
|
||||
|
||||
.. image:: ../images/gridlayout.gif
|
||||
|
|
|
@ -4,13 +4,9 @@ Create a package for Android
|
|||
============================
|
||||
|
||||
.. versionchanged:: 1.1.0
|
||||
|
||||
Starting from 1.1.0, we are not providing anymore a Kivy-XXX-android.zip.
|
||||
We are using `python-for-android <http://https://github.com/kivy/python-for-android>`_
|
||||
project.
|
||||
|
||||
The whole packaging is explained at
|
||||
`http://python-for-android.readthedocs.org/en/latest/index.html`_
|
||||
Kivy-XXX-android.zip is not provided anymore. We are using
|
||||
`python-for-android <http://github.com/kivy/python-for-android>`_
|
||||
(`doc <http://python-for-android.readthedocs.org/en/latest/index.html>`_)
|
||||
|
||||
Packaging your application into APK
|
||||
-----------------------------------
|
||||
|
|
|
@ -102,6 +102,17 @@ development):
|
|||
FAQ
|
||||
---
|
||||
|
||||
Application quit abnormally!
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
By default, all the print on the console and files are avoided. If you have an
|
||||
issue when running your application, you can activate the log by commenting the
|
||||
line in the main.m::
|
||||
|
||||
putenv("KIVY_NO_CONSOLELOG=1");
|
||||
|
||||
Then, you should see all the Kivy log on the Xcode console.
|
||||
|
||||
How Apple can accept a python app ?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -112,5 +123,7 @@ dynamically loaded.
|
|||
Did you already submit a Kivy application to the App store ?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Yes, check `Defletouch on iTunes <http://itunes.apple.com/us/app/deflectouch/id505729681>`_
|
||||
Yes, check:
|
||||
|
||||
- `Defletouch on iTunes <http://itunes.apple.com/us/app/deflectouch/id505729681>`_,
|
||||
- `ProcessCraft on iTunes <http://itunes.apple.com/us/app/processcraft/id526377075>`_
|
||||
|
|
|
@ -11,3 +11,4 @@ Packaging your application
|
|||
packaging-android
|
||||
packaging-ios
|
||||
|
||||
android
|
||||
|
|
|
@ -54,7 +54,7 @@ Traversing the tree
|
|||
-------------------
|
||||
|
||||
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 ::
|
||||
that contains all the children. You can easily traverse the tree by doing::
|
||||
|
||||
root = BoxLayout()
|
||||
# ... add widgets to root ...
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
|
@ -1,5 +1,6 @@
|
|||
:orphan:
|
||||
|
||||
|
||||
Welcome to Kivy
|
||||
===============
|
||||
|
||||
|
@ -19,6 +20,28 @@ concern isn't addressed in the documentation, feel free to :ref:`contact`.
|
|||
|
||||
.. include:: contents.rst.inc
|
||||
|
||||
.. Suppress warnings about documents not being included in toc, but don't
|
||||
actually show them.
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
api-index
|
||||
api-kivy.lib.osc.OSC
|
||||
api-kivy.lib.osc.oscAPI
|
||||
.. gettingstarted/diving
|
||||
gettingstarted/drawing
|
||||
gettingstarted/events
|
||||
gettingstarted/examples
|
||||
gettingstarted/first_app
|
||||
gettingstarted/framework
|
||||
gettingstarted/installation
|
||||
gettingstarted/intro
|
||||
gettingstarted/layouts
|
||||
gettingstarted/packaging
|
||||
gettingstarted/properties
|
||||
gettingstarted/rules
|
||||
guide/layouts
|
||||
|
||||
|
||||
Appendix
|
||||
========
|
||||
|
|
|
@ -141,7 +141,7 @@ Uninstalling Kivy
|
|||
If you are mixing multiple Kivy installations, you might be confused about where each Kivy version is
|
||||
located. Please note that you might need to follow these steps multiple times, if you have multiple kivy versions
|
||||
installed in the Python library path.
|
||||
To find your current installed version, you can use the command line: ::
|
||||
To find your current installed version, you can use the command line::
|
||||
|
||||
$ python -c 'import kivy; print kivy.__path__'
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ def callback_docstring(app, what, name, obj, options, lines):
|
|||
line = lines.pop(0)
|
||||
|
||||
# trick to realign the first line to the second one.
|
||||
# FIXME: fail if we finishing with ::
|
||||
# FIXME: fail if we finishing with::
|
||||
line_with_text = [x for x in lines if len(x.strip())]
|
||||
if len(line_with_text) and line is not None and len(lines):
|
||||
l = len(line_with_text[0]) - len(line_with_text[0].lstrip())
|
||||
|
|
|
@ -32,6 +32,5 @@ class TestApp(App):
|
|||
button.bind(on_press=self.animate)
|
||||
return button
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
TestApp().run()
|
||||
|
||||
|
|
|
@ -57,5 +57,5 @@ class AudioApp(App):
|
|||
|
||||
return root
|
||||
|
||||
if __name__ in ('__android__', '__main__'):
|
||||
if __name__ == '__main__':
|
||||
AudioApp().run()
|
||||
|
|
|
@ -53,6 +53,6 @@ class PicturesApp(App):
|
|||
return True
|
||||
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
PicturesApp().run()
|
||||
|
||||
|
|
|
@ -108,5 +108,5 @@ class ShaderEditorApp(App):
|
|||
def build(self):
|
||||
return ShaderEditor()
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
ShaderEditorApp().run()
|
||||
|
|
|
@ -277,5 +277,5 @@ class ShowcaseApp(App):
|
|||
tv.add_node(TreeViewLabel(text='Subitem %d' % x), n)
|
||||
return tv
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
ShowcaseApp().run()
|
||||
|
|
|
@ -255,41 +255,48 @@
|
|||
TextInput:
|
||||
text: 'Monoline textinput'
|
||||
size_hint_y: None
|
||||
height: 50
|
||||
height: 30
|
||||
|
||||
TextInput:
|
||||
text: 'This is a password'
|
||||
size_hint_y: None
|
||||
height: 50
|
||||
height: 30
|
||||
password: True
|
||||
|
||||
TextInput:
|
||||
text: 'Readonly textinput'
|
||||
size_hint_y: None
|
||||
height: 50
|
||||
height: 30
|
||||
readonly: True
|
||||
|
||||
TextInput:
|
||||
text: 'Multiline textinput\nSecond line'
|
||||
|
||||
HSeparator:
|
||||
text: 'Spinner'
|
||||
|
||||
Spinner:
|
||||
size_hint_y: None
|
||||
height: 44
|
||||
values: ('Work', 'Home', 'Other', 'Custom')
|
||||
text: 'Home'
|
||||
|
||||
HSeparator:
|
||||
text: 'Checkbox'
|
||||
|
||||
GridLayout:
|
||||
rows: 1
|
||||
CheckBox
|
||||
CheckBox:
|
||||
active: True
|
||||
CheckBox
|
||||
|
||||
GridLayout:
|
||||
cols: 2
|
||||
CheckBox:
|
||||
group: 'group1'
|
||||
active: True
|
||||
CheckBox:
|
||||
group: 'group1'
|
||||
CheckBox:
|
||||
group: 'group2'
|
||||
CheckBox:
|
||||
group: 'group2'
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -98,5 +98,5 @@ class TouchtracerApp(App):
|
|||
def on_pause(self):
|
||||
return True
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
TouchtracerApp().run()
|
||||
|
|
|
@ -24,5 +24,5 @@ class ControllerApp(App):
|
|||
def build(self):
|
||||
return Controller(info='Hello world')
|
||||
|
||||
if __name__ in ('__android__', '__main__'):
|
||||
if __name__ == '__main__':
|
||||
ControllerApp().run()
|
||||
|
|
|
@ -10,5 +10,5 @@ class MyApp(App):
|
|||
def build(self):
|
||||
return Button(text='Hello World')
|
||||
|
||||
if __name__ in ('__android__', '__main__'):
|
||||
if __name__ == '__main__':
|
||||
MyApp().run()
|
||||
|
|
|
@ -201,5 +201,5 @@ class ShaderTreeApp(App):
|
|||
root.add_widget(btn)
|
||||
return root
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
ShaderTreeApp().run()
|
||||
|
|
|
@ -80,5 +80,5 @@ class PongApp(App):
|
|||
|
||||
|
||||
|
||||
if __name__ in ('__android__', '__main__'):
|
||||
if __name__ == '__main__':
|
||||
PongApp().run()
|
||||
|
|
|
@ -9,5 +9,5 @@ class PongApp(App):
|
|||
def build(self):
|
||||
return PongGame()
|
||||
|
||||
if __name__ in ('__android__', '__main__'):
|
||||
if __name__ == '__main__':
|
||||
PongApp().run()
|
||||
|
|
|
@ -9,5 +9,5 @@ class PongApp(App):
|
|||
def build(self):
|
||||
return PongGame()
|
||||
|
||||
if __name__ in ('__android__', '__main__'):
|
||||
if __name__ == '__main__':
|
||||
PongApp().run()
|
||||
|
|
|
@ -24,5 +24,5 @@ class PongApp(App):
|
|||
|
||||
|
||||
Factory.register("PongBall", PongBall)
|
||||
if __name__ in ('__android__', '__main__'):
|
||||
if __name__ == '__main__':
|
||||
PongApp().run()
|
||||
|
|
|
@ -44,5 +44,5 @@ class PongApp(App):
|
|||
|
||||
|
||||
Factory.register("PongBall", PongBall)
|
||||
if __name__ in ('__android__', '__main__'):
|
||||
if __name__ == '__main__':
|
||||
PongApp().run()
|
||||
|
|
|
@ -79,5 +79,5 @@ class PongApp(App):
|
|||
|
||||
|
||||
|
||||
if __name__ in ('__android__', '__main__'):
|
||||
if __name__ == '__main__':
|
||||
PongApp().run()
|
||||
|
|
|
@ -29,5 +29,5 @@ class TestAsyncApp(App):
|
|||
return CenteredAsyncImage(
|
||||
source='http://icanhascheezburger.files.wordpress.com/2009/12/funny-pictures-cat-is-expecting-you.jpg')
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
TestAsyncApp().run()
|
||||
|
|
|
@ -56,5 +56,5 @@ class TestBubbleApp(App):
|
|||
def build(self):
|
||||
return BubbleShowcase()
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
TestBubbleApp().run()
|
||||
|
|
|
@ -25,5 +25,5 @@ class LabelMipmapTest(App):
|
|||
s.add_widget(l2)
|
||||
return s
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
LabelMipmapTest().run()
|
||||
|
|
|
@ -22,5 +22,5 @@ class LabelMipmapTest(App):
|
|||
s.add_widget(l2)
|
||||
return s
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
LabelMipmapTest().run()
|
||||
|
|
|
@ -143,5 +143,5 @@ class mainApp(App):
|
|||
return upl
|
||||
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
mainApp().run()
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
from kivy.uix.spinner import Spinner
|
||||
from kivy.base import runTouchApp
|
||||
|
||||
spinner = Spinner(
|
||||
text='Home',
|
||||
values=('Home', 'Work', 'Other', 'Custom'),
|
||||
size_hint=(None, None), size=(100, 44),
|
||||
pos_hint={'center_x': .5, 'center_y': .5})
|
||||
|
||||
def show_selected_value(spinner, text):
|
||||
print 'The spinner', spinner, 'have text', text
|
||||
|
||||
spinner.bind(text=show_selected_value)
|
||||
|
||||
runTouchApp(spinner)
|
|
@ -330,5 +330,5 @@ class TestTabApp(App):
|
|||
def build(self):
|
||||
return TabShowcase()
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
TestTabApp().run()
|
||||
|
|
|
@ -18,5 +18,5 @@ class VideoPlayerApp(App):
|
|||
return VideoPlayer(source=filename, play=True)
|
||||
|
||||
|
||||
if __name__ in ('__main__', '__android__'):
|
||||
if __name__ == '__main__':
|
||||
VideoPlayerApp().run()
|
||||
|
|
|
@ -24,7 +24,7 @@ __all__ = (
|
|||
'kivy_configure', 'kivy_register_post_configuration',
|
||||
'kivy_options', 'kivy_base_dir',
|
||||
'kivy_modules_dir', 'kivy_data_dir', 'kivy_shader_dir',
|
||||
'kivy_icons_dir', 'kivy_home_dir',
|
||||
'kivy_icons_dir', 'kivy_home_dir', 'kivy_userexts_dir',
|
||||
'kivy_config_fn', 'kivy_usermodules_dir',
|
||||
)
|
||||
|
||||
|
@ -145,7 +145,7 @@ def kivy_register_post_configuration(callback):
|
|||
|
||||
|
||||
def kivy_usage():
|
||||
'''Kivy Usage: %s [OPTION...] ::
|
||||
'''Kivy Usage: %s [OPTION...]::
|
||||
|
||||
-h, --help
|
||||
Prints this help message.
|
||||
|
@ -226,20 +226,24 @@ kivy_shader_dir = join(kivy_data_dir, 'glsl')
|
|||
#: Kivy icons config path (don't remove the last '')
|
||||
kivy_icons_dir = join(kivy_data_dir, 'icons', '')
|
||||
#: Kivy user-home storage directory
|
||||
kivy_home_dir = None
|
||||
kivy_home_dir = ''
|
||||
#: Kivy configuration filename
|
||||
kivy_config_fn = None
|
||||
kivy_config_fn = ''
|
||||
#: Kivy user modules directory
|
||||
kivy_usermodules_dir = None
|
||||
kivy_usermodules_dir = ''
|
||||
#: Kivy user extensions directory
|
||||
kivy_userexts_dir = ''
|
||||
|
||||
|
||||
# Don't go further if we generate documentation
|
||||
if basename(sys.argv[0]) in ('sphinx-build', 'autobuild.py'):
|
||||
if any(name in sys.argv[0] for name in ('sphinx-build', 'autobuild.py')):
|
||||
environ['KIVY_DOC'] = '1'
|
||||
if basename(sys.argv[0]) in ('sphinx-build', ):
|
||||
if 'sphinx-build' in sys.argv[0]:
|
||||
environ['KIVY_DOC_INCLUDE'] = '1'
|
||||
if basename(sys.argv[0]) in ('nosetests', ) or 'nosetests' in sys.argv:
|
||||
if any('nosetests' in arg for arg in sys.argv):
|
||||
environ['KIVY_UNITTEST'] = '1'
|
||||
if not 'KIVY_DOC_INCLUDE' in environ:
|
||||
|
||||
if not environ.get('KIVY_DOC_INCLUDE'):
|
||||
# Configuration management
|
||||
user_home_dir = expanduser('~')
|
||||
if platform() == 'android':
|
||||
|
|
|
@ -6,9 +6,7 @@ All objects that produce events in Kivy implement :class:`EventDispatcher`,
|
|||
providing a consistent interface for registering and manipulating event
|
||||
handlers.
|
||||
|
||||
|
||||
.. versionchanged:: 1.0.9
|
||||
|
||||
Properties discovering and methods have been moved from
|
||||
:class:`~kivy.uix.widget.Widget` to :class:`EventDispatcher`
|
||||
|
||||
|
|
|
@ -69,10 +69,6 @@ from kivy.clock import Clock
|
|||
class Animation(EventDispatcher):
|
||||
'''Create an animation definition that can be used to animate a Widget
|
||||
|
||||
.. versionchanged:: 1.4.0
|
||||
|
||||
Added s/step parameter.
|
||||
|
||||
:Parameters:
|
||||
`duration` or `d`: float, default to 1.
|
||||
Duration of the animation, in seconds
|
||||
|
@ -89,6 +85,10 @@ class Animation(EventDispatcher):
|
|||
Fired when the animation is completed or stopped on a widget
|
||||
`on_progress`: widget, progression
|
||||
Fired when the progression of the animation is changing
|
||||
|
||||
.. versionchanged:: 1.4.0
|
||||
Added s/step parameter.
|
||||
|
||||
'''
|
||||
|
||||
_instances = set()
|
||||
|
@ -136,7 +136,7 @@ class Animation(EventDispatcher):
|
|||
'''Stop all animations that concern a specific widget / list of
|
||||
properties.
|
||||
|
||||
Example ::
|
||||
Example::
|
||||
|
||||
anim = Animation(x=50)
|
||||
anim.start(widget)
|
||||
|
|
|
@ -151,7 +151,7 @@ However, you might want to know when a config value has been changed by the
|
|||
user, in order to adapt or reload your UI. You can overload the
|
||||
:meth:`on_config_change` method::
|
||||
|
||||
class TestApp(self):
|
||||
class TestApp(App):
|
||||
# ...
|
||||
def on_config_change(self, config, section, key, value):
|
||||
if config is self.config:
|
||||
|
@ -309,7 +309,7 @@ class App(EventDispatcher):
|
|||
widget and added to the window.
|
||||
|
||||
:return: None or a root :class:`~kivy.uix.widget.Widget` instance is no
|
||||
self.root exist.
|
||||
self.root exist.
|
||||
'''
|
||||
if not self.root:
|
||||
return Widget()
|
||||
|
@ -370,6 +370,8 @@ class App(EventDispatcher):
|
|||
'''
|
||||
try:
|
||||
default_kv_directory = dirname(getfile(self.__class__))
|
||||
if default_kv_directory == '':
|
||||
default_kv_directory = '.'
|
||||
except TypeError:
|
||||
# if it's a builtin module.. use the current dir.
|
||||
default_kv_directory = '.'
|
||||
|
@ -408,7 +410,6 @@ class App(EventDispatcher):
|
|||
'''.. versionadded:: 1.0.7
|
||||
|
||||
.. versionchanged:: 1.4.0
|
||||
|
||||
Customize the default path for iOS and Android platform. Add
|
||||
defaultpath parameter for desktop computer (not applicatable for iOS
|
||||
and Android.)
|
||||
|
@ -492,6 +493,8 @@ class App(EventDispatcher):
|
|||
if self._app_directory is None:
|
||||
try:
|
||||
self._app_directory = dirname(getfile(self.__class__))
|
||||
if self._app_directory == '':
|
||||
self._app_directory = '.'
|
||||
except TypeError:
|
||||
# if it's a builtin module.. use the current dir.
|
||||
self._app_directory = '.'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# pylint: disable=W0611
|
||||
'''
|
||||
Event loop management
|
||||
=====================
|
||||
|
@ -25,7 +26,7 @@ EventLoop = None
|
|||
|
||||
class ExceptionHandler:
|
||||
'''Base handler that catch exception in runTouchApp().
|
||||
You can derivate and use it like this ::
|
||||
You can derivate and use it like this::
|
||||
|
||||
class E(ExceptionHandler):
|
||||
def handle_exception(self, inst):
|
||||
|
@ -105,7 +106,7 @@ class EventLoopBase(EventDispatcher):
|
|||
def ensure_window(self):
|
||||
'''Ensure that we have an window
|
||||
'''
|
||||
__import__('kivy.core.window')
|
||||
import kivy.core.window
|
||||
|
||||
def set_window(self, window):
|
||||
'''Set the window used for event loop
|
||||
|
|
|
@ -3,7 +3,7 @@ Clock object
|
|||
============
|
||||
|
||||
The :class:`Clock` object allows you to schedule a function call in the
|
||||
future; once or on interval. ::
|
||||
future; once or on interval::
|
||||
|
||||
def my_callback(dt):
|
||||
pass
|
||||
|
@ -59,6 +59,8 @@ module::
|
|||
|
||||
# and keep the instance of foo, until you don't need it anymore!
|
||||
|
||||
.. _schedule-before-frame:
|
||||
|
||||
Schedule before frame
|
||||
---------------------
|
||||
|
||||
|
@ -85,6 +87,8 @@ If you need to increase the limit, set the :data:`max_iteration` property::
|
|||
from kivy.clock import Clock
|
||||
Clock.max_iteration = 20
|
||||
|
||||
.. _triggered-events:
|
||||
|
||||
Triggered Events
|
||||
----------------
|
||||
|
||||
|
@ -93,7 +97,7 @@ Triggered Events
|
|||
A triggered event is a way to defer a callback exactly like schedule_once(),
|
||||
but with some added convenience. The callback will only be scheduled once per
|
||||
frame, even if you call the trigger twice (or more). This is not the case
|
||||
with :func:`Clock.schedule_once` ::
|
||||
with :func:`Clock.schedule_once`::
|
||||
|
||||
# will run the callback twice before the next frame
|
||||
Clock.schedule_once(my_callback)
|
||||
|
@ -104,7 +108,7 @@ with :func:`Clock.schedule_once` ::
|
|||
t()
|
||||
t()
|
||||
|
||||
Before triggered events, you may have used this approach in a widget ::
|
||||
Before triggered events, you may have used this approach in a widget::
|
||||
|
||||
def trigger_callback(self, *largs):
|
||||
Clock.unschedule(self.callback)
|
||||
|
@ -112,7 +116,7 @@ Before triggered events, you may have used this approach in a widget ::
|
|||
|
||||
As soon as you call `trigger_callback()`, it will correctly schedule the
|
||||
callback once in the next frame. It is more convenient to create and bind to
|
||||
the triggered event than using :func:`Clock.schedule_once` in a function ::
|
||||
the triggered event than using :func:`Clock.schedule_once` in a function::
|
||||
|
||||
from kivy.clock import Clock
|
||||
from kivy.uix.widget import Widget
|
||||
|
@ -353,7 +357,6 @@ class ClockBase(object):
|
|||
'''Schedule an event in <timeout> seconds.
|
||||
|
||||
.. versionchanged:: 1.0.5
|
||||
|
||||
If the timeout is -1, the callback will be called before the next
|
||||
frame (at :func:`tick_draw`).
|
||||
|
||||
|
|
|
@ -23,24 +23,6 @@ Change the configuration and save it::
|
|||
Available configuration tokens
|
||||
------------------------------
|
||||
|
||||
.. versionchanged:: 1.0.8
|
||||
|
||||
* `scroll_timeout`, `scroll_distance` and `scroll_friction` have been added
|
||||
* `list_friction`, `list_trigger_distance` and `list_friction_bound` have
|
||||
been removed.
|
||||
* `keyboard_type` and `keyboard_layout` have been removed from widget
|
||||
* `keyboard_mode` and `keyboard_layout` have been added to kivy section
|
||||
|
||||
.. versionchanged:: 1.1.0
|
||||
|
||||
* tuio is not listening by default anymore.
|
||||
* windows icons are not copied to user directory anymore. You can still set
|
||||
a new window icon by using ``window_icon`` config setting.
|
||||
|
||||
.. versionchanged:: 1.2.0
|
||||
|
||||
* `resizable` has been added to graphics section
|
||||
|
||||
:kivy:
|
||||
|
||||
`log_level`: (debug, info, warning, error, critical)
|
||||
|
@ -164,6 +146,21 @@ Available configuration tokens
|
|||
|
||||
Anything after the = will be passed to the module as arguments.
|
||||
Check the specific module's documentation for a list of accepted arguments.
|
||||
|
||||
.. versionchanged:: 1.2.0
|
||||
`resizable` has been added to graphics section
|
||||
|
||||
.. versionchanged:: 1.1.0
|
||||
tuio is not listening by default anymore. windows icons are not copied to
|
||||
user directory anymore. You can still set a new window icon by using
|
||||
``window_icon`` config setting.
|
||||
|
||||
.. versionchanged:: 1.0.8
|
||||
`scroll_timeout`, `scroll_distance` and `scroll_friction` have been added.
|
||||
`list_friction`, `list_trigger_distance` and `list_friction_bound` have been
|
||||
removed. `keyboard_type` and `keyboard_layout` have been removed from
|
||||
widget. `keyboard_mode` and `keyboard_layout` have been added to kivy
|
||||
section.
|
||||
'''
|
||||
|
||||
__all__ = ('Config', 'ConfigParser')
|
||||
|
@ -258,7 +255,7 @@ class ConfigParser(PythonConfigParser):
|
|||
return True
|
||||
|
||||
|
||||
if not 'KIVY_DOC_INCLUDE' in environ:
|
||||
if not environ.get('KIVY_DOC_INCLUDE'):
|
||||
|
||||
#
|
||||
# Read, analyse configuration file
|
||||
|
|
|
@ -10,9 +10,9 @@ from kivy.core.audio import Sound, SoundLoader
|
|||
|
||||
try:
|
||||
if platform() == 'android':
|
||||
mixer = __import__('android_mixer')
|
||||
import android_mixer as mixer
|
||||
else:
|
||||
mixer = __import__('pygame.mixer', fromlist='.')
|
||||
from pygame import mixer
|
||||
except:
|
||||
raise
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@ from kivy.graphics.texture import Texture
|
|||
from kivy.core.camera import CameraBase
|
||||
|
||||
try:
|
||||
cv = __import__('opencv', fromlist='.')
|
||||
hg = __import__('opencv.highgui', fromlist='.')
|
||||
import opencv as cv
|
||||
import opencv.highgui as hg
|
||||
except ImportError:
|
||||
cv = __import__('cv')
|
||||
import cv
|
||||
|
||||
class Hg(object):
|
||||
'''
|
||||
|
|
|
@ -5,23 +5,23 @@ Clipboard
|
|||
Core class for accessing to the Clipboard. If we are not able to access to the
|
||||
system clipboard, a fake one will be used.
|
||||
|
||||
Usage example (i have copied 'Hello World' somewhere else)::
|
||||
Usage example::
|
||||
|
||||
>>> from kivy.core.clipboard import Clipboard
|
||||
>>> Clipboard.get_types()
|
||||
['TIMESTAMP', 'TARGETS', 'MULTIPLE', 'SAVE_TARGETS', 'UTF8_STRING',
|
||||
'COMPOUND_TEXT', 'TEXT', 'STRING', 'text/plain;charset=utf-8',
|
||||
'text/plain']
|
||||
>>> Clipboard.get('TEXT')
|
||||
'Hello World'
|
||||
>>> Clipboard.put('Great', 'UTF8_STRING')
|
||||
>>> Clipboard.get_types()
|
||||
['UTF8_STRING']
|
||||
>>> Clipboard.get('UTF8_STRING')
|
||||
'Great'
|
||||
>>> Clipboard.get('TEXT')
|
||||
'Hello World'
|
||||
>>> Clipboard.put('Great', 'UTF8_STRING')
|
||||
>>> Clipboard.get_types()
|
||||
['UTF8_STRING']
|
||||
>>> Clipboard.get('UTF8_STRING')
|
||||
'Great'
|
||||
|
||||
Note that the main implementation rely on Pygame, and works great with
|
||||
text/string. Anything else might not work the same on all platform.
|
||||
.. note:: The main implementation rely on Pygame, and works great with
|
||||
text/string. Anything else might not work the same on all platform.
|
||||
'''
|
||||
|
||||
__all__ = ('ClipboardBase', 'Clipboard')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# pylint: disable=W0611
|
||||
'''
|
||||
OpenGL
|
||||
======
|
||||
|
@ -49,4 +50,4 @@ if 'KIVY_DOC' not in environ:
|
|||
|
||||
# To be able to use our GL provider, we must have a window
|
||||
# Automaticly import window auto to ensure the default window creation
|
||||
__import__('kivy.core.window')
|
||||
import kivy.core.window
|
||||
|
|
|
@ -23,9 +23,9 @@ from kivy.resources import resource_find
|
|||
from kivy.utils import platform
|
||||
import zipfile
|
||||
try:
|
||||
SIO = __import__('cStringIO')
|
||||
import cStringIO as SIO
|
||||
except ImportError:
|
||||
SIO = __import__('StringIO')
|
||||
import StringIO as SIO
|
||||
|
||||
|
||||
# late binding
|
||||
|
@ -137,11 +137,12 @@ class ImageLoaderBase(object):
|
|||
'''Base to implement an image loader.'''
|
||||
|
||||
__slots__ = ('_texture', '_data', 'filename', 'keep_data',
|
||||
'_mipmap')
|
||||
'_mipmap', '_nocache')
|
||||
|
||||
def __init__(self, filename, **kwargs):
|
||||
self._mipmap = kwargs.get('mipmap', False)
|
||||
self.keep_data = kwargs.get('keep_data', False)
|
||||
self._nocache = kwargs.get('nocache', False)
|
||||
self.filename = filename
|
||||
self._data = self.load(filename)
|
||||
self._textures = None
|
||||
|
@ -167,7 +168,8 @@ class ImageLoaderBase(object):
|
|||
if texture is None:
|
||||
texture = Texture.create_from_data(
|
||||
self._data[count], mipmap=self._mipmap)
|
||||
Cache.append('kv.texture', uid, texture)
|
||||
if not self._nocache:
|
||||
Cache.append('kv.texture', uid, texture)
|
||||
|
||||
# set as our current texture
|
||||
self._textures.append(texture)
|
||||
|
@ -364,7 +366,7 @@ class Image(EventDispatcher):
|
|||
'''
|
||||
|
||||
copy_attributes = ('_size', '_filename', '_texture', '_image',
|
||||
'_mipmap')
|
||||
'_mipmap', '_nocache')
|
||||
|
||||
def __init__(self, arg, **kwargs):
|
||||
# this event should be fired on animation of sequenced img's
|
||||
|
@ -374,6 +376,7 @@ class Image(EventDispatcher):
|
|||
|
||||
self._mipmap = kwargs.get('mipmap', False)
|
||||
self._keep_data = kwargs.get('keep_data', False)
|
||||
self._nocache = kwargs.get('nocache', False)
|
||||
self._size = [0, 0]
|
||||
self._image = None
|
||||
self._filename = None
|
||||
|
@ -579,7 +582,7 @@ class Image(EventDispatcher):
|
|||
tmpfilename = self._filename
|
||||
image = ImageLoader.load(
|
||||
self._filename, keep_data=self._keep_data,
|
||||
mipmap=self._mipmap)
|
||||
mipmap=self._mipmap, nocache=self._nocache)
|
||||
self._filename = tmpfilename
|
||||
|
||||
# put the image into the cache if needed
|
||||
|
@ -624,7 +627,7 @@ class Image(EventDispatcher):
|
|||
|
||||
.. warning::
|
||||
This function can be used only with images loaded with
|
||||
keep_data=True keyword. For examples ::
|
||||
keep_data=True keyword. For examples::
|
||||
|
||||
m = Image.load('image.png', keep_data=True)
|
||||
color = m.read_pixel(150, 150)
|
||||
|
|
|
@ -5,6 +5,21 @@ Spelling
|
|||
Provide abstracted access to a range of spellchecking backends. Also provides
|
||||
word suggestions. The API is inspired by enchant, but other backends can be
|
||||
added that implement the same API.
|
||||
|
||||
Spelling currently require `python-enchant` for all platform, except OSX, where
|
||||
a native implementation exist.
|
||||
|
||||
::
|
||||
|
||||
>>> from kivy.core.spelling import Spelling
|
||||
>>> s = Spelling()
|
||||
>>> s.list_languages()
|
||||
['en', 'en_CA', 'en_GB', 'en_US']
|
||||
>>> s.select_language('en_US')
|
||||
>>> s.check('helo')
|
||||
[u'hole', u'help', u'helot', u'hello', u'halo', u'hero', u'hell', u'held',
|
||||
u'helm', u'he-lo']
|
||||
|
||||
'''
|
||||
|
||||
__all__ = ('Spelling', 'SpellingBase', 'NoSuchLangError',
|
||||
|
|
|
@ -5,9 +5,9 @@ Text
|
|||
Abstraction of text creation. Depending of the selected backend, the text
|
||||
rendering can be more or less accurate.
|
||||
|
||||
.. versionadded::
|
||||
Starting to 1.0.7, the :class:`LabelBase` don't generate any texture is the
|
||||
text have a width <= 1.
|
||||
.. versionchanged:: 1.0.7
|
||||
The :class:`LabelBase` don't generate any texture is the text have a width
|
||||
<= 1.
|
||||
'''
|
||||
|
||||
__all__ = ('LabelBase', 'Label')
|
||||
|
@ -17,7 +17,6 @@ import os
|
|||
from kivy import kivy_data_dir
|
||||
from kivy.graphics.texture import Texture
|
||||
from kivy.core import core_select_lib
|
||||
from kivy.utils import platform
|
||||
from kivy.resources import resource_find
|
||||
|
||||
DEFAULT_FONT = 'DroidSans'
|
||||
|
@ -52,14 +51,14 @@ class LabelBase(object):
|
|||
Activate "bold" text style
|
||||
`italic`: bool, default to False
|
||||
Activate "italic" text style
|
||||
`text_size`: list, default to (None, None)
|
||||
`text_size`: tuple, default to (None, None)
|
||||
Add constraint to render the text (inside a bounding box)
|
||||
If no size is given, the label size will be set to the text size.
|
||||
`padding`: int, default to None
|
||||
If it's a integer, it will set padding_x and padding_y
|
||||
`padding_x`: int, default to 0
|
||||
`padding`: float, default to None
|
||||
If it's a float, it will set padding_x and padding_y
|
||||
`padding_x`: float, default to 0.0
|
||||
Left/right padding
|
||||
`padding_y`: int, default to 0
|
||||
`padding_y`: float, default to 0.0
|
||||
Top/bottom padding
|
||||
`halign`: str, default to "left"
|
||||
Horizontal text alignement inside bounding box
|
||||
|
@ -82,80 +81,43 @@ class LabelBase(object):
|
|||
|
||||
_fonts_cache = {}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
if 'font_size' not in kwargs:
|
||||
kwargs['font_size'] = 12
|
||||
if 'font_name' not in kwargs:
|
||||
kwargs['font_name'] = DEFAULT_FONT
|
||||
if 'bold' not in kwargs:
|
||||
kwargs['bold'] = False
|
||||
if 'italic' not in kwargs:
|
||||
kwargs['italic'] = False
|
||||
if 'halign' not in kwargs:
|
||||
kwargs['halign'] = 'left'
|
||||
if 'valign' not in kwargs:
|
||||
kwargs['valign'] = 'bottom'
|
||||
if 'padding_x' not in kwargs:
|
||||
kwargs['padding_x'] = None
|
||||
if 'padding_y' not in kwargs:
|
||||
kwargs['padding_y'] = None
|
||||
if 'shorten' not in kwargs:
|
||||
kwargs['shorten'] = False
|
||||
if 'mipmap' not in kwargs:
|
||||
kwargs['mipmap'] = False
|
||||
if 'color' not in kwargs:
|
||||
kwargs['color'] = (1, 1, 1, 1)
|
||||
if 'padding' not in kwargs:
|
||||
kwargs['padding'] = padding = None
|
||||
else:
|
||||
padding = kwargs['padding']
|
||||
def __init__(self, text='', font_size=12, font_name=DEFAULT_FONT,
|
||||
bold=False, italic=False, halign='left', valign='bottom',
|
||||
shorten=False, text_size=None, mipmap=False, color=None,
|
||||
**kwargs):
|
||||
|
||||
tp_padding = type(padding)
|
||||
padding_x = padding_y = None
|
||||
if 'padding_x' in kwargs:
|
||||
padding_x = kwargs['padding_x']
|
||||
if 'padding_y' in kwargs:
|
||||
padding_y = kwargs['padding_y']
|
||||
if not padding_x:
|
||||
if tp_padding is tuple or tp_padding is list:
|
||||
kwargs['padding_x'] = padding_x = float(padding[0])
|
||||
elif padding is not None:
|
||||
kwargs['padding_x'] = padding_x = float(padding)
|
||||
options = {'text': text, 'font_size': font_size,
|
||||
'font_name': font_name, 'bold': bold, 'italic': italic,
|
||||
'halign': halign, 'valign': valign, 'shorten': shorten,
|
||||
'mipmap': mipmap}
|
||||
|
||||
options['color'] = color or (1, 1, 1, 1)
|
||||
options['padding'] = kwargs.get('padding', 0)
|
||||
options['padding_x'] = kwargs.get('padding_x', options['padding'])
|
||||
options['padding_y'] = kwargs.get('padding_y', options['padding'])
|
||||
|
||||
if 'size' in kwargs:
|
||||
options['text_size'] = kwargs['size']
|
||||
else:
|
||||
if text_size is None:
|
||||
options['text_size'] = (None, None)
|
||||
else:
|
||||
kwargs['padding_x'] = padding_x = 0
|
||||
if not padding_y:
|
||||
if tp_padding is tuple or tp_padding is list:
|
||||
kwargs['padding_y'] = float(padding[1])
|
||||
elif padding is not None:
|
||||
kwargs['padding_y'] = float(padding)
|
||||
else:
|
||||
kwargs['padding_y'] = 0
|
||||
options['text_size'] = text_size
|
||||
|
||||
if 'text_size' in kwargs:
|
||||
ts = kwargs['text_size']
|
||||
elif 'size' in kwargs:
|
||||
ts = kwargs['size']
|
||||
text_width, text_height = options['text_size']
|
||||
if text_width is not None:
|
||||
self._text_size = (
|
||||
text_width - options['padding_x'] * 2,
|
||||
text_height)
|
||||
else:
|
||||
ts = (None, None)
|
||||
self._text_size = options['text_size']
|
||||
|
||||
uw = ts[0]
|
||||
if uw is not None:
|
||||
self._text_size = uw - padding_x * 2, ts[1]
|
||||
else:
|
||||
self._text_size = ts
|
||||
|
||||
super(LabelBase, self).__init__()
|
||||
|
||||
self._text = None
|
||||
self._text = options['text']
|
||||
self._internal_height = 0
|
||||
|
||||
self.options = kwargs
|
||||
self.options = options
|
||||
self.texture = None
|
||||
self.resolve_font_name()
|
||||
if 'text' in kwargs:
|
||||
self.text = kwargs['text']
|
||||
else:
|
||||
self.text = ''
|
||||
|
||||
@staticmethod
|
||||
def register(name, fn_regular, fn_italic=None, fn_bold=None,
|
||||
|
@ -164,7 +126,7 @@ class LabelBase(object):
|
|||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
If you're using directly a ttf, you might not be able to use bold/italic
|
||||
If you're using a ttf directly, you might not be able to use bold/italic
|
||||
of the ttf version. If the font is delivered with different version of
|
||||
it (one regular, one italic and one bold), then you need to register it
|
||||
and use the alias instead.
|
||||
|
@ -173,52 +135,38 @@ class LabelBase(object):
|
|||
:func:`kivy.resources.resource_find`. If fn_italic/fn_bold are None,
|
||||
fn_regular will be used instead.
|
||||
'''
|
||||
_fn_regular = resource_find(fn_regular)
|
||||
if _fn_regular is None:
|
||||
raise IOError('File %r not found' % fn_regular)
|
||||
if fn_italic is None:
|
||||
_fn_italic = _fn_regular
|
||||
else:
|
||||
_fn_italic = resource_find(fn_italic)
|
||||
if _fn_italic is None:
|
||||
raise IOError('File %r not found' % fn_italic)
|
||||
if fn_bold is None:
|
||||
_fn_bold = _fn_regular
|
||||
else:
|
||||
_fn_bold = resource_find(fn_bold)
|
||||
if _fn_bold is None:
|
||||
raise IOError('File %r not found' % fn_bold)
|
||||
if fn_bolditalic is None:
|
||||
_fn_bolditalic = _fn_regular
|
||||
else:
|
||||
_fn_bolditalic = resource_find(fn_bolditalic)
|
||||
if _fn_bolditalic is None:
|
||||
raise IOError('Label: File %r not found' % fn_bolditalic)
|
||||
LabelBase._fonts[name] = (_fn_regular, _fn_italic, _fn_bold,
|
||||
_fn_bolditalic)
|
||||
|
||||
fonts = []
|
||||
|
||||
for font_type in fn_regular, fn_italic, fn_bold, fn_bolditalic:
|
||||
if font_type is not None:
|
||||
font = resource_find(font_type)
|
||||
|
||||
if font is None:
|
||||
raise IOError('File {0}s not found'.format(font_type))
|
||||
else:
|
||||
fonts.append(font)
|
||||
else:
|
||||
fonts.append(fonts[-1]) # add regular font to list again
|
||||
|
||||
LabelBase._fonts[name] = tuple(fonts)
|
||||
|
||||
def resolve_font_name(self):
|
||||
options = self.options
|
||||
if 'font_name' not in options:
|
||||
return
|
||||
fontname = options['font_name']
|
||||
fontname = self.options['font_name']
|
||||
fonts = self._fonts
|
||||
fontscache = self._fonts_cache
|
||||
|
||||
# is the font is registered ?
|
||||
if fontname in fonts:
|
||||
# return the prefered font for the current bold/italic combinaison
|
||||
bold = options['bold']
|
||||
italic = options['italic']
|
||||
font = fonts[fontname]
|
||||
if not bold and not italic:
|
||||
options['font_name_r'] = font[FONT_REGULAR]
|
||||
elif bold and italic:
|
||||
options['font_name_r'] = font[FONT_BOLDITALIC]
|
||||
elif bold:
|
||||
options['font_name_r'] = font[FONT_BOLD]
|
||||
italic = int(options['italic'])
|
||||
if options['bold']:
|
||||
bold = FONT_BOLD
|
||||
else:
|
||||
options['font_name'] = font[FONT_ITALIC]
|
||||
bold = FONT_REGULAR
|
||||
|
||||
options['font_name_r'] = fonts[fontname][italic | bold]
|
||||
|
||||
elif fontname in fontscache:
|
||||
options['font_name_r'] = fontscache[fontname]
|
||||
|
@ -228,9 +176,7 @@ class LabelBase(object):
|
|||
# XXX for compatibility, check directly in the data dir
|
||||
filename = os.path.join(kivy_data_dir, fontname)
|
||||
if not os.path.exists(filename):
|
||||
filename = None
|
||||
if filename is None:
|
||||
raise IOError('Label: File %r not found' % fontname)
|
||||
raise IOError('Label: File %r not found' % fontname)
|
||||
fontscache[fontname] = filename
|
||||
options['font_name_r'] = filename
|
||||
|
||||
|
@ -247,27 +193,26 @@ class LabelBase(object):
|
|||
def _render_end(self):
|
||||
pass
|
||||
|
||||
def shorten(self, text):
|
||||
def shorten(self, text, margin=2):
|
||||
# Just a tiny shortcut
|
||||
textwidth = lambda txt: self.get_extents(txt)[0]
|
||||
mid = len(text)/2
|
||||
begin = text[:mid].strip()
|
||||
end = text[mid:].strip()
|
||||
steps = 1
|
||||
middle = '...'
|
||||
width = textwidth(begin+end) + textwidth(middle)
|
||||
last_width = width
|
||||
while width > self.text_size[0]:
|
||||
begin = text[:mid - steps].strip()
|
||||
end = text[mid + steps:].strip()
|
||||
steps += 1
|
||||
width = textwidth(begin+end) + textwidth(middle)
|
||||
if width == last_width:
|
||||
# No more shortening possible. This is the best we can
|
||||
# do. :-( -- Prevent infinite while loop.
|
||||
break
|
||||
last_width = width
|
||||
return begin + middle + end
|
||||
if self.text_size[0] is None:
|
||||
width = 0
|
||||
else:
|
||||
width = int(self.text_size[0])
|
||||
|
||||
letters = text + '...'
|
||||
letter_width = textwidth(letters) // len(letters)
|
||||
max_letters = width // letter_width
|
||||
segment = (max_letters // 2)
|
||||
|
||||
if segment - margin > 5:
|
||||
segment -= margin
|
||||
return '{0}...{1}'.format(text[:segment].strip(),
|
||||
text[-segment:].strip())
|
||||
else:
|
||||
segment = max_letters - 3 # length of '...'
|
||||
return '{0}...'.format(text[:segment].strip())
|
||||
|
||||
def render(self, real=False):
|
||||
'''Return a tuple(width, height) to create the image
|
||||
|
|
|
@ -260,22 +260,33 @@ class MarkupLabel(MarkupLabelBase):
|
|||
r = self._render_text
|
||||
|
||||
# convert halign/valign to int, faster comparaison
|
||||
#av = {'top': 0, 'middle': 1, 'bottom': 2}[self.options['valign']]
|
||||
av = {'top': 0, 'middle': 1, 'bottom': 2}[self.options['valign']]
|
||||
ah = {'left': 0, 'center': 1, 'right': 2}[self.options['halign']]
|
||||
|
||||
y = 0
|
||||
w, h = self._size
|
||||
refs = self._refs
|
||||
no_of_lines = len(self._lines)-1
|
||||
|
||||
for line in self._lines:
|
||||
lh = line[1]
|
||||
lw = line[0]
|
||||
|
||||
# horizontal alignement
|
||||
if ah == 0:
|
||||
x = 0
|
||||
elif ah == 1:
|
||||
x = int((w - line[0]) / 2)
|
||||
x = int((w - lw) / 2)
|
||||
else:
|
||||
x = w - line[0]
|
||||
x = w - lw
|
||||
|
||||
# vertical alignement
|
||||
if y == 0:
|
||||
if av == 1:
|
||||
y = int((h - (lh*no_of_lines))/2)
|
||||
elif av == 2:
|
||||
y = h - (lh*(no_of_lines))
|
||||
|
||||
|
||||
for pw, ph, part, options in line[2]:
|
||||
self.options = options
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# pylint: disable=W0611
|
||||
'''
|
||||
Window
|
||||
======
|
||||
|
@ -194,18 +195,21 @@ class WindowBase(EventDispatcher):
|
|||
`on_keyboard`: key, scancode, codepoint, modifier
|
||||
Fired when the keyboard is in action
|
||||
.. versionchanged:: 1.3.0
|
||||
The *unicode* parameter has be deprecated in favor of
|
||||
codepoint, and will be removed completely in future versions
|
||||
|
||||
The *unicode* parameter has be deprecated in favor of
|
||||
codepoint, and will be removed completely in future versions
|
||||
`on_key_down`: key, scancode, codepoint
|
||||
Fired when a key is down
|
||||
.. versionchanged:: 1.3.0
|
||||
The *unicode* parameter has be deprecated in favor of
|
||||
codepoint, and will be removed completely in future versions
|
||||
|
||||
The *unicode* parameter has be deprecated in favor of
|
||||
codepoint, and will be removed completely in future versions
|
||||
`on_key_up`: key, scancode, codepoint
|
||||
Fired when a key is up
|
||||
.. versionchanged:: 1.3.0
|
||||
The *unicode* parameter has be deprecated in favor of
|
||||
codepoint, and will be removed completely in future versions
|
||||
|
||||
The *unicode* parameter has be deprecated in favor of
|
||||
codepoint, and will be removed completely in future versions
|
||||
`on_dropfile`: str
|
||||
Fired when a file is dropped on the application
|
||||
'''
|
||||
|
@ -250,17 +254,22 @@ class WindowBase(EventDispatcher):
|
|||
def _get_size(self):
|
||||
r = self._rotation
|
||||
w, h = self._size
|
||||
if r == 0 or r == 180:
|
||||
if r in (0, 180):
|
||||
return w, h
|
||||
return h, w
|
||||
|
||||
def _set_size(self, size):
|
||||
if super(WindowBase, self)._set_size(size):
|
||||
Logger.debug('Window: Resize window to %s' % str(self.size))
|
||||
if self._size != size:
|
||||
r = self._rotation
|
||||
if r in (0, 180):
|
||||
self._size = size
|
||||
else:
|
||||
self._size = size[1], size[0]
|
||||
|
||||
self.dispatch('on_resize', *size)
|
||||
return True
|
||||
return False
|
||||
|
||||
else:
|
||||
return False
|
||||
size = AliasProperty(_get_size, _set_size)
|
||||
'''Get the rotated size of the window. If :data:`rotation` is set, then the
|
||||
size will change to reflect the rotation.
|
||||
|
@ -281,7 +290,7 @@ class WindowBase(EventDispatcher):
|
|||
bind=('_clearcolor', ))
|
||||
'''Color used to clear window.
|
||||
|
||||
::
|
||||
::
|
||||
from kivy.core.window import Window
|
||||
|
||||
# red background color
|
||||
|
@ -461,7 +470,7 @@ class WindowBase(EventDispatcher):
|
|||
self.parent = self
|
||||
|
||||
# before creating the window
|
||||
__import__('kivy.core.gl')
|
||||
import kivy.core.gl
|
||||
|
||||
# configure the window
|
||||
self.create_window()
|
||||
|
@ -755,7 +764,7 @@ class WindowBase(EventDispatcher):
|
|||
pass
|
||||
|
||||
def on_keyboard(self, key,
|
||||
scancode=None, codepoint=None, modifier=None ,**kwargs):
|
||||
scancode=None, codepoint=None, modifier=None, **kwargs):
|
||||
'''Event called when keyboard is in action
|
||||
|
||||
.. warning::
|
||||
|
@ -766,7 +775,6 @@ class WindowBase(EventDispatcher):
|
|||
"and will be removed in future versions. Use codepoint "
|
||||
"instead, which has identical semantics.")
|
||||
|
||||
|
||||
def on_key_down(self, key,
|
||||
scancode=None, codepoint=None, modifier=None, **kwargs):
|
||||
'''Event called when a key is down (same arguments as on_keyboard)'''
|
||||
|
@ -883,7 +891,6 @@ class WindowBase(EventDispatcher):
|
|||
and if configuration allowed it, a VKeyboard instance.
|
||||
|
||||
.. versionchanged:: 1.0.8
|
||||
|
||||
`target` have been added, and must be the widget source that request
|
||||
the keyboard. If set, the widget must have one method named
|
||||
`on_keyboard_text`, that will be called from the vkeyboard.
|
||||
|
@ -967,4 +974,3 @@ Window = core_select_lib('window', (
|
|||
('pygame', 'window_pygame', 'WindowPygame'),
|
||||
('sdl', 'window_sdl', 'WindowSDL'),
|
||||
), True)
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ class WindowPygame(WindowBase):
|
|||
|
||||
def request_keyboard(self, *largs):
|
||||
keyboard = super(WindowPygame, self).request_keyboard(*largs)
|
||||
if android:
|
||||
if android and not self.allow_vkeyboard:
|
||||
android.show_keyboard()
|
||||
return keyboard
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
@ -1 +1 @@
|
|||
{"defaulttheme-0.png": {"player-play-overlay": [306, 396, 117, 115], "progressbar_background": [160, 137, 24, 24], "media-playback-pause": [448, 344, 48, 48], "tab_btn_pressed": [465, 178, 32, 32], "image-missing": [399, 344, 48, 48], "filechooser_selected": [187, 393, 118, 118], "audio-volume-muted": [350, 344, 48, 48], "sliderv_background": [473, 404, 37, 41], "tab": [332, 228, 96, 32], "close": [490, 491, 20, 20], "ring": [1, 326, 185, 185], "vkeyboard_key_down": [61, 129, 32, 32], "vkeyboard_background": [187, 328, 64, 64], "checkbox_off": [300, 178, 32, 32], "bubble_arrow": [148, 162, 16, 10], "player-background": [228, 222, 103, 103], "bubble": [424, 446, 65, 65], "sliderh_background": [148, 173, 41, 37], "audio-volume-medium": [301, 344, 48, 48], "media-playback-start": [1, 162, 48, 48], "tab_btn": [432, 178, 32, 32], "bubble_btn_pressed": [267, 178, 32, 32], "tree_closed": [490, 470, 20, 20], "switch-background": [429, 228, 83, 32], "filechooser_file": [332, 261, 64, 64], "checkbox_radio_off": [366, 178, 32, 32], "vkeyboard_key_normal": [94, 129, 32, 32], "checkbox_radio_on": [399, 178, 32, 32], "checkbox_on": [333, 178, 32, 32], "tree_opened": [490, 449, 20, 20], "button_pressed": [31, 124, 29, 37], "media-playback-stop": [50, 162, 48, 48], "audio-volume-high": [424, 397, 48, 48], "audio-volume-low": [252, 344, 48, 48], "bubble_btn": [234, 178, 32, 32], "slider_cursor": [99, 162, 48, 48], "button": [1, 124, 29, 37], "progressbar": [127, 137, 32, 24], "switch-button": [190, 178, 43, 32], "filechooser_folder": [397, 261, 64, 64], "popup-background": [462, 271, 45, 54], "textinput_active": [1, 211, 114, 114], "textinput": [116, 214, 111, 111]}}
|
||||
{"defaulttheme-0.png": {"player-play-overlay": [306, 396, 117, 115], "spinner_pressed": [91, 124, 29, 37], "progressbar_background": [220, 137, 24, 24], "media-playback-pause": [448, 344, 48, 48], "tab_btn_pressed": [465, 178, 32, 32], "image-missing": [399, 344, 48, 48], "filechooser_selected": [187, 393, 118, 118], "audio-volume-muted": [350, 344, 48, 48], "sliderv_background": [473, 404, 37, 41], "tab": [332, 228, 96, 32], "close": [490, 491, 20, 20], "ring": [1, 326, 185, 185], "vkeyboard_key_down": [121, 129, 32, 32], "vkeyboard_background": [187, 328, 64, 64], "checkbox_off": [300, 178, 32, 32], "bubble_arrow": [148, 162, 16, 10], "player-background": [228, 222, 103, 103], "bubble": [424, 446, 65, 65], "spinner": [61, 124, 29, 37], "sliderh_background": [148, 173, 41, 37], "audio-volume-medium": [301, 344, 48, 48], "media-playback-start": [1, 162, 48, 48], "tab_btn": [432, 178, 32, 32], "bubble_btn_pressed": [267, 178, 32, 32], "tree_closed": [490, 470, 20, 20], "switch-background": [429, 228, 83, 32], "filechooser_file": [332, 261, 64, 64], "checkbox_radio_off": [366, 178, 32, 32], "vkeyboard_key_normal": [154, 129, 32, 32], "checkbox_radio_on": [399, 178, 32, 32], "checkbox_on": [333, 178, 32, 32], "tree_opened": [490, 449, 20, 20], "button_pressed": [31, 124, 29, 37], "media-playback-stop": [50, 162, 48, 48], "audio-volume-high": [424, 397, 48, 48], "audio-volume-low": [252, 344, 48, 48], "bubble_btn": [234, 178, 32, 32], "slider_cursor": [99, 162, 48, 48], "button": [1, 124, 29, 37], "progressbar": [187, 137, 32, 24], "switch-button": [190, 178, 43, 32], "filechooser_folder": [397, 261, 64, 64], "popup-background": [462, 271, 45, 54], "textinput_active": [1, 211, 114, 114], "textinput": [116, 214, 111, 111]}}
|
|
@ -7,28 +7,28 @@
|
|||
["`", "`", "`", 1], ["1", "1", "1", 1], ["2", "2", "2", 1],
|
||||
["3", "3", "3", 1], ["4", "4", "4", 1], ["5", "5", "5", 1],
|
||||
["6", "6", "6", 1], ["7", "7", "7", 1], ["8", "8", "8", 1],
|
||||
["9", "9", "9", 1], ["0", "0", "0", 1], ["+", "+", "+", 1],
|
||||
["9", "9", "9", 1], ["0", "0", "0", 1], ["-", "-", "-", 1],
|
||||
["=", "=", "=", 1], ["\u232b", null, "backspace", 2]
|
||||
],
|
||||
"normal_2" : [
|
||||
["\u21B9", "\t", "tab", 1.5], ["q", "q", "q", 1], ["w", "w", "w", 1],
|
||||
["e", "e", "e", 1], ["r", "r", "r", 1], ["t", "t", "t", 1],
|
||||
["y", "y", "y", 1], ["u", "u", "u", 1], ["i", "i", "i", 1],
|
||||
["o", "o", "o", 1], ["p", "p", "p", 1], ["{", "{", "{", 1],
|
||||
["}", "}", "}", 1], ["|", "|", "|", 1.5]
|
||||
["o", "o", "o", 1], ["p", "p", "p", 1], ["[", "[", "[", 1],
|
||||
["]", "]", "j", 1], ["\\", "\\", "\\", 1]
|
||||
],
|
||||
"normal_3": [
|
||||
["\u21ea", null, "capslock", 1.8], ["a", "a", "a", 1], ["s", "s", "s", 1],
|
||||
["d", "d", "d", 1], ["f", "f", "f", 1], ["g", "g", "g", 1],
|
||||
["h", "h", "h", 1], ["j", "j", "j", 1], ["k", "k", "k", 1],
|
||||
["l", "l", "l", 1], [":", ":", ":", 1], ["\"", "\"", "\"", 1],
|
||||
["l", "l", "l", 1], [":", ":", ":", 1], ["'", "'", "'", 1],
|
||||
["\u23ce", null, "enter", 2.2]
|
||||
],
|
||||
"normal_4": [
|
||||
["\u21e7", null, "shift", 2.5], ["z", "z", null, 1], ["x", "x", "x", 1],
|
||||
["c", "c", "c", 1], ["v", "v", "v", 1], ["b", "b", "b", 1],
|
||||
["n", "n", "n", 1], ["m", "m", "m", 1], ["<", "<", "<", 1],
|
||||
[">", ">", ">", 1], ["?", "?", "?", 1], ["\u21e7", null, "shift", 2.5]
|
||||
["n", "n", "n", 1], ["m", "m", "m", 1], [",", ",", ",", 1],
|
||||
[".", ".", ".", 1], ["/", "/", "/", 1], ["\u21e7", null, "shift", 2.5]
|
||||
],
|
||||
"normal_5": [
|
||||
[" ", " ", "spacebar", 12], ["\u2b12", null, "layout", 1.5], ["\u2a2f", null, "escape", 1.5]
|
||||
|
@ -44,21 +44,21 @@
|
|||
["\u21B9", "\t", "tab", 1.5], ["Q", "Q", null, 1], ["W", "W", null, 1],
|
||||
["E", "E", "e", 1], ["R", "R", "r", 1], ["T", "T", "t", 1],
|
||||
["Y", "Y", "y", 1], ["U", "U", "u", 1], ["I", "I", "i", 1],
|
||||
["O", "O", "o", 1], ["P", "P", "p", 1], ["[", "[", "[", 1],
|
||||
["]", "]", "j", 1], ["?", "?", "?", 1.5]
|
||||
["O", "O", "o", 1], ["P", "P", "p", 1], ["{", "{", "{", 1],
|
||||
["}", "}", "}", 1], ["|", "|", "|", 1.5]
|
||||
],
|
||||
"shift_3": [
|
||||
["\u21ea", null, "capslock", 1.8], ["A", "A", "a", 1], ["S", "S", "s", 1],
|
||||
["D", "D", "d", 1], ["F", "F", "f", 1], ["G", "G", "g", 1],
|
||||
["H", "H", "h", 1], ["J", "J", "j", 1], ["K", "K", "k", 1],
|
||||
["L", "L", "l", 1], [":", ":", ":", 1], ["'", "'", "'", 1],
|
||||
["L", "L", "l", 1], [";", ";", ";", 1], ["\"", "\"", "\"", 1],
|
||||
["\u23ce", null, "enter", 2.2]
|
||||
],
|
||||
"shift_4": [
|
||||
["\u21e7", null, "shift", 2.5], ["Z", "Z", "z", 1], ["X", "X", "x", 1],
|
||||
["C", "C", "c", 1], ["V", "V", "v", 1], ["B", "B", "b", 1],
|
||||
["N", "N", "n", 1], ["M", "M", "m", 1], [",", ",", ",", 1],
|
||||
[".", ".", ".", 1], ["/", "/", "/", 1], ["\u21e7", null, "shift", 2.5]
|
||||
["N", "N", "n", 1], ["M", "M", "m", 1], ["<", "<", "<", 1],
|
||||
[">", ">", ">", 1], ["?", "?", "?", 1.5], ["\u21e7", null, "shift", 2.5]
|
||||
],
|
||||
"shift_5": [
|
||||
[" ", " ", "spacebar", 12], ["\u2b12", null, "layout", 1.5], ["\u2a2f", null, "escape", 1.5]
|
||||
|
|
|
@ -388,9 +388,9 @@
|
|||
size: 43, 32
|
||||
pos: int(self.center_x - 41 + self.active_norm_pos * 41), int(self.center_y - 16)
|
||||
|
||||
# Popup widget
|
||||
<Popup>:
|
||||
_container: container
|
||||
|
||||
# ModalView widget
|
||||
<ModalView>:
|
||||
canvas:
|
||||
Color:
|
||||
rgba: root.background_color[:3] + [root.background_color[-1] * self._anim_alpha]
|
||||
|
@ -405,6 +405,10 @@
|
|||
pos: self.pos
|
||||
size: self.size
|
||||
|
||||
|
||||
# Popup widget
|
||||
<Popup>:
|
||||
_container: container
|
||||
GridLayout:
|
||||
padding: 12
|
||||
cols: 1
|
||||
|
@ -757,3 +761,23 @@
|
|||
do_rotation: False
|
||||
do_scale: False
|
||||
auto_bring_to_front: False
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Screen Manager
|
||||
# =============================================================================
|
||||
|
||||
<ScreenManager>:
|
||||
canvas.before:
|
||||
StencilPush
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
StencilUse
|
||||
canvas.after:
|
||||
StencilUnUse
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
StencilPop
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ Factory = FactoryBase()
|
|||
|
||||
# Now import the file with all registers
|
||||
# automatically generated by build_factory
|
||||
__import__('kivy.factory_registers')
|
||||
import kivy.factory_registers
|
||||
Logger.info('Factory: %d symbols loaded' % len(Factory.classes))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -81,6 +81,7 @@ r('Bubble', module='kivy.uix.bubble')
|
|||
r('BubbleButton', module='kivy.uix.bubble')
|
||||
r('Camera', module='kivy.uix.camera')
|
||||
r('CheckBox', module='kivy.uix.checkbox')
|
||||
r('DropDown', module='kivy.uix.dropdown')
|
||||
r('FloatLayout', module='kivy.uix.floatlayout')
|
||||
r('RelativeLayout', module='kivy.uix.relativelayout')
|
||||
r('FileChooserListView', module='kivy.uix.filechooser')
|
||||
|
@ -89,6 +90,7 @@ r('Image', module='kivy.uix.image')
|
|||
r('AsyncImage', module='kivy.uix.image')
|
||||
r('Label', module='kivy.uix.label')
|
||||
r('Layout', module='kivy.uix.layout')
|
||||
r('ModalView', module='kivy.uix.modalview')
|
||||
r('ProgressBar', module='kivy.uix.progressbar')
|
||||
r('Popup', module='kivy.uix.popup')
|
||||
r('Scatter', module='kivy.uix.scatter')
|
||||
|
@ -98,6 +100,7 @@ r('Settings', module='kivy.uix.settings')
|
|||
r('Slider', module='kivy.uix.slider')
|
||||
r('Screen', module='kivy.uix.screenmanager')
|
||||
r('ScreenManager', module='kivy.uix.screenmanager')
|
||||
r('Spinner', module='kivy.uix.spinner')
|
||||
r('StackLayout', module='kivy.uix.stacklayout')
|
||||
r('StencilView', module='kivy.uix.stencilview')
|
||||
r('Switch', module='kivy.uix.switch')
|
||||
|
|
|
@ -9,7 +9,7 @@ at rendering time.
|
|||
Reducing the context instructions
|
||||
---------------------------------
|
||||
|
||||
Imagine that you have a scheme like this ::
|
||||
Imagine that you have a scheme like this::
|
||||
|
||||
Color(1, 1, 1)
|
||||
Rectangle(source='button.png', pos=(0, 0), size=(20, 20))
|
||||
|
@ -18,7 +18,7 @@ Imagine that you have a scheme like this ::
|
|||
Color(1, 1, 1)
|
||||
Rectangle(source='button.png', pos=(10, 20), size=(20, 20))
|
||||
|
||||
The real instruction seen by the graphics canvas would be ::
|
||||
The real instruction seen by the graphics canvas would be::
|
||||
|
||||
Color: change 'color' context to 1, 1, 1
|
||||
BindTexture: change 'texture0' to `button.png texture`
|
||||
|
@ -32,7 +32,7 @@ The real instruction seen by the graphics canvas would be ::
|
|||
|
||||
Only the first :class:`~kivy.graphics.context_instructions.Color` and
|
||||
:class:`~kivy.graphics.context_instructions.BindTexture` are useful, and really
|
||||
change the context. We can reduce them to ::
|
||||
change the context. We can reduce them to::
|
||||
|
||||
Color: change 'color' context to 1, 1, 1
|
||||
BindTexture: change 'texture0' to `button.png texture`
|
||||
|
|
|
@ -122,11 +122,16 @@ cdef class Context:
|
|||
cdef Shader shader
|
||||
cdef Canvas canvas
|
||||
|
||||
Cache.remove('kv.atlas')
|
||||
image_objects = Cache._objects['kv.image']
|
||||
Cache.remove('kv.image')
|
||||
Cache.remove('kv.texture')
|
||||
Cache.remove('kv.shader')
|
||||
|
||||
# For texture cache, save the objects. We need to clean the cache as the
|
||||
# others to prevent of using it during the reloading part.
|
||||
# We'll restore the object later.
|
||||
texture_objects = Cache._objects['kv.texture']
|
||||
Cache.remove('kv.texture')
|
||||
|
||||
start = time()
|
||||
Logger.info('Context: Reloading graphics data...')
|
||||
Logger.debug('Context: Collect and flush all garbage')
|
||||
|
@ -143,6 +148,7 @@ cdef class Context:
|
|||
texture = item()
|
||||
if texture is None:
|
||||
continue
|
||||
Logger.trace('Context: unset texture id %r' % texture)
|
||||
texture._id = -1
|
||||
|
||||
# First time, only reload base texture
|
||||
|
@ -150,14 +156,24 @@ cdef class Context:
|
|||
texture = item()
|
||||
if texture is None or isinstance(texture, TextureRegion):
|
||||
continue
|
||||
Logger.trace('Context: >> reload base texture %r' % texture)
|
||||
texture.reload()
|
||||
Logger.trace('Context: << reload base texture %r' % texture)
|
||||
|
||||
# Second time, update texture region id
|
||||
for item in l:
|
||||
texture = item()
|
||||
if texture is None or not isinstance(texture, TextureRegion):
|
||||
continue
|
||||
Logger.trace('Context: >> reload region texture %r' % texture)
|
||||
texture.reload()
|
||||
Logger.trace('Context: << reload region texture %r' % texture)
|
||||
|
||||
# Restore texture cache
|
||||
texture_objects.update(Cache._objects['kv.texture'])
|
||||
Cache._objects['kv.texture'] = texture_objects
|
||||
image_objects.update(Cache._objects['kv.image'])
|
||||
Cache._objects['kv.image'] = image_objects
|
||||
|
||||
Logger.debug('Context: Reload vbos')
|
||||
for item in self.l_vbo[:]:
|
||||
|
|
|
@ -267,6 +267,8 @@ cdef class BindTexture(ContextInstruction):
|
|||
def __set__(self, object texture):
|
||||
if not texture:
|
||||
texture = get_default_texture()
|
||||
Logger.trace('BindTexture: setting texture %r (previous is %r)' % (
|
||||
texture, self._texture))
|
||||
self._texture = texture
|
||||
|
||||
property index:
|
||||
|
|
|
@ -7,7 +7,7 @@ texture, and use your fbo as a texture for another drawing.
|
|||
|
||||
Fbo act as a :class:`kivy.graphics.instructions.Canvas`.
|
||||
|
||||
Exemple of using an fbo for some color rectangles ::
|
||||
Example of using an fbo for some color rectangles::
|
||||
|
||||
from kivy.graphics import Fbo, Color, Rectangle
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ Stencil instructions
|
|||
.. versionadded:: 1.0.4
|
||||
|
||||
.. versionchanged:: 1.3.0
|
||||
|
||||
The stencil operation have been updated to resolve some issues appearing
|
||||
when nested. You **must** know have a StencilUnUse and repeat the same
|
||||
operation as you did after StencilPush.
|
||||
|
|
|
@ -184,11 +184,8 @@ include "config.pxi"
|
|||
include "common.pxi"
|
||||
include "opengl_utils_def.pxi"
|
||||
|
||||
from os import environ
|
||||
from array import array
|
||||
from kivy.weakmethod import WeakMethod
|
||||
from kivy.logger import Logger
|
||||
from kivy.cache import Cache
|
||||
from kivy.graphics.context cimport get_context
|
||||
|
||||
from kivy.graphics.c_opengl cimport *
|
||||
|
@ -761,7 +758,7 @@ cdef class Texture:
|
|||
self._id = texture.id
|
||||
else:
|
||||
from kivy.core.image import Image
|
||||
image = Image(self._source)
|
||||
image = Image(self._source, nocache=True)
|
||||
self._id = image.texture.id
|
||||
texture = image.texture
|
||||
texture._nofree = 1
|
||||
|
|
|
@ -29,7 +29,8 @@ cdef extern from "string.h":
|
|||
cdef double _EPS = 8.8817841970012523e-16
|
||||
|
||||
cdef class Matrix:
|
||||
'''Optimized matrix class for OpenGL ::
|
||||
'''
|
||||
Optimized matrix class for OpenGL::
|
||||
|
||||
>>> from kivy.graphics.transformation import Matrix
|
||||
>>> m = Matrix()
|
||||
|
@ -42,8 +43,7 @@ cdef class Matrix:
|
|||
[ 0 1 2 3]
|
||||
[ 4 5 6 7]
|
||||
[ 8 9 10 11]
|
||||
[12 13 14 15]
|
||||
|
||||
[ 12 13 14 15]
|
||||
'''
|
||||
|
||||
def __cinit__(self):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# pylint: disable=W0611
|
||||
'''
|
||||
Input management
|
||||
================
|
||||
|
@ -29,7 +30,7 @@ from kivy.input.motionevent import MotionEvent
|
|||
from kivy.input.postproc import kivy_postproc_modules
|
||||
from kivy.input.provider import MotionEventProvider
|
||||
from kivy.input.factory import MotionEventFactory
|
||||
__import__('kivy.input.providers')
|
||||
import kivy.input.providers
|
||||
|
||||
__all__ = (
|
||||
MotionEvent.__name__,
|
||||
|
|
|
@ -10,8 +10,8 @@ __all__ = ('MotionEventFactory', )
|
|||
|
||||
class MotionEventFactory:
|
||||
'''MotionEvent factory is a class who register all availables input
|
||||
factories. If you create a new input factory, don't forget to register it
|
||||
::
|
||||
factories. If you create a new input factory, don't forget to register
|
||||
it::
|
||||
|
||||
MotionEventFactory.register('myproviderid', MyInputProvider)
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ Listen to Motion Event
|
|||
----------------------
|
||||
|
||||
If you want to receive all Motion Event, Touch or not, you can bind motion event
|
||||
from :class:`~kivy.core.window.Window` to your own callbacks ::
|
||||
from :class:`~kivy.core.window.Window` to your own callbacks::
|
||||
|
||||
def on_motion(self, etype, motionevent):
|
||||
# will receive all motion event.
|
||||
|
@ -64,13 +64,13 @@ pressure Pressure of the contact. Use property `pressure`
|
|||
shape Contact shape. Use property `shape`
|
||||
============== ================================================================
|
||||
|
||||
If yo want to know if the current :class:`MotionEvent` have an angle ::
|
||||
If yo want to know if the current :class:`MotionEvent` have an angle::
|
||||
|
||||
def on_touch_move(self, touch):
|
||||
if 'angle' in touch.profile:
|
||||
print 'The touch angle is', touch.a
|
||||
|
||||
If you want to select only the fiducials ::
|
||||
If you want to select only the fiducials::
|
||||
|
||||
def on_touch_move(self, touch):
|
||||
if 'markerid' not in touch.profile:
|
||||
|
@ -276,7 +276,7 @@ class MotionEvent(object):
|
|||
def grab(self, class_instance, exclusive=False):
|
||||
'''Grab this motion event. You can grab a touch if you absolutly want to
|
||||
receive on_touch_move() and on_touch_up(), even if the touch is not
|
||||
dispatched by your parent ::
|
||||
dispatched by your parent::
|
||||
|
||||
def on_touch_down(self, touch):
|
||||
touch.grab(self)
|
||||
|
|
|
@ -20,7 +20,7 @@ from kivy.config import Config
|
|||
class InputPostprocDejitter(object):
|
||||
'''
|
||||
Get rid of jitterish BLOBs.
|
||||
Example ::
|
||||
Example::
|
||||
|
||||
[postproc]
|
||||
jitter_distance = 0.004
|
||||
|
|
|
@ -16,7 +16,7 @@ class InputPostprocDoubleTap(object):
|
|||
'''
|
||||
InputPostProcDoubleTap is a post-processor to check if
|
||||
a touch is a double tap or not.
|
||||
Double tap can be configured in the Kivy config file ::
|
||||
Double tap can be configured in the Kivy config file::
|
||||
|
||||
[postproc]
|
||||
double_tap_time = 250
|
||||
|
|
|
@ -14,7 +14,7 @@ from kivy.utils import strtotuple
|
|||
class InputPostprocIgnoreList(object):
|
||||
'''
|
||||
InputPostprocIgnoreList is a post-processor who remove touch in ignore list.
|
||||
Ignore list can be configured in the Kivy config file ::
|
||||
Ignore list can be configured in the Kivy config file::
|
||||
|
||||
[postproc]
|
||||
# Format: [(xmin, ymin, xmax, ymax), ...]
|
||||
|
|
|
@ -18,7 +18,7 @@ class InputPostprocRetainTouch(object):
|
|||
touch, to reuse it under certains conditions. This module is designed to
|
||||
prevent finger lost on some hardware/setup.
|
||||
|
||||
Retain touch can be configured in the Kivy config file ::
|
||||
Retain touch can be configured in the Kivy config file::
|
||||
|
||||
[postproc]
|
||||
retain_time = 100
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# pylint: disable=W0611
|
||||
'''
|
||||
Providers
|
||||
=========
|
||||
|
@ -9,51 +10,51 @@ import os
|
|||
from kivy.utils import platform as core_platform
|
||||
from kivy.logger import Logger
|
||||
|
||||
__import__('kivy.input.providers.tuio')
|
||||
__import__('kivy.input.providers.mouse')
|
||||
import kivy.input.providers.tuio
|
||||
import kivy.input.providers.mouse
|
||||
|
||||
platform = core_platform()
|
||||
|
||||
if platform == 'win' or 'KIVY_DOC' in os.environ:
|
||||
try:
|
||||
__import__('kivy.input.providers.wm_touch')
|
||||
__import__('kivy.input.providers.wm_pen')
|
||||
import kivy.input.providers.wm_touch
|
||||
import kivy.input.providers.wm_pen
|
||||
except:
|
||||
err = 'Input: WM_Touch/WM_Pen not supported by your version of Windows'
|
||||
Logger.warning(err)
|
||||
|
||||
if platform == 'macosx' or 'KIVY_DOC' in os.environ:
|
||||
try:
|
||||
__import__('kivy.input.providers.mactouch')
|
||||
import kivy.input.providers.mactouch
|
||||
except:
|
||||
err = 'Input: MacMultitouchSupport is not supported by your system'
|
||||
Logger.exception(err)
|
||||
|
||||
if platform == 'linux' or 'KIVY_DOC' in os.environ:
|
||||
try:
|
||||
__import__('kivy.input.providers.probesysfs')
|
||||
import kivy.input.providers.probesysfs
|
||||
except:
|
||||
err = 'Input: ProbeSysfs is not supported by your version of linux'
|
||||
Logger.exception(err)
|
||||
try:
|
||||
__import__('kivy.input.providers.mtdev')
|
||||
import kivy.input.providers.mtdev
|
||||
except:
|
||||
err = 'Input: MTDev is not supported by your version of linux'
|
||||
Logger.exception(err)
|
||||
try:
|
||||
__import__('kivy.input.providers.hidinput')
|
||||
import kivy.input.providers.hidinput
|
||||
except:
|
||||
err = 'Input: HIDInput is not supported by your version of linux'
|
||||
Logger.exception(err)
|
||||
try:
|
||||
import kivy.input.providers.linuxwacom
|
||||
except:
|
||||
err = 'Input: LinuxWacom is not supported by your version of linux'
|
||||
Logger.exception(err)
|
||||
|
||||
if platform == 'android' or 'KIVY_DOC' in os.environ:
|
||||
try:
|
||||
__import__('kivy.input.providers.linuxwacom')
|
||||
except:
|
||||
err = 'Input: LinuxWacom is not supported by your version of linux'
|
||||
Logger.exception(err)
|
||||
try:
|
||||
__import__('kivy.input.providers.androidjoystick')
|
||||
import kivy.input.providers.androidjoystick
|
||||
except:
|
||||
err = 'Input: AndroidJoystick is not supported by your version of linux'
|
||||
Logger.exception(err)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# pylint: disable=W0611
|
||||
__all__ = ('AndroidMotionEventProvider', )
|
||||
|
||||
import os
|
||||
|
||||
try:
|
||||
__import__('android')
|
||||
import android
|
||||
except ImportError:
|
||||
if 'KIVY_DOC' not in os.environ:
|
||||
raise Exception('android lib not found.')
|
||||
|
|
|
@ -4,7 +4,7 @@ Native support of HID input from linux kernel
|
|||
|
||||
Support start from 2.6.32-ubuntu, or 2.6.34.
|
||||
|
||||
To configure HIDInput, put in your configuration ::
|
||||
To configure HIDInput, put in your configuration::
|
||||
|
||||
[input]
|
||||
# devicename = hidinput,/dev/input/eventXX
|
||||
|
@ -29,7 +29,7 @@ To fix that, you can add one of theses options on the argument line :
|
|||
|
||||
For example, on Asus T101M, the touchscreen report a range from 0-4095 for X and
|
||||
Y value, but real value are in a range from 0-32768. You can put it on
|
||||
configuration ::
|
||||
configuration::
|
||||
|
||||
[input]
|
||||
t101m = hidinput,/dev/input/event7,max_position_x=32768,max_position_y=32768
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Native support of Wacom tablet from linuxwacom driver
|
||||
=====================================================
|
||||
|
||||
To configure LinuxWacom, put in your configuration ::
|
||||
To configure LinuxWacom, put in your configuration::
|
||||
|
||||
[input]
|
||||
pen = linuxwacom,/dev/input/event2,mode=pen
|
||||
|
|
|
@ -8,7 +8,7 @@ touch can generate one event from mouse provider and from multitouch provider.
|
|||
|
||||
To avoid this behavior, you can activate the "disable_on_activity" token in
|
||||
mouse. Then, if they are any touch active from another provider, the mouse will
|
||||
be discarded. Put in your configuration ::
|
||||
be discarded. Put in your configuration::
|
||||
|
||||
[input]
|
||||
mouse = mouse,disable_on_activity
|
||||
|
@ -20,7 +20,7 @@ Disabling multitouch interaction with mouse
|
|||
|
||||
By default middle and right mouse buttons ared used for multitouch emulation.
|
||||
If you want to use them for other purpose you can disable this behavior by
|
||||
activating the "disable_multitouch" token ::
|
||||
activating the "disable_multitouch" token::
|
||||
|
||||
[input]
|
||||
mouse = mouse,disable_multitouch
|
||||
|
|
|
@ -8,7 +8,7 @@ You can read more on http://wiki.ubuntu.com/Multitouch
|
|||
To configure MTDev, it's preferable to use probesysfs providers.
|
||||
Check :py:class:`~kivy.input.providers.probesysfs` for more information.
|
||||
|
||||
Otherwise, you can put in your configuration ::
|
||||
Otherwise, you can put in your configuration::
|
||||
|
||||
[input]
|
||||
# devicename = hidinput,/dev/input/eventXX
|
||||
|
|
|
@ -9,7 +9,7 @@ be made by other providers like: hidinput, mtdev, linuxwacom. mtdev is used
|
|||
prior to other providers. For more information about mtdev, check
|
||||
:py:class:`~kivy.input.providers.mtdev`.
|
||||
|
||||
Here is an example of auto creation ::
|
||||
Here is an example of auto creation::
|
||||
|
||||
[input]
|
||||
# using mtdev
|
||||
|
|
|
@ -119,7 +119,7 @@ else:
|
|||
windll.user32.GetTouchInputInfo.restype = BOOL
|
||||
windll.user32.GetTouchInputInfo.argtypes = [HANDLE, UINT,
|
||||
POINTER(TOUCHINPUT), c_int]
|
||||
|
||||
|
||||
class WM_MotionEventProvider(MotionEventProvider):
|
||||
|
||||
def start(self):
|
||||
|
|
|
@ -265,7 +265,7 @@ For example, for a list, you'll need to create a entry with a image on the left,
|
|||
and a label on the right. You can create a template for making that definition
|
||||
more easy to use.
|
||||
So, we'll create a template that require 2 entry in the context: a image
|
||||
filename and a title ::
|
||||
filename and a title::
|
||||
|
||||
[IconItem@BoxLayout]:
|
||||
Image:
|
||||
|
@ -275,7 +275,7 @@ filename and a title ::
|
|||
|
||||
.. highlight:: python
|
||||
|
||||
Then in Python, you can create instanciate the template with ::
|
||||
Then in Python, you can create instanciate the template with::
|
||||
|
||||
from kivy.lang import Builder
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from types import TracebackType, CodeType
|
|||
|
||||
# on pypy we can take advantage of transparent proxies
|
||||
try:
|
||||
tproxy = __import__('__pypy__')
|
||||
import __pypy__ as tproxy
|
||||
except ImportError:
|
||||
tproxy = None
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# pylint: disable=W0611
|
||||
''' simpleOSC 0.2
|
||||
ixi software - July, 2006
|
||||
www.ixi-software.net
|
||||
|
@ -38,7 +39,7 @@ try:
|
|||
raise
|
||||
use_multiprocessing = True
|
||||
from multiprocessing import Process, Queue, Value
|
||||
__import__('multiprocessing.synchronize')
|
||||
import multiprocessing.synchronize
|
||||
Logger.info('OSC: using <multiprocessing> for socket')
|
||||
except:
|
||||
use_multiprocessing = False
|
||||
|
|
|
@ -21,7 +21,7 @@ If you want to change the default loading image, you can do::
|
|||
|
||||
__all__ = ('Loader', 'LoaderBase', 'ProxyImage')
|
||||
|
||||
from kivy import kivy_data_dir
|
||||
from kivy import kivy_data_dir, kivy_base_dir
|
||||
from kivy.logger import Logger
|
||||
from kivy.clock import Clock
|
||||
from kivy.cache import Cache
|
||||
|
@ -96,7 +96,8 @@ class LoaderBase(object):
|
|||
def error_image(self):
|
||||
'''Image used for error (readonly)'''
|
||||
if not self._error_image:
|
||||
error_png_fn = join(kivy_data_dir, 'images', 'image-missing.png')
|
||||
error_png_fn = join(kivy_base_dir, 'tools/theming/defaulttheme',
|
||||
'image-missing.png')
|
||||
self._error_image = ImageLoader.load(filename=error_png_fn)
|
||||
return self._error_image
|
||||
|
||||
|
@ -206,7 +207,7 @@ class LoaderBase(object):
|
|||
'''Load a image using loader. A Proxy image is returned with a loading
|
||||
image.
|
||||
|
||||
::
|
||||
::
|
||||
img = Loader.image(filename)
|
||||
# img will be a ProxyImage.
|
||||
# You'll use it the same as an Image class.
|
||||
|
|
|
@ -288,7 +288,8 @@ if 'KIVY_NO_CONSOLELOG' not in os.environ:
|
|||
Logger.addHandler(getattr(sys, '_kivy_logging_handler'))
|
||||
else:
|
||||
use_color = os.name != 'nt'
|
||||
color_fmt = formatter_message('[%(levelname)-18s] %(message)s', use_color)
|
||||
color_fmt = formatter_message(
|
||||
'[%(levelname)-18s] %(message)s', use_color)
|
||||
formatter = ColoredFormatter(color_fmt, use_color=use_color)
|
||||
console = ConsoleHandler()
|
||||
console.setFormatter(formatter)
|
||||
|
@ -299,4 +300,3 @@ sys.stderr = LogFile('stderr', Logger.warning)
|
|||
|
||||
#: Kivy history handler
|
||||
LoggerHistory = LoggerHistory
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue