Skip to content

Commit

Permalink
examples/ - Update docstrings
Browse files Browse the repository at this point in the history
Update or create docstrings from many of the examples.  This is part of
the gallery project, as the new docstrings will be the website visible
documentation for the example.   Some changes are to use the main
phrase of ‘the file xx.py’ to include related files on the gallery page.

These are all documentation changes only.
  • Loading branch information
merriam committed Feb 12, 2015
1 parent d5c2443 commit f16fe11
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 27 deletions.
10 changes: 5 additions & 5 deletions examples/3Drendering/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'''
3D Rendering Monkey Head
3D Rotating Monkey Head
========================
This example demonstrates using OpenGL to display rotating monkey head. This
This example demonstrates using OpenGL to display a rotating monkey head. This
includes loading a Blender OBJ file, shaders written in OpenGL's Shading
Language (GLSL), and using scheduled callbacks.
The file monkey.obj is a OBJ file output form the Blender free 3D creation
software. The file is text, listing vertices and faces. It is loaded
into a scene using objloader.py's ObjFile class. The file simple.glsl is
The monkey.obj file is an OBJ file output from the Blender free 3D creation
software. The file is text, listing vertices and faces and is loaded
using a class in the file objloader.py. The file simple.glsl is
a simple vertex and fragment shader written in GLSL.
'''

Expand Down
16 changes: 12 additions & 4 deletions examples/application/app_suite.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
'''
Application Suite
=================
Suite of Application Builders
=============================
This explores different methods of starting an application. If you run
this without a command line parameter, you should see a menu in your terminal.
For example, you can rerun this with 'r' command to pick a random method.
There are lots of logging options to make this easier to debug: execution
order may not be obvious. Each time you run the command, only one kivy
application is created.
This uses the file testkvfile.kv and the file app_suite_data/testkvdir.kv.
Explore how applications start. Starts applications one after another,
waiting for each to be closed first.
'''

from __future__ import print_function
import sys
import re
Expand Down
13 changes: 9 additions & 4 deletions examples/application/app_with_kv.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
'''
Application from a .kv
======================
Application built from a .kv file
==================================
The root application is created from the corresponding .kv. Check the test.kv
file to see what will be the root widget.
This shows how to implicitly use a .kv file for your application. You
should see a full screen button labelled "Hello from test.kv".
After Kivy instantiates a subclass of App, it implicitly searches for a .kv
file. The file test.kv is selected because the name of the subclass of App is
TestApp, which implies that kivy should try to load "test.kv". That file
contains a root Widget.
'''

import kivy
Expand Down
15 changes: 10 additions & 5 deletions examples/application/app_with_kv_in_template1.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
'''
Application from a .kv
======================
Application from a .kv in a Template Directory
==============================================
This example shows how you can change the directory for the .kv file. You
should see "Hello from template1/test.ky" as a button.
As kivy instantiates the TestApp subclass of App, the variable kv_directory
is set. Kivy then implicitly searches for a .kv file matching the name
of the subclass in that directory, finding the file template1/test.kv. That
file contains a root of class Widget.
The root application is created from the corresponding .kv. Check the test.kv
file to see what will be the root widget.
This example shows how you can change the directory where the .kv lives.
'''

import kivy
Expand Down
3 changes: 2 additions & 1 deletion examples/canvas/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
This example exercises circle (ellipse) drawing. You should see sliders at the
top of the screen with the Kivy logo below it. The sliders control the
angle start and stop and the height and width scales. There is a button
to reset the sliders. The entire example is coded in the
to reset the sliders. The logo used for the circle's background image is
from the kivy/data directory. The entire example is coded in the
kv language description.
'''

Expand Down
11 changes: 7 additions & 4 deletions examples/canvas/multitexture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
Multitexture Example
====================
This example blends two textures: the letter K in mtexture1.png and an orange
circle in mtexture2.png. You should see an orange K clipped to a circle.
It uses a custom shader, written in glsl (OpenGL Shading Language), stored
in a local string.
This example blends two textures: the image mtexture1.png of the letter K
and the image mtexture2.png of an orange circle. You should see an orange
K clipped to a circle. It uses a custom shader, written in glsl
(OpenGL Shading Language), stored in a local string.
Note the image mtexture1.png is a white 'K' on a transparent background, which
makes it hard to see.
'''

from kivy.clock import Clock
Expand Down
5 changes: 4 additions & 1 deletion examples/canvas/repeat_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
This examples repeats the letter 'K' (mtexture1.png) 64 times in a window.
You should see 8 rows and 8 columns of white K letters, along a label
showing the current size. As you resize the window, it stays an 8x8.
This example includes a label on a background.
This example includes a label with a colored background.
Note the image mtexture1.png is a white 'K' on a transparent background, which
makes it hard to see.
'''

from kivy.app import App
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas/tesselate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This demonstrates the experimental library for tesselating polygons. You
should see a hollow square with some buttons below it. You can click and
drag to create additional shapes, watchin the number of vertexes and elements
drag to create additional shapes, watching the number of vertexes and elements
at the top of the screen. The 'debug' button toggles showing the mesh in
different colors.
'''
Expand Down
15 changes: 13 additions & 2 deletions examples/canvas/texture.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
'''
Example of changing texture properties and the properties
of its containing rectangle.
Texture Wrapping and Coordinates Example
========================================
This example changes texture properties and the properties
of its containing rectangle. You should see some a multicolored
texture with sliders to the left and below and buttons at the
bottom of the screen. The image texture_example_image.png is
rendered into the rectangle. Sliders change the number of copies of the
texture (the tex_coords), the size of enclosing rectangle (the taw_height
and taw_width) while the buttons change how the texture is rendered when more
than one copy is in the rectangle (the
texture_wrap).
'''


