logo资料库

kivy 官方文档.pdf

第1页 / 共1053页
第2页 / 共1053页
第3页 / 共1053页
第4页 / 共1053页
第5页 / 共1053页
第6页 / 共1053页
第7页 / 共1053页
第8页 / 共1053页
资料共1053页,剩余部分请下载后查看
I User's Guide
Installation
Stable Version
Development Version
Philosophy
Why bother?
Contributing
Feedback
Reporting an Issue
Code Contributions
Documentation Contributions
Unit tests contributions
GSOC
FAQ
Technical FAQ
Android FAQ
Project FAQ
Contact Us
Issue Tracker
Mail
IRC
II Programming Guide
Kivy Basics
Installation of the Kivy environment
Create an application
Kivy App Life Cycle
Running the application
Customize the application
Platform specifics
Controlling the environment
Configuration
Path control
Restrict core to specific implementation
Metrics
Configure Kivy
Locating the configuration file
Understanding config tokens
Architectural Overview
Core Providers and Input Providers
Graphics
Core
UIX (Widgets & Layouts)
Modules
Input Events (Touches)
Widgets and Event Dispatching
Events and Properties
Introduction to the Event Dispatcher
Main loop
Widget events
Creating custom events
Attaching callbacks
Introduction to Properties
Declaration of a Property
Dispatching a Property event
Compound Properties
Input management
Input architecture
Motion event profiles
Touch events
Widgets
Introduction to Widget
Manipulating the Widget tree
Traversing the Tree
Widgets Z Index
Organize with Layouts
Adding a Background to a Layout
Nesting Layouts
Size and position metrics
Screen Separation with Screen Manager
Graphics
Introduction to Canvas
Context instructions
Drawing instructions
Manipulating instructions
Kv language
Concept behind the language
How to load KV
Rule context
Special syntaxes
Instantiate children
Event Bindings
Extend canvas
Referencing Widgets
Accessing Widgets defined inside Kv lang in your python code
Dynamic Classes
Re-using styles in multiple widgets
Designing with the Kivy Language
Integrating with other Frameworks
Using Twisted inside Kivy
Best Practices
Designing your Application code
Handle Window re-sizing
Managing resources
Platform consideration
Tips and Tricks
Advanced Graphics
Create your own Shader
Rendering in a Framebuffer
Optimizations
Packaging your application
Create a package for Windows
Creating packages for MacOSX
Create a package for Android
Create a package for IOS
Kivy on Android
III Tutorials
Pong Game Tutorial
Introduction
Getting Started
Add Simple Graphics
Add the Ball
Adding Ball Animation
Connect Input Events
Where To Go Now?
A Simple Paint App
Basic Considerations
Paint Widget
IV API Reference
Kivy framework
Animation
Application
Asynchronous data loader
Atlas
Cache manager
Clock object
Compatibility module for Python 2.7 and > 3.3
Configuration object
Context
Event dispatcher
Factory object
Garden
Geometry utilities
Gesture recognition
Interactive launcher
Kivy Base
Kivy Language
Logger object
Metrics
Parser utilities
Properties
Resources management
Support
Utils
Vector
Weak Method
Adapters
Adapter
DictAdapter
List Item View Argument Converters
ListAdapter
SelectableDataItem
SimpleListAdapter
Adapter
List Item View Argument Converters
DictAdapter
ListAdapter
SelectableDataItem
Data Models
SimpleListAdapter
Animation
Simple animation
Multiple properties and transitions
Sequential animation
Parallel animation
Repeating animation
Application
Creating an Application
Application configuration
Profiling with on_start and on_stop
Customising layout
Pause mode
Atlas
Definition of .atlas
How to create an Atlas
How to use an Atlas
Manual usage of the Atlas
Kivy Base
Event loop management
Cache manager
Clock object
Schedule before frame
Triggered Events
Compatibility module for Python 2.7 and > 3.3
Configuration object
Usage of the Config object
Available configuration tokens
Context
Core Abstraction
Audio
Camera
Clipboard
OpenGL
Image
Spelling
Text
Video
Window
Audio
Camera
Clipboard
OpenGL
Image
Spelling
Text
Text Markup
Text Markup
Video
Window
Effects
Damped scroll effect
Kinetic effect
Opacity scroll effect
Scroll effect
Damped scroll effect
Kinetic effect
Opacity scroll effect
Scroll effect
Event dispatcher
Extension Support
Factory object
Garden
Packaging
Geometry utilities
Gesture recognition
Graphics
The basics
GL Reloading mechanism
Canvas
Context instructions
Context management
Framebuffer
GL instructions
Graphics compiler
OpenGL
OpenGL utilities
Shader
Stencil instructions
Texture
Transformation
Vertex Instructions
Graphics compiler
Reducing the context instructions
Context management
Context instructions
Framebuffer
Reloading the FBO content
GL instructions
Clearing an FBO
Canvas
OpenGL
OpenGL utilities
Shader
Header inclusion
Single file glsl shader programs
Stencil instructions
Limitations
Example of stencil usage
Texture
Blitting custom data
BGR/BGRA support
NPOT texture
Texture atlas
Mipmapping
Reloading the Texture
Transformation
Input management
Input Postprocessing
Providers
Input recorder
Motion Event
Motion Event Factory
Motion Event Provider
Motion Event Shape
Motion Event Factory
Motion Event
Motion Event and Touch
Listening to a Motion Event
Profiles
Input Postprocessing
Dejitter
Double Tap
Ignore list
Retain Touch
Triple Tap
Dejitter
Double Tap
Ignore list
Retain Touch
Triple Tap
Motion Event Provider
Providers
NO DOCUMENTATION (module kivy.uix)
Auto Create Input Provider Config Entry for Available MT Hardware (linux only).
Common definitions for a Windows provider
Leap Motion - finger only
Mouse provider implementation
Native support for HID input from the linux kernel
Native support for Multitouch devices on Linux, using libmtdev.
Native support of MultitouchSupport framework for MacBook (MaxOSX platform)
Native support of Wacom tablet from linuxwacom driver
Support for WM_PEN messages (Windows platform)
Support for WM_TOUCH messages (Windows platform)
TUIO Input Provider
NO DOCUMENTATION (module kivy.uix)
Native support for HID input from the linux kernel
Leap Motion - finger only
Native support of Wacom tablet from linuxwacom driver
Native support of MultitouchSupport framework for MacBook (MaxOSX platform)
Mouse provider implementation
Disabling multitouch interaction with the mouse
Native support for Multitouch devices on Linux, using libmtdev.
Auto Create Input Provider Config Entry for Available MT Hardware (linux only).
TUIO Input Provider
Configure a TUIO provider in the config.ini
Configure a TUIO provider in the App
Common definitions for a Windows provider
Support for WM_PEN messages (Windows platform)
Support for WM_TOUCH messages (Windows platform)
Input recorder
Recording events
Manual play
Recording more attributes
Known limitations
Motion Event Shape
Interactive launcher
Creating an InteractiveLauncher
Interactive Development
Directly Pausing the Application
Adding Attributes Dynamically
Kivy Language
Overview
Syntax of a kv File
Value Expressions, on_property Expressions, and Reserved Keywords
Relation Between Values and Properties
Graphical Instructions
Dynamic classes
Templates
Redefining a widget's style
Lang Directives
External libraries
GstPlayer
GstPlayer
Asynchronous data loader
Tweaking the asynchronous loader
Logger object
Logger configuration
Logger history
Metrics
Dimensions
Examples
Manual control of metrics
Modules
Activating a module
Create your own module
Inspector
Keybinding
Monitor module
Recorder module
Screen
Touchring
Web Debugger
Inspector
Usage
Keybinding
Usage
Monitor module
Usage
Recorder module
Configuration
Usage
Screen
Touchring
Configuration
Example
Web Debugger
Network support
Url Request
Url Request
Parser utilities
Properties
Comparison Python vs. Kivy
Observe Properties changes
Binding to properties of properties.
Resources management
Storage
Usage
Examples
Synchronous / Asynchronous API
Synchronous container type
Dictionary store
JSON store
Redis Store
Dictionary store
JSON store
Redis Store
Support
Widgets
Abstract View
Accordion
Action Bar
Anchor Layout
Behaviors
Box Layout
Bubble
Button
Camera
Carousel
CheckBox
Code Input
Color Picker
Drop-Down List
FileChooser
Float Layout
Grid Layout
Image
Label
Layout
List View
ModalView
PageLayout
Popup
Progress Bar
Relative Layout
Sandbox
Scatter
Scatter Layout
Screen Manager
Scroll View
Settings
Slider
Spinner
Splitter
Stack Layout
Stencil View
Switch
TabbedPanel
Text Input
Toggle button
Tree View
VKeyboard
Video
Video player
Widget class
reStructuredText renderer
Abstract View
Accordion
Simple example
Customize the accordion
Action Bar
Anchor Layout
Behaviors
Box Layout
Bubble
Simple example
Customize the Bubble
Button
Camera
Carousel
CheckBox
Code Input
Usage example
Color Picker
Drop-Down List
Basic example
Extending dropdown in Kv
FileChooser
Simple example
Float Layout
Grid Layout
Background
Column Width and Row Height
Using a GridLayout
Image
Asynchronous Loading
Alignment
Label
Markup text
Interactive Zone in Text
Layout
Understanding the size_hint Property in Widget
List View
Introduction
Basic Example
Using an Adapter
ListAdapter and DictAdapter
Using an Args Converter
An Example ListView
Using a Custom Item View Class
Using an Item View Template
Using CompositeListItem
Uses for Selection
ModalView
Examples
ModalView Events
PageLayout
Popup
Examples
Popup Events
Progress Bar
Relative Layout
Coordinate Systems
reStructuredText renderer
Usage with Text
Usage with Source
Sandbox
Scatter
Usage
Control Interactions
Automatic Bring to Front
Scale Limitation
Behaviors
Scatter Layout
Screen Manager
Basic Usage
Changing transitions
Scroll View
Scrolling Behavior
Limiting to the X or Y Axis
Managing the Content Size and Position
Overscroll Effects
Settings
Create a panel from JSON
Different panel layouts
Slider
Spinner
Splitter
Stack Layout
Stencil View
Switch
TabbedPanel
Simple example
Customize the Tabbed Panel
Text Input
Usage example
Selection
Filtering
Default shortcuts
Toggle button
Tree View
Introduction
Creating Your Own Node Widget
Video
Video player
Annotations
Fullscreen
End-of-stream behavior
VKeyboard
Modes
Layouts
Request Keyboard
Widget class
Using Properties
Basic drawing
Widget event bubbling
Utils
Vector
Optimized usage
Vector operators
Weak Method
V Appendix
License
Python Module Index
Index
Kivy Documentation Release 1.8.1-dev www.kivy.org
CONTENTS I User’s Guide 1 Installation Stable Version . 1.1 . 1.2 Development Version . . . . . 2 Philosophy 2.1 Why bother? . . . . . . 3 Contributing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1 Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Reporting an Issue . 3.3 Code Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4 Documentation Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5 Unit tests contributions . 3.6 GSOC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 FAQ 4.1 4.2 Android FAQ . . 4.3 Technical FAQ . . . Project FAQ . 5 Contact Us 5.1 5.2 Mail 5.3 IRC . Issue Tracker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . II Programming Guide 6 Kivy Basics . . Running the application . 6.1 . 6.2 Create an application . . 6.3 Kivy App Life Cycle . . 6.4 . 6.5 Customize the application . . 6.6 Installation of the Kivy environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Platform specifics . . . . . . . . . . . . . . 7 Controlling the environment . . . . . . 7.1 Configuration . 7.2 . 7.3 7.4 Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Path control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Restrict core to specific implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5 5 22 25 25 27 27 27 28 30 31 34 41 41 42 43 47 47 47 47 49 51 51 65 65 67 68 69 71 71 71 71 72 i
8 Configure Kivy 8.1 Locating the configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2 Understanding config tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Architectural Overview . . . . . . . . . . . 9.1 Core Providers and Input Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.2 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3 Core . . . . 9.4 UIX (Widgets & Layouts) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.5 Modules . . 9.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.7 Widgets and Event Dispatching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Input Events (Touches) . . . . . . . . . . . . . . . . . . . . . . 10 Events and Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.1 Introduction to the Event Dispatcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.2 Main loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.3 Widget events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.4 Creating custom events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.5 Attaching callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.6 Introduction to Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.7 Declaration of a Property . 10.8 Dispatching a Property event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.9 Compound Properties . . . . . . . . . . . . . . 11 Input management 11.1 Input architecture . 11.2 Motion event profiles 11.3 Touch events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 73 73 75 76 76 76 77 77 77 78 79 79 80 81 82 82 82 83 83 86 87 87 88 88 12 Widgets . . . 91 91 12.1 Introduction to Widget 91 12.2 Manipulating the Widget tree . 92 . 12.3 Traversing the Tree . . 92 12.4 Widgets Z Index . . . . 12.5 Organize with Layouts 92 . 12.6 Adding a Background to a Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 12.7 Nesting Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 12.8 Size and position metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 12.9 Screen Separation with Screen Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Graphics . 13.1 Introduction to Canvas . 13.2 Context instructions . 13.3 Drawing instructions . 13.4 Manipulating instructions . . . . . . . . 111 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 . . . . 14 Kv language . . . 113 14.1 Concept behind the language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 14.2 How to load KV . . . . . 14.3 Rule context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 14.4 Special syntaxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 14.5 Instantiate children . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 . . . 14.6 Event Bindings . . 14.7 Extend canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 14.8 Referencing Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 14.9 Accessing Widgets defined inside Kv lang in your python code . . . . . . . . . . . . . . . 117 14.10 Dynamic Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
14.11 Re-using styles in multiple widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 14.12 Designing with the Kivy Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 15 Integrating with other Frameworks 15.1 Using Twisted inside Kivy . 123 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 16 Best Practices 127 16.1 Designing your Application code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 16.2 Handle Window re-sizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 . 16.3 Managing resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 . 16.4 Platform consideration . 16.5 Tips and Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 . . . . . . . . . . 17 Advanced Graphics 17.1 Create your own Shader . . 17.2 Rendering in a Framebuffer . 17.3 Optimizations . . . . . . . . . . 129 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 18 Packaging your application 131 18.1 Create a package for Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 18.2 Creating packages for MacOSX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 18.3 Create a package for Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 . 18.4 Create a package for IOS . 18.5 Kivy on Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 . . . . . . III Tutorials 143 . . . . . . . 19 Pong Game Tutorial . . . 19.1 Introduction . . 19.2 Getting Started . . . 19.3 Add Simple Graphics . 19.4 Add the Ball . . . 19.5 Adding Ball Animation . . 19.6 Connect Input Events . 19.7 Where To Go Now? . . . . . . . . 20 A Simple Paint App 20.1 Basic Considerations . 20.2 Paint Widget . . . . . . . . . 145 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 157 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 . . . . . . . . . . . . . . . . . . . . IV API Reference 167 . . . . . . . . . . . . . . . . . . . . . . . . . 21 Kivy framework 169 21.1 Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 . 21.2 Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 . 21.3 Asynchronous data loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 . . 21.4 Atlas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 . . 21.5 Cache manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 21.6 Clock object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 21.7 Compatibility module for Python 2.7 and > 3.3 . . . . . . . . . . . . . . . . . . . . . . . . . 201 . 21.8 Configuration object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 . 21.9 Context . 21.10 Event dispatcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 . . 21.11 Factory object . 21.12 Garden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
. . . . . 21.13 Geometry utilities . 21.14 Gesture recognition . . . 21.15 Interactive launcher . . . 21.16 Kivy Base . . . 21.17 Kivy Language . . . . . . . . 21.18 Logger object . . . . 21.19 Metrics . . . . . . . . 21.20 Parser utilities . . 21.21 Properties . . . . . 21.22 Resources management . . . 21.23 Support . . . 21.24 Utils . . 21.25 Vector . . . . 21.26 Weak Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 22 Adapters . . . . . . . 247 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 . 22.1 Adapter . 22.2 DictAdapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 22.3 List Item View Argument Converters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 . 22.4 ListAdapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 22.5 SelectableDataItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 . 22.6 SimpleListAdapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Adapter 24 List Item View Argument Converters 25 DictAdapter 26 ListAdapter 255 257 259 261 27 SelectableDataItem 27.1 Data Models . . . . . . . . . . . 265 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 28 SimpleListAdapter 29 Animation . . . . 29.1 Simple animation . 29.2 Multiple properties and transitions 29.3 Sequential animation . 29.4 Parallel animation . . 29.5 Repeating animation . . . . . . . . . . . . . 267 . . 269 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 30 Application 281 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 30.1 Creating an Application . . 30.2 Application configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 30.3 Profiling with on_start and on_stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 30.4 Customising layout 30.5 Pause mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 . . . . . . . . . . . . . . . . . 31 Atlas . 31.1 Definition of .atlas . . . 31.2 How to create an Atlas . 31.3 How to use an Atlas . . . 31.4 Manual usage of the Atlas . . . . . 32 Kivy Base 32.1 Event loop management . . iv 293 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 . . . . 297 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 . . . . .
33 Cache manager 34 Clock object 34.1 Schedule before frame . 34.2 Triggered Events . . . . 303 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 . . . . . . 301 35 Compatibility module for Python 2.7 and > 3.3 307 36 Configuration object 309 36.1 Usage of the Config object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 36.2 Available configuration tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 . . 313 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 37 Context 38 Core Abstraction . 38.1 Audio . . 38.2 Camera . . 38.3 Clipboard . . 38.4 OpenGL . . 38.5 Image . . . 38.6 Spelling . . 38.7 Text . . . . 38.8 Video . . 38.9 Window . . . . 39 Audio 40 Camera 41 Clipboard 42 OpenGL 43 Image 44 Spelling 45 Text 333 335 337 339 341 345 347 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 351 353 355 361 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 . . . . . . . . . . . . . . . . . . . . 365 367 369 371 v 45.1 Text Markup . . . . . . . . . . 46 Text Markup 47 Video 48 Window 49 Effects 49.1 Damped scroll effect . . 49.2 Kinetic effect . . 49.3 Opacity scroll effect 49.4 Scroll effect . . . . . . . . . 50 Damped scroll effect 51 Kinetic effect 52 Opacity scroll effect 53 Scroll effect
54 Event dispatcher 55 Extension Support 56 Factory object 57 Garden 57.1 Packaging . . . . . . . . . . . 58 Geometry utilities 59 Gesture recognition 60 Graphics . . . . . . . . . . . . . . . . . . 60.1 The basics . . 60.2 GL Reloading mechanism . . 60.3 Canvas . . 60.4 Context instructions . . . 60.5 Context management . . 60.6 Framebuffer . . . 60.7 GL instructions . . 60.8 Graphics compiler . . . . 60.9 OpenGL . . . . 60.10 OpenGL utilities . . 60.11 Shader . . . 60.12 Stencil instructions . . . . 60.13 Texture . . . 60.14 Transformation . . 60.15 Vertex Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 377 379 381 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 383 385 387 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438 . . . . . . . . . . . . . . . 61 Graphics compiler 447 61.1 Reducing the context instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 62 Context management 63 Context instructions 449 451 64 Framebuffer 64.1 Reloading the FBO content 65 GL instructions 65.1 Clearing an FBO . . . . . . . . . . 455 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 459 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 66 Canvas 67 OpenGL 68 OpenGL utilities 69 Shader 461 467 477 69.1 Header inclusion . 69.2 Single file glsl shader programs . . . . . . 479 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480 70 Stencil instructions 70.1 Limitations . . 70.2 Example of stencil usage . . . . . . 71 Texture 71.1 Blitting custom data . . . vi 481 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482 483 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 . . . . . . . . .
分享到:
收藏