Expand Down
12 changes: 12 additions & 0 deletions examples/demo/camera_puzzle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
'''
Shuffled Camera Feed Puzzle
===========================
This demonstrates using Scatter widgets with a live camera.
You should see a shuffled grid of rectangles that make up the
camera feed. You can drag the squares around to see the
unscrambled camera feed or double click to scramble the grid
again.
'''


from kivy.app import App
from kivy.uix.camera import Camera
from kivy.uix.widget import Widget
Expand Down
21 changes: 21 additions & 0 deletions examples/demo/kivycatalog/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
#!/usr/bin/kivy
'''
Kivy Catalog
============
The Kivy Catalog viewer showcases widgets available in Kivy
and allows interactive editing of kivy language code to get immediate
feedback. You should see a two panel screen with a menu spinner button
(starting with 'Welcome') and other controls across the top. The left pane
contains kivy (.kv) code, and the right side is that code rendered. You can
edit the left pane, though changes will be lost when you use the menu
spinner button. The catalog will show you dozens of .kv examples controlling
different widgets and layouts.
The catalog's interface is set in the file kivycatalog.kv, while the
interfaces for each menu option are set in containers_kvs directory. To
add a new .kv file to the Kivy Catalog, add a .kv file into the container_kvs
directory and reference that file in the ScreenManager section of
kivycatalog.kv.
Known bugs include some issue with the drop
'''
import kivy
kivy.require('1.4.2')
import os
Expand Down
22 changes: 22 additions & 0 deletions examples/demo/multistroke/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
#!/usr/bin/env python
'''
Multistroke Recognition Database Demonstration
==============================================
This application records gestures and attempts to match them. You should
see a black drawing surface with some buttons across the bottom. As you
make a gesture on the drawing surface, the gesture will be added to
the history and a match will be attempted. If you go to the history tab,
name the gesture, and add it to the database, then simliar gestures in the
future will be recognized. You can load and save databases of gestures
in .kg files.
This demonstration code is many files, with this being the primary file.
The information pop-up ('No match') comes from the file helpers.py.
The history pane is managed in the file historymanager.py and described
in the file historymanager.kv. The database pane and storage is managed in
the file gestureDatabase.py and the described in the file gestureDatabase.kv.
The general logic of the sliders and buttons are in the file
settings.py and described in settings.kv. but the actual settings pane is
described in the file multistroke.kv and managed from this file.
'''
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.gesturesurface import GestureSurface
Expand Down
16 changes: 16 additions & 0 deletions examples/demo/shadereditor/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/usr/bin/kivy
'''
Live Shader Editor
==================
This provides a live editor for vertex and fragment editors.
You should see a window with two editable panes on the left
and a large kivy logo on the right. The top pane is the
Vertex shader and the bottom is the Fragment shader. The file shadereditor.kv
describes the interface.
On each keystroke to either shader, declarations are added and the shaders
are compiled. If there are no errors, the screen is updated. Otherwise,
the error is visible as logging message in your terminal.
'''


import sys
import kivy
kivy.require('1.0.6')
Expand Down
27 changes: 27 additions & 0 deletions examples/demo/showcase/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
#!/usr/bin/kivy
'''
Showcase of Kivy Features
=========================
This showcases many features of Kivy. You should see a
menu bar across the top with a demonstration area below. The
first demonstration is the accordion layout. You can see, but not
edit, the kv language code for any screen by pressing the bug or
'show source' icon. Scroll through the demonstrations using the
left and right icons in the top right or selecting from the menu
bar. This showcases dozens of features.
The file showcase.kv describes the main container, while each demonstration
pane is described in a separate .kv file in the data/screens directory.
The image data/background.png provides the gradient background while the
icons in data/icon directory are used in the control bar. The file
data/faust_github.jpg is used in the Scatter pane. The icons are
from `http://www.gentleface.com/free_icon_set.html` and licensed as
Creative Commons - Attribution and Non-commercial Use Only; they
sell a commercial license.
The file android.txt is used to package the application for use with the
Kivy Launcher Android application. For Android devices, you can
copy/paste this directory into /sdcard/kivy/showcase on your Android device.
'''

from time import time
from kivy.app import App
from os.path import dirname, join
Expand Down
19 changes: 19 additions & 0 deletions examples/demo/touchtracer/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
#!/usr/bin/kivy
'''
Touch Tracer Line Drawing Demonstration
=======================================
The demonstrates tracking each touch registered to a device. You should
see a basic background image. When you press and hold the mouse, you
should see a cross-hairs with the coordinates written next to them. As
you drag, it leaves a trail. Additional information, like pressure,
will be shown if they are in your device's touch.profile.
This program specifies an icon, the file icon.png, in its App subclass.
It also uses the particle.png file as source for drawing the trails, which
white on transparent. The file touchtracer.kv describes the application.
The file android.txt is used to package the application for use with the
Kivy Launcher Android application. For Android devices, you can
copy/paste this directory into /sdcard/kivy/touchtracer on your Android device.
'''
__version__ = '1.0'

import kivy
Expand Down

0 comments on commit f16fe11

Please sign in to comment.