Kivy DocumentationRelease 1.4.2-dev www.kivy.org CONTENTS I 1 User’s Guide Philosophy 1.1 Why bother? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Installation 2.1 Stable Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Development Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Programming Guide 3.1 Quickstart . . . . . . . . . . . . . . . 3.2 How to read the documentation . . 3.3 Controling the environment . . . . . 3.4 Configure Kivy . . . . . . . . . . . . 3.5 Architectural Overview . . . . . . . 3.6 Your First Widget . . . . . . . . . . . 3.7 Widget tree . . . . . . . . . . . . . . 3.8 Events . . . . . . . . . . . . . . . . . 3.9 Input management . . . . . . . . . . 3.10 Introduction to the Kivy Language . 3.11 Designing with the Kivy Language 3.12 Integrating with other Frameworks 3.13 Packaging your application . . . . . 3 5 5 7 7 16 19 19 20 21 22 23 26 34 35 38 41 45 46 49 59 59 71 71 71 72 74 75 79 79 80 80 83 83 83 83 2 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Tutorials 4.1 Pong Game Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Contributing 5.1 Feedback . . . . . . . . . . . . 5.2 Reporting an Issue . . . . . . . 5.3 Code Contributions . . . . . . 5.4 Documentation Contributions 5.5 Unit tests contributions . . . . 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 FAQ 6.1 Technical FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 Android FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3 Project FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Contact Us 7.1 Issue Tracker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3 IRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 i 8 Programming Guide 2 8.1 Basic Kivy . . . . . . . 8.2 Events and Properties 8.3 Widgets . . . . . . . . 8.4 Graphics . . . . . . . . 8.5 Kv language . . . . . . 8.6 Best Practices . . . . . 8.7 Advanced Graphics . 8.8 Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 85 94 94 94 94 94 94 94 II 9 API Reference Kivy framework 9.1 Animation . . . . . . . . . . 9.2 Application . . . . . . . . . 9.3 Asynchronous data loader 9.4 Atlas . . . . . . . . . . . . . 9.5 Cache manager . . . . . . . 9.6 Clock object . . . . . . . . . 9.7 Configuration object . . . . 9.8 Event dispatcher . . . . . . 9.9 Event loop management . . 9.10 Factory object . . . . . . . . 9.11 Gesture recognition . . . . 9.12 Interactive launcher . . . . 9.13 Kivy Language . . . . . . . 9.14 Logger object . . . . . . . . 9.15 Metrics . . . . . . . . . . . . 9.16 Parser utilities . . . . . . . . 9.17 Properties . . . . . . . . . . 9.18 Resources management . . 9.19 Support . . . . . . . . . . . 9.20 Utils . . . . . . . . . . . . . 9.21 Vector . . . . . . . . . . . . 9.22 Weak Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 97 98 108 115 116 118 120 123 126 127 129 130 131 134 141 142 144 145 151 151 152 153 156 159 159 160 161 161 162 164 165 167 168 175 177 177 177 192 195 198 10 Core Abstraction 10.1 Audio . . . 10.2 Camera . . 10.3 Clipboard . 10.4 OpenGL . . 10.5 Image . . . 10.6 Spelling . . 10.7 Text . . . . . 10.8 Video . . . . 10.9 Window . . 11 Extension Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Graphics 12.1 The basics . . . . . . . . . 12.2 GL Reloading mechanism 12.3 Canvas . . . . . . . . . . . 12.4 Context instructions . . . 12.5 Context management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii 12.6 12.7 12.8 12.9 12.10 12.11 12.12 12.13 12.14 12.15 Framebuffer . . . . GL instructions . . Graphics compiler OpenGL . . . . . . OpenGL utilities . Shader . . . . . . . Stencil instructions Texture . . . . . . . Transformation . . Vertex Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 200 201 202 210 211 212 214 219 219 227 229 230 235 237 241 241 241 13 Input management 13.1 Input Postprocessing . . 13.2 Providers . . . . . . . . 13.3 Input recorder . . . . . 13.4 Motion Event . . . . . . 13.5 Motion Event Factory . 13.6 Motion Event Provider 13.7 Motion Event Shape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 External libraries 243 14.1 jinja2.debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 15 Modules 15.1 Activate module in config . 15.2 Activate module in Python 15.3 Create my own module . . 15.4 Inspector . . . . . . . . . . . 15.5 Keybinding . . . . . . . . . 15.6 Monitor module . . . . . . 15.7 Recorder module . . . . . . 15.8 Screen . . . . . . . . . . . . 15.9 Touchring . . . . . . . . . . 245 245 245 245 246 246 246 246 247 247 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Network support 249 16.1 Url Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 17 Widgets 17.1 Accordion . . . . 17.2 Anchor Layout . 17.3 Box Layout . . . 17.4 Bubble . . . . . . 17.5 Button . . . . . . 17.6 Camera . . . . . 17.7 Carousel . . . . . 17.8 CheckBox . . . . 17.9 Code Input . . . 17.10 Drop-Down List 17.11 FileChooser . . . 17.12 Float Layout . . . 17.13 Grid Layout . . . 17.14 Image . . . . . . 17.15 Label . . . . . . . 17.16 Layout . . . . . . 17.17 ModalView . . . 17.18 Popup . . . . . . 253 253 257 258 259 262 263 264 266 267 268 270 272 273 276 278 283 284 286 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii 17.19 17.20 17.21 17.22 17.23 17.24 17.25 17.26 17.27 17.28 17.29 17.30 17.31 17.32 17.33 17.34 17.35 17.36 17.37 17.38 Progress Bar . . . . . . . . Relative Layout . . . . . . Scatter . . . . . . . . . . . Screen Manager . . . . . . Scroll View . . . . . . . . Settings . . . . . . . . . . Slider . . . . . . . . . . . . Spinner . . . . . . . . . . Stack Layout . . . . . . . Stencil View . . . . . . . . Switch . . . . . . . . . . . TabbedPanel . . . . . . . Text Input . . . . . . . . . Toggle button . . . . . . . Tree View . . . . . . . . . VKeyboard . . . . . . . . Video . . . . . . . . . . . . Video player . . . . . . . Widget class . . . . . . . . reStructuredText renderer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 288 289 291 296 300 305 307 308 309 309 311 315 321 322 327 330 332 336 341 III Appendix 345 347 349 351 18 License Python Module Index Index iv Welcome to Kivy’s documentation. Kivy is an open source software library for rapid development of applications equipped with novel user interfaces, such as multi-touch apps. We recommend that you get started with Getting Started. Then head over the Programming Guide. We also have a Quickstart if you are impatient. You are probably wondering why you’d be interested in using Kivy. There is a document outlining our Philosophy that we encourage you to read, and an detailed Architectural Overview. If you want to contribute to Kivy, make sure to read Contributing. If your concern isn’t addressed in the documentation, feel free to Contact Us. 1 2 . 3 .Part I USER’S GUIDE This part of the documentation explains the basic ideas behind Kivy’s design 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. 4 . Novel input methods such as Multi-Touch become increasingly important. OS X). to name just two good choices for application development. We’re not trying to force this new approach to using a computer into the corset of existing models (say single-pointer mouse interaction). Most importantly.1.1 Fresh Kivy is made for today and tomorrow. This applies to both: application development and application execution speeds. there are many great toolkits (or frameworks. That’s why we try to let the GPU do as much of the work as possible. More than once have we added support for new external devices and software protocols. especially drawing.1. thus increasing performance considerably. You have Qt and Flash. More importantly. Kivy is also flexible in that it is possible to use it in combination with a great number of different third-party solutions. Linux. rather ‘well-established’) toolkits carry their legacy. 1. specifically for this kind of interaction. Lastly. We have optimized Kivy in many ways. which 5 .1. We created Kivy from scratch. For example. this document is for you.3 Flexible Kivy is flexible. which is often a burden. or platforms) available out there – for free. sometimes even before they were released. That means we were able to rethink many things in terms of human computer interaction whereas older (not saying ‘outdated’. We support all major operating systems (Windows. including Android powered smartphones and tablets.2 Fast Kivy is fast. and many of these numerous solutions already support Multi-Touch. on Windows we support WM_TOUCH. This is what really sets Kivy apart. we also use intelligent algorithms to minimize costly operations. We want to let it flourish and let you explore the possibilities. We implement time-critical functionality on the C level to leverage the power of existing compilers. So what is it that makes Kivy special and worth using? 1. we use the GPU wherever it makes sense in our context.1 Why bother? Why would you want to use Kivy? After all. 1. This means it can be run on a variety of different devices. Being flexible also means that Kivy’s fast-paced development allows it to adapt to new technologies quickly.CHAPTER ONE PHILOSOPHY In case you are wondering what Kivy is all about and what sets it apart from different solutions. The computational power of today’s graphics cards surpasses that of today’s CPUs by far for some tasks and algorithms. 1. You can write a simple application with a few lines of code.means that any device that has Windows 7 Pen & Touch drivers will just work with Kivy. Kivy programs are created using the Python programming language. It’s not a small. the Kivy Language. 1. Kivy is a community-influenced. which is incredibly versatile. This language allows you to set up. professionally developed and commercially backed solution. In addition. In addition to that.1. powerful yet easy to use. You don’t even have to pay for it if you’re making money out of selling an application that uses Kivy. we support TUIO (Tangible User Interface Objects) and a number of other input sources. We took that burden off your shoulders.1. On OS X you can use Apple’s Multi-Touch capable devices.6 Free Kivy is free to use. such as trackpads and mice. we created our own description language. Kivy is here to stay. vanishing student project.4 Focused Kivy is focused. 1. 6 .1. We feel that allowing you to focus on the essence of your application is more important than forcing you to fiddle with compiler settings. connect and arrange your application elements quickly. Some of our core developers develop Kivy for a living. 1.5 Funded Kivy is actively developed by professionals in their field. You don’t have to pay for it. for creating sophisticated user interfaces. you can use HID kernel input events. On Linux. video playback) you don’t need the corresponding dependency. you need a Python 2. In addition. but to bring something innovative to the market. respectively. Other optional libraries (mutually independent) are: • OpenCV 2.0 – Camera input. We just want you to know about the alternatives for the defaults and give you an overview about the things Kivy uses internally. rich set of features that Kivy offers. high-quality third-party libraries where possible. To support the full.x (2. there is one dependency that Kivy does require: Cython.1.6 <= x < 3. • PIL – Image and text display. audio/video playback or spelling correction.1 Installation on Windows For Windows. we provide what we call a ‘portable package’.org/#download 7 . 2.g. Instead. we have created nice portable packages that you can use directly since they already contain the necessary packages for your platform. • PyEnchant – Spelling correction. You don’t have to install anything “system” wide. several other libraries are required. As a consequence.org/#download Please refer to the installation instructions for your specific platform: 2. That said. open a Window). we’re focused on our own code and use pre-existing. That said.. For these. Gst-Python and Enchant. however. additional dependencies must be available.1 Stable Version The latest stable version can be found on Kivy’s website at http://kivy. • PyCairo – Text display. • PyGST – Audio/video playback and camera input.CHAPTER TWO INSTALLATION We try not to reinvent the wheel. Just unzip & run: 1. DON’T PANIC! We don’t ask you to install all those things on your own. If you want to enable features like windowing (i. If you do not use a specific feature (e. we recommend Pygame.0) interpreter.e. Download the latest version from http://kivy. use it for launching any kivy application as described below Start a Kivy Application Send-to method You can launch a . Unzip the package 3. Copy the kivy. you have a script called kivy. in the unzipped package.py file with our Python using the Send-to menu: 1. Then.bat.bat in the Clipboard 8 .2. bat as a shortcut 9 . You should get the special windows directory SendTo 4. and to go the address ‘shell:sendto’ 3. Open the explorer. Paste the previously copied kivy.2. you can execute application by doing a right click on the . 10 .py file -> “Send To” -> “Kivy <version>”.5. Rename it to Kivy <kivy-version> Then. Select “Always open the file with. When you install msysGit.py file. You are done. Browse your hard disk drive and find the file kivy. Normally this should not be harmful as it’s just a normal version of Python with the necessary third party libraries added to the module search path.” if you don’t want to repeat this procedure every time you double click a . Right click on the main python file (. Select it. 4. You need a minimalist GNU system installed on your system.py ending) of the application you want to launch 2. you must select theses options: 11 . you will set Kivy’s version of Python as the default for opening .Double-click method There are some simple steps that you need to do once in order to be able to launch any kivy application by just double-clicking it: 1. Start from Command-Line If you just want to use or develop with the latest stable kivy version. Use msysGit.bat from the portable package.py file. please Contact Us. select Open With 3. 5. Open the file. The next time you double click a . Note: On Windows we have to ship our own version of Python since it’s not installed by default on Windows (unlike Mac OS X and Linux). it will be executed with the version of python that Kivy ships with. From the context menu that appears... we offer an alternative way with a console.py files for your user. By following the steps above. If you do encounter unexpected problems. ) You are now ready to launch python/kivy from the command-line! Just do: python <filename.bat etc.py> Also. You might encounter issue during the development. Download and install Kivy for windows as the explained before 2. Rename the directory named “kivy-<some hash>” to just “kivy” 7. kivy.stable 4. such as: • cython • gcc / make. Mingw.. and download the latest development version of Kivy 5. commit as-is (no CLRF replacement!) You’ll have an icon “Git bash” on your desktop.10 Use development Kivy Warning: Using the latest development version can be risky. Go into the portable Kivy directory. where is located Python. Extract the zip into the Kivy portable directory 6. Start “Git bash” 2.1 • Glew 1. Go on github. If you want to use the latest development version of Kivy.• Don’t replace windows shell • Checkout as-is. Rename the kivy directory to kivy. you can follow theses step: 1.bat 8.9. • easy_install • gst-inspect-0.. this is the console we want: 1. you have a latest development version! Package Contents The latest Windows package contains: • Latest stable kivy version • Python 2.sh <full directory path of portable kivy> # (don’t use . Launch kivy. 3. please report it.5.7. cd <directory of portable kivy> 3.7 • Pygame 1. If you hit any bug. source kivyenv.2 12 . all other scripts and binaries are available. Go to the Kivy portable directory/kivy 9. Type: make force 10. That’s all. app • Readme.app and run kivy. To test if it worked: 1. 3.6 32-bit. Download the latest version from http://kivy.txt Start any Kivy Application You can run any Kivy application by simply dragging the application’s main file onto the Kivy. it worked.app into the Applications folder. Start from Command Line If you want to use Kivy from the command line. Open Terminal. you must: 1.3 Installation on Linux Prerequisites Ubuntu (11.app into your Applications folder 4. Double-click to open it 3. 2. We suggest using homebrew to do that. For Mac OS X 10. we provide a Kivy.txt • An Examples folder • A script to install a kivy command for shell usage To install Kivy.1.6 and later. Make sure to read the Readme.app with all dependencies bundled. Just try with any python file in the examples folder.py 2. You should get a Python prompt.14 • MinGW • GStreamer • Setuptools 2.6 or 10.org/#download 2. double-click the Make Symlinks script after you dragged the Kivy.1.app icon. Download it from our google code project page.dmg file that contains: • Kivy. It comes as a .• Cython 0. For versions prior to 10. Running any Kivy application from the command line is now simply a matter of executing a command like the following: kivy yourapplication.10 or newer) 13 . you have to install the components yourself. Drag the Kivy.6 Snow Leopard 64-bit. enter import kivy.2 Installation on MacOSX Note: This method has only been tested on Mac OSX 10. In there. If it just goes to the next line without errors. you must known first where easy_install have installed your current kivy package.resource_filename(’kivy’.10-plugins-good python-dev \ build-essential libgl1-mesa-dev libgles2-mesa-dev python-pip $ sudo pip install --upgrade cython Fedora (16) $ sudo yum install python-distutils-extra python-enchant freeglut PyOpenGL \ SDL_ttf-devel SDL_mixer-devel pygame pygame-devel khrplatform-devel \ mesa-libGLES mesa-libGLES-devel gstreamer-plugins-good gstreamer \ gstreamer-python mtdev-devel python-pip $ sudo pip install --upgrade cython OpenSuse (12. print pkg_resources. and go to the example directory: $ python -c "import pkg_resources. ’. That’s mean./share/kivy-e And you should have a path similar to: 14 . do: $ sudo easy_install kivy If you already installed kivy before.1) $ sudo zypper install python-distutils-extra python-pygame python-opengl \ python-gstreamer-0_10 python-enchant gstreamer-0_10-plugins-good \ python-devel Mesa-devel python-pip $ zypper install -t pattern devel_C_C++ $ sudo pip install --upgrade cython Mageia (1 and 2(cauldron)) $ su $ urpmi python-setuptools python-pygame python-opengl \ gstreamer0.10-python python-enchant gstreamer0.10 python-enchant gstreamer0. you can upgrade it with: $ sudo easy_install --upgrade kivy Start from Command Line We are shipping some examples ready-to-run.$ sudo apt-get install python-setuptools python-pygame python-opengl \ python-gst0..10-plugins-good \ python-cython lib64python-devel lib64mesagl1-devel lib64mesaegl1-devel \ lib64mesaglesv2_2-devel make gcc $ sudo easy_install pip $ sudo pip install --upgrade cython Installation If you’re installing Kivy for the first time. theses examples are packaged inside the package. However. Select your phone. check http://kivy.4_beta-py2. Refer to Kivy on Android for a more detailed explanation. Go to the Kivy Launcher on the Google Play Store 2. Unzip the content.6/dist-packages/Kivy-1. We’ll provide instructions for packaging your Kivy application in a standalone way in the future. Copy all the folders to /sdcard/kivy 4. Then. Showcase. 15 .py launch pictures cd <path to kivy-examples> cd demo/pictures python main.py If you don’t know about Unix and symbolic link. Click on Install 3. Touchtracer.6-linux-x86_64. for an easier access..org/#download for downloading the APK manually.. For example: 1. Now. Get the example path from the command line above 2. And you’re done! If you don’t have Google Play Store on your tablet. you can access to kivy-examples directly in your Home directory: $ cd ~/kivy-examples 2. and run it: # $ $ $ # $ $ $ launch touchtracer cd <path to kivy-examples> cd demo/touchtracer python main. Cymunk demo. and go to the kivydemo-for-android 3.4 Installation on Android Please note that Kivy is a framework. Installation of Examples 1. Download the Kivy demos for Android 2. you can create a link directly in your home directory. we provide a “launcher” that allows you to push your Kivy application onto your phone and execute it through a simple interface. To install the Kivy launcher. Run the launcher and select one of Pictures..1. Installing Kivy itself on your phone will do absolutely nothing.. you must: 1.egg/share/kivy-examples Then you can go to the example directory./usr/local/lib/python2.0. you can put your Kivy applications in the Kivy directory on the SD Card. Paste in your console: $ ln -s <path to kivy-examples> ~/ 3. Kivy is not an application. That said. please read Contributing. a set of unittests is provided. follow the guide below for your platform.2. 2. maybe a test will show this. For that.git $ cd kivy $ # Compile: $ python setup. and then. please see our Contributing document. it might be a good time to write one . 2. Afterwards you have to set up Kivy on your computer in a way that allows for easy development.2. A good thing to do is to run it just after kivy installation. or you think something was broken in kivy. you’re running potentially broken code at your own risk.1 Installing Dependencies To install Kivy’s dependencies. Note that when running a development version.2 Development Version The development version is for developers and testers. so it’s better to use the last version published on pypi.) 16 .10 python-enchant gstreamer0. Ubuntu For Ubuntu. with sudo): $ python setup.2. Python will instead import Kivy from your clone. every time you intend to push a change.2 Installing Kivy for Development Now that you’ve installed all the required dependencies. if you don’t want to make any changes to Kivy itself.3 Running the test suite To help detect issues and behaviour changes in kivy.10-plugins-good python-dev \ build-essential libgl1-mesa-dev libgles2-mesa-dev python-pip Kivy require a recent version of cython. This way you don’t have to install (setup. If not. it’s time to download and compile a development version of Kivy: $ # Download Kivy from GitHub $ git clone git://github. new features) to the Kivy code base.com/kivy/kivy.2. you can also use the following shortcut to compile (does the same as the last command): $ make If you want to modify the Kivy code itself. you will first need to install the dependencies. set up the PYTHONPATH environment variable to point at your clone.g. you can also run (as admin. To use the development version. :: $ sudo pip install –upgrade cython 2.py install) after every tiny modification. simply enter the following command that will install all necessary packages: $ sudo apt-get install python-setuptools python-pygame python-opengl \ python-gst0.py install If you want to contribute code (patches.py build_ext --inplace -f If you have the make command available. Or. e. do: $ sudo apt-get remove --purge python-kivy 17 .7/dist-packages/Kivy-1. you can use the command line: $ python -c ’import kivy.7-py2.0. if you have multiple kivy versions installed in the Python library path.0.7-linux-x86_64.7-linux-x86_64.Kivy tests are based on nosetest. remove that directory recursively. do : $ make test 2. Remove that as well: $ python -c ’import kivy.4 Uninstalling Kivy If you are mixing multiple Kivy installations.2.7-py2.__path__’ [’/usr/local/lib/python2. print kivy.egg/kivy’] $ sudo rm -rf /usr/local/lib/python2. the directory may contain a “egg” directory. that you can install from your package manager or using pip : $ pip install nose to run the test suite.__path__’ Then.7/dist-packages/Kivy-1.egg If you have installed with apt-get. To find your current installed version. If you have installed Kivy with easy_install on linux. you might be confused about where each Kivy version is located. Please note that you might need to follow these steps multiple times. print kivy. 18 . require(’1.app import App from kivy.py Mac OS X Follow the instructions for running Kivy application on MacOSX: $ kivy main. If you do not. To run the application.button import Button class MyApp(App): def build(self): return Button(text=’Hello World’) if __name__ == ’__main__’: MyApp().py. 19 .py Windows Follow the instructions for running Kivy application on Windows: $ python main.1 Quickstart This page explains how to create a simple Kivy “Hello world” program.py # or C:\appdir>kivy. head over to the Installation section.py Android Your application needs some complementary files to be able to run on Android. This assumes you already have Kivy installed.bat main.x knowledge throughout the rest of this documentation.run() Save it as main.1 Create an application The base code for creating an application looks like this: import kivy kivy.1. See Kivy on Android for further reference.uix.CHAPTER THREE PROGRAMMING GUIDE 3. We also assume basic Python 2.0. follow the instructions for your operating system: Linux Follow the instructions for running Kivy application on Linux: $ python main.6’) # replace with your current kivy version ! from kivy. 3. 3. If not. based on the App class. we create our application class. 3. So what does that code do? 1.2. First. • the API: all the functions. specially if you never done GUI programming before. This instance will be used as the root of the widget tree (because we returned it). it will be generated like this: 20 . Then. 2. We extend the build() function to be able to return an instance of Button. we call run() on our application instance to launch the Kivy process with our application inside. showing a sole button (with the label ‘Hello World’) that covers the entire window’s area.1 Importing a class The API part is autogenerated from the source code. You can read the documentation of kivy. classes. 3. By subclassing this class. to be able to create an instance of a button with a custom label. methods are explained.2 How to read the documentation The documentation is seperated in 2 parts: • the Programming Guide: it’s a must read to understand the Kivy basics. and prevent your application to crash in runtime. we import the Button class.A window should open. If you take any class. Finally. 5. to be able to subclass it. We import the App class. and check if the current installed version will be enough for our application. an exception will be automatically fired.require() function for more information. That’s all there is to it. 4. we import Kivy. your own class gains several features that we already developed for you to make sure it will be recognized by Kivy. Next. KIVY_NO_CONFIG If set.2 Path control New in version 1.1 Configuration KIVY_USE_DEFAULTCONFIG If this name is found in environ. you might want to restrict the selector to a specific implementation.7. KIVY_NO_FILELOG If set.uix. KIVY_DATA_DIR Location of the Kivy data.button import Button 3.3.3 Restrict core to specific implementation kivy. extensions. So if you want to import that class in your code.uix.It should be read like this: the “Button” class is in the “kivy. default to <kivy path>/modules 3. logs will be not print on the console 3.3. KIVY_WINDOW Implementation to use for creating the Window Values: pygame 21 .3. logs will be not print on a file KIVY_NO_CONSOLELOG If set. You can control where is located default directory of modules.0. For testing or custom installation. default to <kivy path>/extensions KIVY_MODULES_DIR Location of the Kivy modules. no configuration file will be read or write. default to <kivy path>/data KIVY_EXTS_DIR Location of the Kivy extensions.py Environment variable can be set before importing kivy: import os os. and no user configuration directory too. Kivy will not read the user config file.button” module. for restricting text rendering to PIL implementation: $ KIVY_TEXT=pil python main.3 Controling the environment Many environment variables are available to control the initialization and behavior of Kivy. and kivy datas.core try to select the best implementation available for your platform. write that: from kivy.environ[’KIVY_TEXT’] = ’pil’ import kivy 3. For example. 4.5.KIVY_TEXT Implementation to use for rendering text Values: pil. 3.0.0. pygame KIVY_IMAGE Implementation to use for reading image Values: pil.config module.1 Locating the configuration file The location of the configuration file is in: <HOME_DIRECTORY>/.ini • MacOSX: /Users/tito/.4 Metrics KIVY_DPI If set. KIVY_METRICS_DENSITY If set.kivy/config.4 Configure Kivy The configuration file of kivy is named config. opencv. osxappkit KIVY_CLIPBOARD Implementation to use for clipboard management Values: pygame. ffmpeg KIVY_AUDIO Implementation to use for playing audio Values: gstreamer. the value will be used for Metrics.5.dpi.kivy\config. New in version 1. pygame KIVY_CAMERA Implementation to use for reading camera Values: gstreamer.3. 22 . the value will be used for Metrics.ini If your user is named “tito”. the file will be located at: • Windows: C:\Users\tito\.density.0. following the INI format file.4. videocapture KIVY_SPELLING Implementation to use for spelling Values: enchant. KIVY_METRICS_FONTSCALE If set. New in version 1. pyglet.ini • Linux: /home/tito/.kivy/config.ini 3.fontscale. New in version 1.4. 3.kivy/config. the value will be used for Metrics.2 Understanding config tokens All the configuration tokens are explained in the kivy. pygame KIVY_VIDEO Implementation to use for rendering video Values: gstreamer. dummy 3.ini. 1 Core Providers and Input Providers One idea that is key to understanding Kivy’s internals is that of modularity and abstraction. chances are you will get a rough idea already. For example. We try to abstract from basic tasks such as opening a window. We call these core tasks. it allows us to use – what we call – specific providers for the respective scenario in which your app is being run. This makes the API both easy to use and easy to extend. 3. spelling correction and so on. Most importantly. but since this approach certainly is daunting for most users. getting images from a camera. by using libraries that are shipped 23 . Furthermore. This is key to understanding how everything works together.5 Architectural Overview We would like to take a moment to explain how we designed Kivy from a software engineering point of view. It also gives users a choice. displaying images and text. this section explains the basic ideas of the implementation in more detail. Linux and Windows. You can skip this section and refer to it later.5. The advantage of using specialized core providers for each platform is that we can fully leverage the functionality exposed by the operating system and act as efficiently as possible. but we suggest at least skimming it for a rough overview. there are different native APIs for the different core tasks.3. If you just look at the code. on OSX. playing audio. A piece of code that uses one of these specific APIs to talk to the operating system on one side and to Kivy on the other (acting as an intermediate communication layer) is what we call a core provider. Kivy consists of several building blocks that we will explain in the following. buttons. This is especially helpful if you’re not an expert at tuning OpenGL. we effectively reduce the size of the Kivy distribution and make packaging easier.5.with any one platform. Layouts You use layouts to arrange widgets. of course. On the lowest level.g. It is our own properties class that links your widget code with the user interface description. 3. such as Apple’s trackpads. It’s also easier to port Kivy to other platforms. You can train it to detect your own strokes. Examples would be a file browser. Widgets receive MotionEvents. You can also nest layouts. An input provider is a piece of code that adds support for a specific input device. We follow the same concept with input handling. etc. sliders. lists and so on. 24 . Another advantage of the graphics API is its ability to automatically optimize the drawing commands that your code issues. but often it is more convenient to use one of our ready made layouts. 3. This makes your drawing code more efficient in many cases. You can. Writing OpenGL code however can be a bit confusing.4 UIX (Widgets & Layouts) The UIX module contains commonly used widgets and layouts that you can reuse to quickly create a user interface. The Android port did greatly benefit from this. TUIO or a mouse emulator. especially to newcomers. Canvas. such as: Clock You can use the clock to schedule timer events. Examples would be Grid Layouts or Box Layouts.3 Core The code in the core package provides commonly used features. All of our widgets themselves use this graphics API. so if you want to stay cross-platform compatible. Gesture Detection We ship a simple gesture recognizer that you can use to detect various kinds of strokes. you can use our class for that instead of writing your own. That’s why we provide the graphics API that lets you draw things using simple metaphors that do not exist as such in OpenGL (e.5.5. Rectangle. Both one-shot timers and periodic timers are supported Cache If you need to cache something that you use often. 3. we advise you to only use the GLES2 functions.). which is implemented on the C level for performance reasons. Properties These are not the normal properties that you may know from python. Kivy issues hardwareaccelerated drawing commands using OpenGL. The version we target is OpenGL 2. you can simply provide a new class that reads your input data from your device and transforms them into Kivy basic events. such as circles or rectangles. Widgets Widgets are user interface elements that you add to your program to provide some kind of functionality. It is of course possible to calculate your widgets’ positions yourself.0 ES (GLES2) on all devices. They may or may not be visible. If you need to add support for a new input device. Kivy Language The kivy language is used to easily and efficiently describe user interfaces.2 Graphics Kivy’s graphics API is our abstraction of OpenGL. still use raw OpenGL commands if you prefer that. If you know the input sources your users will be using. even if the original author did not include it. Otherwise. A ‘Move’ happens whenever the 2D position of a touch changes. 3. There is exactly one root widget at the top of the tree that has no parent widget. This kind of input is handled separately.3. (Note that this does not only refer to finger touches. you will know whether or not you can rely on this state being entered. and all other widgets are directly or indirectly children of this widget (which is why it’s called the root). or never. It does not necessarily have to have a visible representation on the screen. a tilt of your device. When a touch enters one of these states. Kivy sends out one event per touch. on_touch_move or on_touch_up event handler being called. Each widget (this includes the root widget) in the tree can choose to either digest or pass the event further.5. Move A touch can be in this state for a potentially unlimited time.) All of these input types are represented by instances of the Touch() class. When new input data is available. Modules can be used to inject functionality into Kivy programs. (There are other input devices such as accelerometers where you cannot easily find a 2D position for e. The root widget of the widget tree first receives the event. but all the other input types as well. a widget is an object that receives input events. the event handler passes the widget on to its own children by calling its superclass’s implementation of the respective event handler. which results in the root widget’s corresponding on_touch_down. In the following we describe the former types.5. All widgets are arranged in a widget tree (which is a tree data structure as known from computer science classes): One widget can have any number of child widgets or none. which – in its touch event handlers – does nothing but pass the touches to its children: 25 . 3. Depending on the state of the touch.5.) A touch instance. Up A touch goes up at most once. your program is informed that the event occurred. but it is not guaranteed. No further processing will happen with that event.5 Modules If you’ve ever used a modern web browser and customized it with some add-ons then you already know the basic idea behind our module classes.6 Input Events (Touches) Kivy abstracts from different input types and sources such as touches.g. TUIO or similar. If an event handler returns True it means that the event has been digested and handled properly. or object. For Kivy. the on_touch_down. An example would be a module that always shows the FPS of the current application and some graph depicting the FPS over time. In practice you will almost always receive an up event because nobody is going to hold a finger on the screen for all eternity. on_touch_move or on_touch_up event is dispatched (with the touch as the argument) to the root widget. at the very moment where it first appears. You can also write your own modules. mice. The three states a touch can be in are: Down A touch is down only once. This goes all the way up to the base Widget class. We just called it Touch for the sake of simplicity. What all of these input types have in common is that you can associate a 2D onscreen-position with any individual input event. A touch does not have to be in this state during its lifetime. Think of it of something that touches the user interface or your screen. can be in one of three states.7 Widgets and Event Dispatching The term widget is often used in GUI programming contexts to describe some part of the program that the user interacts with. defines the user’s interaction with that data and draws its visual representation. Often you would like to be able to reuse code that you already wrote in a different context. 3. which is why widgets typically represent one specific instance that answers the three questions above. You have? Great! Let’s get started! 26 . 3. you need a custom widget that is beyond the scope of what is shipped with Kivy (e. While doing so. There are many widgets built in. Often times you will want to restrict the area on the screen that a widget watches for touches. touch): for child in self. your application would memorize the positions where the user’s finger was. a medical visualization widget). an applications user interface is composed of Widgets.children[:]: if child.e. a widget does exactly what its supposed to do and nothing more. In many cases. x & y) and size (width & height). as it lets you create completely new user interfaces with custom elements for your specific purpose. So keep these three questions in mind when you design your widgets.6. By default.6.# This is analogous for move/up: def on_touch_down(self. In Kivy. You can use a widget’s collide_point() method to achieve this. this checks the rectangular region on the screen that’s described by the widget’s pos (for position. Make sure that you have read and understood Quickstart. you have to ask yourself three main questions: • What data does my application process? • How do I visually represent that data? • How does the user interact with that data? If you want to write a very simple line drawing application for example. Allow us to help you achieve that.g. A widget encapsulates data. Try to write them in a minimal and reusable manner (I. sliders and other common stuff. In the following sections you will successively learn how to write a program like that using Kivy. such as buttons. touch): return True This really is much easier than it first seems. That’s how the user interacts with your application. This provides very powerful and important knowledge when programming Kivy applications.dispatch(’on_touch_down’. but you can override this behaviour in your own class. however. You can then build anything from simple to complex user interfaces by nesting widgets. An example of how this can be used to create nice applications quickly will be given in the following section.6 Your First Widget In the following you will be guided through the creation of your first widget. So the points where the fingers were would be your data and the lines that you draw between these would be your visual representation. If you need more. Everything that you see on the screen is somehow drawn by a widget. write more widgets or compose other widgets of smaller widgets). you most likely want the user to just draw on the screen with his fingers. so that you can later draw lines between those positions.1 Basic Considerations When creating an application.2 Paint Widget We’re sure one of your childhood dreams has always been creating your own multitouch paint program. You simply pass it the touch’s position and it returns True if the touch is within the ‘watched area’ or False otherwise. 3. if you write import paint. instead of doing something like from kivy import *.Initial Structure Let’s start by writing the very basic code structure that we need. The way we do it is faster and cleaner. Note: You may be wondering why you have to import App and Widget separately. The if __name__ .uix.py. It’s also not as clear what your application uses. i.app import App from kivy. so you don’t need to copy & paste it all the time. this would have the disadvantage of cluttering your namespace and making the start of the application potentially much slower.. we are going to write our own widget to do the drawing.. Change the code like so: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 from kivy. it won’t do something unexpected but just nicely provide the classes defined in the file. we can still treat it like a normal Kivy widget (line 11). instead of using a built-in widget such as Button (see Quickstart). While shorter. all the different pieces of code that are used in this section are also available in the examples/guide/firstwidget directory that comes with Kivy.app import App from kivy. construct (line 14) is a Python mechanism that prevents you from executing the code in the if-statement when importing from that file.run() This is actually really simple. Save it as paint. If you run it.uix.e.run() 27 .widget import Widget class MyPaintWidget(Widget): pass class MyPaintApp(App): def build(self): return MyPaintWidget() if __name__ == ’__main__’: MyPaintApp(). By the way. touch): print touch class MyPaintApp(App): def build(self): return MyPaintWidget() if __name__ == ’__main__’: MyPaintApp(). you should only see a black screen. i. Adding Behaviour Let’s now add some actual behaviour to the widget.e.widget import Widget class MyPaintWidget(Widget): def on_touch_down(self. As you can see. make it react to user input. We do that by creating a class that inherits from Widget (line 5-6) and although that class does nothing yet. Here is the basic code skeleton that we will need: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 from kivy. x .This is just to show you how easy it is to react to user input. there will be a small yellow circle drawn where you touched. d)) class MyPaintApp(App): def build(self): return MyPaintWidget() if __name__ == ’__main__’: MyPaintApp(). Now that’s not really an overwhelming user experience. 1.run() If you run your code with these modifications. This also demonstrates that a widget does not always have to have a visual representation. internal state can be cleaned up properly.d / 2. you will see a message for every touch (initially). Ellipse class MyPaintWidget(Widget): def on_touch_down(self. but if you observe the command-line from which you are running the program.canvas: Color(1. etc. you will see that every time you touch.y . a touch. When a MotionEvent (i.uix. You won’t see anything on the screen. Ellipse(pos=(touch. 28 . touch): with self.e. click.) occurs. size=(d. The with statement also makes sure that after our drawing. This is like an area in which the widget can draw things to represent itself on the screen. How does it work? • Line 8: We use Python’s with statement with the widget’s Canvas object. Let’s add some code that actually draws something into our window: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 from kivy.d / 2). 0) d = 30.widget import Widget from kivy. touch.app import App from kivy. all successive drawing commands that are properly indented will modify this canvas. we simply print the information about the touch object to the console. By using the with statement with it.graphics import Color. d)) touch. touch.x. That was easy.uix. touch): touch. left and downwards) because the position specifies the bottom left corner of the ellipse’s bounding box. Ellipse(pos=(touch. 0) d = 30.app import App from kivy.points += [touch.e.y] class MyPaintApp(App): def build(self): return MyPaintWidget() if __name__ == ’__main__’: MyPaintApp(). we pass the touch’s position to the ellipse.ud[’line’]. Line class MyPaintWidget(Widget): def on_touch_down(self.x.run() 29 .d / 2. Since we want the circle to be drawn where the user touches. touch. Think of this as dipping your brushes in that color which you can then use to draw on a canvas until you dip the brushes into another color. touch): with self. 1. 0) is yellow). This is true until another color is set. 1. so (1.• Line 9: You might have guessed it already: This sets the Color for successive drawing operations to yellow (default color format is RGB.y . size=(d. • Line 11: To draw a circle.x .graphics import Color.y)) def on_touch_move(self. and we want it to be centered around our touch.widget import Widget from kivy.canvas: Color(1. Ellipse.ud[’line’] = Line(points=(touch. • Line 10: We specify the diameter for the circle that we are about to draw.d / 2). Note that we need to shift the ellipse by -d/2 in the x and y directions (i. we simply draw an Ellipse with equal width and height. touch. Using a variable for that is preferable since we need to refer to that value multiple times and we don’t want to have to change it in several places if we want the circle bigger or smaller. wasn’t it? It gets better! Update the code to look like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 from kivy. Ellipse. y1. xN.ud dictionary! To the line we set up for this touch earlier. Since this is done in on_touch_down. It looks a bit like spaghetti bolognese. . By creating the line inside the with block.ud is a Python dictionary (type <dict>) that allows us to store custom attributes for a touch. let’s do it: 1 2 3 4 5 6 from from from from random import random kivy. yN).. We just want to modify the line later. This isn’t exactly beautiful yet. This is similar to the on_touch_down method. so we can simply access the data we stored away in the touch. • Line 13: We make use of the Line instruction that we imported and set a Line up for drawing. but instead of being called when a new touch occurs.app import App kivy. its position changes. like (x1.This is what has changed: • Line 3: We now not only import the Ellipse drawing instruction. Note that this is the same MotionEvent object with updated attributes. which is exactly why we want to update the line.graphics import Color.. but also the Line drawing instruction.ud makes it a whole lot easier for us as we don’t have to maintain our own touch-to-line bookkeeping. i. So far so good.e. touch.ud dictionary under the arbitrarily chosen but aptly named key ‘line’.uix. • Lines 15: We add a new method to our widget. you will see that it accepts a points argument that has to be a list of 2D point coordinates. Line 30 . If you look at the documentation for Line.. which is only called when the touch has moved. so we store a reference to it in the touch. y2. there will be a new line for every new touch. x2. What about we give each touch its own color? Great. We know that we need to extend the line because this happens in on_touch_move. we now add the current position of the touch as a new point. though. the canvas automatically knows about the line and will draw it. We pass the line that we’re creating the initial touch position because that’s where our line will begin. Storing the line in the touch. • Line 13: This is where it gets interesting. This is something we found incredibly handy and you will shortly see why.widget import Widget kivy. • Line 16: Remember: This is the same touch object that we got in on_touch_down. this method is being called when an existing touch (for which on_touch_down was already called) moves. • Line 10: In this case we simply create a new tuple of 3 random float values that will represent a random RGB color. regardless of the fact that the tuple itself contains 3 values).x.points += [touch.). • Line 12: As before. Only this time we use the random values we generated and feed them to the color class using Python’s tuple unpacking syntax (since the Color class expects three individual color components instead of just 1. every new touch will get its own color. touch.canvas: Color(*color) d = 30. touch. touch): touch. you might even be able to create a nice 31 . We’re just binding the tuple to color as well as a shortcut for use within this method because we’re lazy. size=(d. If we were to pass the tuple directly.y] class MyPaintApp(App): def build(self): return MyPaintWidget() if __name__ == ’__main__’: MyPaintApp(). This looks a lot nicer already! With a lot of skill and patience. touch. random().x.run() Here are the changes: • Line 1: We import Python’s random() function that will give us random values in the range of [0. 1.ud[’line’] = Line(points=(touch.. we set the color for the canvas. that would be just 1 value being passed. d)) touch.7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 class MyPaintWidget(Widget): def on_touch_down(self.ud[’line’]. Ellipse(pos=(touch. Don’t get confused by the use of two = operators. touch): color = (random().y .x .d / 2).d / 2. random()) with self.y)) def on_touch_move(self. Since we do this in on_touch_down. The widget does what it’s supposed to do: It traces the touches and draws lines. That would be bad because by default the background color is dark as well.x.points += [touch. touch.d / 2). set the mode to HSV color space: Color(*color.uix.ud[’line’].y)) def on_touch_move(self. every widget gets its own button. We’ll go with the second option here so that you see how you can build up your application’s widget tree in your app class’s build() method. But what if the user wants to start a new drawing? With the current code. Ellipse(pos=(touch. • Or we set up the button only once. touch): touch. mode=’hsv’).x . we could say we are done.widget import Widget kivy.ud[’line’] = Line(points=(touch. If you’re not careful. create a tuple like this: (random().y] class MyPaintApp(App): def build(self): parent = Widget() painter = MyPaintWidget() 32 . It even still draws circles at the positions where a line begins. Ellipse. touch): color = (random(). touch.app import App kivy.button import Button kivy.canvas: Color(*color.little drawing! Note: Since by default the Color instructions assume RGB mode and we’re feeding a tuple with three random float values to it. touch. We’ll also change to the HSV color space (see preceding note): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 from from from from from random import random kivy.d / 2. For larger applications you should give some thought to who does what in your code. initially. this will also allow users to draw on top of the button. we can do better. that doesn’t really matter at all. which might not be what you want. Bonus Points At this point. Luckily. the only option to clear the window would be to restart the entire application. so you wouldn’t be able to (easily) see the lines you draw.y . it might very well happen that we end up with a lot of dark or even black colors if we are unlucky. Let us add a Clear button that erases all the lines and circles that have been drawn so far. when passing it to the color instruction.graphics import Color. 1. 1) with self. There are two options now: • We could either create the button as a child of our widget. size=(d.uix. Line class MyPaintWidget(Widget): def on_touch_down(self. mode=’hsv’) d = 30. That would imply that if you create more than one widget.). 1. For our simple example..x. Only the hue changes. This way you will have a smaller number of possible colors. Then. d)) touch. 1. but the colors that you get will always be equally bright. in our app class and when it’s pressed we clear the widget. There is a nice trick to prevent this: Instead of creating a tuple with three random values. We change that here: We create a small throw-away function that is going to be our callback function which is called when the button is pressed.bind(on_release=clear_canvas) return parent if __name__ == ’__main__’: MyPaintApp().run() Here’s what happens: • Line 4: We added an import statement to be able to use the Button class. • Line 29 & 30: We set up the widget hierarchy by making both the painter and the clear button children of the dummy parent widget. • Line 27: We create our MyPaintWidget() as usual. • Line 34: We bind the button’s on_release event (which is fired when the button is pressed and then released) to the callback we just defined. and you could press it.canvas. • Line 26: We create a dummy Widget() object as a parent for both our painting widget and the button we’re about to add. • Line 28: We create a button widget.add_widget(painter) parent. making it black again. Again: This widget does absolutely nothing except holding the two widgets we will now add to it as children. We could just as well use a layout or do some other fancy stuff. • Lines 32 & 33: Up to now. It will have a label on it that displays the text ‘Clear’.add_widget(clearbtn) def clear_canvas(obj): painter. only this time we don’t return it directly but bind it to a variable name. This is just a poor-man’s approach to setting up a widget tree hierarchy. It was there. 33 . The function just clears the painter’s canvas’ contents. but nothing would happen.clear() clearbtn.27 28 29 30 31 32 33 34 35 36 37 38 39 clearbtn = Button(text=’Clear’) parent. visible. the button did nothing. That means painter and button are now siblings in the usual computer science tree terminology. Kivy has a tree for handling a hierarchy of widgets. There are no general properties such as background color and border color. you can move to more elaborate customization. 3. Use the API docs to see what is offered by a widget.7 Widget tree Like most GUI toolkits. We suggest taking a short break to let what you just learned sink in. More than that. do have convenience properties such as background_color.add_widget(button) Now. and drawing the shape. setting the color for the canvas. you might have issues on further calls of add_widget. Each widget can be connected to other widgets. such as Button. Obviously this was just a quick introduction. if you add a widget into the children list without adding its canvas to the graphics tree. For example. and layout will have button in his children list. The widget tree is associated to a graphic tree. if you want to add a button inside a boxlayout. 34 . deriving from Widget. by design. the widget will be a child yes. From a simple start. we encourage you to read on. as a parent or as a child.remove_widget(button) The button parent will be set to None. remove_widget and clear_widgets. If you want to clear all the children inside a widget.7. but nothing will be drawn on the screen. The top level widget is called “root”. There is much more to discover. 3. Instead. Maybe draw some nice pictures to relax? If you feel like you’ve understood everything and are ready for more. the button parent will be set to layout. and subclass if you need to add more functionality.Note: The Kivy Widget class. To remove the button from the layout: layout. Higher-level built-in widgets. the examples and documentation illustrate how to easily handle such simple things yourself. is kept simple.clear_widgets() Warning: Never manipulate the children list yourself. and layout will remove button from his children list. use clear_widgets() method: layout. you can do: layout = BoxLayout(padding=10) button = Button(text=’My first button’) layout. Congratulations! You’ve written your first Kivy widget. but these vary by widget.1 Manipulating the tree The tree can be manipulated with 3 methods: • add_widget(): add a widget as a child • remove_widget(): remove a widget from the children list • clear_widgets(): remove all children from a widget For example. if you don’t know what you are doing. as we have done here. You cannot add into the widget tree something that is not a Widget subclass. You need to “schedule” your animate_something() function call over time. dt Clock.1 Clock events Before we discuss events.8 Events There are two types of events in Kivy: • Clock events: if you want to call a function X times per second.width < 100: root.7. As a result. and that it’s important that you avoid breaking it. Here is an example of calling a function named my_callback 30 times per second: def my_callback(dt): print ’My callback is called’. For example here.children[:]: # manipulate the tree. you need to know that Kivy has a main loop. preventing Kivy from doing all of the other things that need doing. 1 / 30. If you are looping or sleeping. or if you want to call a function later. etc. Scheduling a repetitive event You can call a function or a method every X times per second using schedule_interval(). drawing to the frame. loading images asynchronously.. unschedule(): The first would be to use 35 . • Widget events: if you want to call a function when something changes in the widget.schedule_interval(my_callback.. The main loop is responsible for reading from inputs. this must be used carefuly. You can do this in 2 ways: a repetitive call or one-time call.2 Traversing the tree The widget class has a children list property that contains all the children.) You have two ways of unscheduling a previously scheduled event.children: print child However. or attach a function to a widget specific event. You can easily traverse the tree by doing: root = BoxLayout() # .remove_widget(child) 3. you’ll break the main loop. If you intend to modify the children list with one of the methods shown in the previous section. remove all widgets that have a # width < 100 if child.3. you must use a copy of the list like this: for child in root. 3..8.10) When you run this. for child in root. all you’ll see is a black window which you won’t be able to interact with. the program will never exit your loop.. As an example. the following code does both: while True: animate_something() time.sleep(. add widgets to root . the callback will be called after the next frame • If X is -1.8. the callback will be called before the next frame The -1 is mostly used when you are already in a scheduled event. like in the next frame. the callback will be called in X seconds • If X is 0. However. 36 . 1) This will call my_calback in one second.unschedule(my_callback) Clock. The second argument is the amount of time to wait before calling the function. Trigger events If you want to schedule a function to be called only once for the next frame. whether or not you’ve even scheduled it.schedule_interval(my_callback. 1 / 30. In addition. you can achieve that like so: Clock. it will schedule a single call of your callback. you can achieve some other results with special values for the second argument: • If X is greater than 0. bye bye !’ return False print ’My callback is called’ Clock.2 Widget events A widget has 2 types of events: • Property event: if your widget changes its position or size. 0) This way of programming a trigger is expensive. an event is fired. it will not be rescheduled. and your event will be automatically unscheduled: count = 0 def my_callback(dt): global count count += 1 if count == 10: print ’Last call of my callback.schedule_once(my_callback.) Scheduling a one-time event Using schedule_once(). since you’ll always call unschedule. 3. in seconds. unschedule needs to iterate the weakref list of the Clock in order to find your callback and remove it. Use a trigger instead: trigger = Clock. you can call a function “later”. like a trigger.Clock.create_trigger(my_callback) # later trigger() Each time you call trigger. or in X seconds: def my_callback(dt): print ’My callback is called !’ Clock.schedule_once(my_callback. and if you want to schedule a call BEFORE the next frame is happening. you can return False in your callback. If it was already scheduled.unschedule(my_callback) Or. StringProperty.bind(prop1=my_callback) # now change prop1 => it will call your callback ! obj.__init__(**kwargs) own widget. self).prop1 = ’hello world’ If you want to stop receiving events from the prop1 property.prop1 = ’bleh’ Using this code though. ’prop1 changed to’. at the start of the class. ’is pressed’ button = Button(text=’Hello world’) button. Usually. you do not have a good way to know when prop1 is changed.__init__() self. instance. The Kivy way to do this is: class MyClass(Widget): prop1 = StringProperty(’bleh’) You can connect a function to this property if you want to be called when the value of the property changes: def my_callback(instance. you do something like this: class MyClass(object): def __init__(self): super(MyClass. You can find a list of widget-defined events that the widget supports. self). a Button could have a state property that indicates whether the Button is currently pressed or not. Property event A widget has many properties.unbind(prop1=my_callback) Widget-defined event Sometimes the property event is not enough to hook onto. except by rewriting the class and adding a hook in __getattribute__. For example. value): print ’the widget’. You’ll find in the documentation that every property has a type like NumericProperty. call unbind: obj. when you want to create a Python class with properties. **kwargs): self.bind(on_press=my_callback_press) Every event defined by a widget is in the documentation. If you are designing your register_event_type(): class MyClass(Widget): def __init__(self. We made the choice to add additional events for this: the on_press() and on_release() events: def my_callback_press(instance): print ’The button’. instance. ListProperty. value # create an instance of MyClass obj = MyClass() # and connect my_callback to prop1 obj. you can create a widget event by using 37 .• Widget-defined event: an event will be fired for a Button when it’s pressed or released.register_event_type(’on_custom_event’) super(MyClass. • WM_MotionEventProvider: use the windows API for reading multitouch information and sending it to Kivy. you will need to configure kivy to make it work. without position. you don’t need to create an input provider. WM_Touch. and call every function attached to this event.. From this. the event is never dispatched. it will dispatch on_custom_event. like: • TuioMotionEventProvider: create a UDP server and listen for TUIO/OSC messages. the network or even from another application. iterate over all the hardware connected to the computer. However.9 Input management 3.def on_custom_event(self): # empty handler needed pass Then. Every motion event is analyzed to detect and correct faulty input.dispatch(’on_custom_event’) Now. Android. It never starts or stops. For example.. gyroscope. MT Protocol A/B. In this example. Several input providers exist. every time you call the do_something() method. 3. the accelerometer is a continuous event. A Motion event is generated by an Input Provider. Before the newly-created Motion Event is passed to the user. These events are not dispatched accross the Widget tree.1 Input architecture Kivy is able to handle most types of input: mouse. Kivy applies post-processing on the input. if you want to support custom hardware. the user can hook to it. An input provider is responsible for reading the input event from the operating system. All the touch events are dispatched accross the Widget tree. accelerometer. and attach a multitouch input provider for each multitouch hardware found. touchscreen.on_press event. etc. • No-touch events: all the rest. It handles the native multitouch protocols on the following platforms: Tuio. there are 2 kinds of events: • Touch events: a motion event that contains at least an X and Y position. • ProbeSysfsHardwareProbe: In Linux. as well as make meaningful interpretations like: • Double-tap detection. The global architecture can be viewed as: Input providers -> Motion event -> Post processing -> Dispatch to Window The class for all input events is the MotionEvent. according to a distance and time threshold 38 . __init__ + on_custom_event def do_something(self): self. Kivy tries to automatically detect available hardware. • and much more! When you write an application. Let’s just add a function demonstrating how to dispatch a widget-defined event: class MyClass(Widget): # .9. the same as to the Button. MacMultitouchSupport. For the ’pos’ profile.2 Motion event profiles Depending on your hardware and the input providers used. scaled to the Window width and height.• Making events more accurate when the hardware is not accurate • Reducing the amount of generated events if the native touch hardware is sending events with nearly the same position Then. it will be dispatched to on_motion() • if it’s a touch event. touch): print touch.profile return super(. 3.9. As explained at the start. Just because ’angle’ is in the available profile doesnt mean that the touch event object will have an angle property.. For a given event: • if it’s only a motion event. meaning the touch 39 .motionevent documentation..3 Touch events A touch event is a specialized MotionEvent where the property is_touch evaluates to True. and dispatched to: – on_touch_down() – on_touch_move() – on_touch_up() 3. touch): print ’The touch is at position’.a You can find a list of available profiles in the api-kivy. As we said. Let’s imagine that you are in an on_touch_move method: def on_touch_move(self.9. the properties pos.on_touch_move(touch) The print could output: [’pos’. For all touch events. and y will be available. for touch events ’pos’ is a mandatory profile. an acceleration vector. the property a will be available. but not ’angle’. more information may be made available to you. all events are not dispatched to the whole widget tree. ’angle’] Warning: Most people mix up the profile’s name and the name of the corresponding property. You must take care about matrix transformation in your touch as soon as you use a widget with matrix transformation. a touch input has an (x. blob size.y) position. the (x. Some widgets such as Scatter have their own matrix transformation. you automatically have the X and Y positions available. With the ’angle’ profile.input.profile: print ’The touch angle is’. all touch events have the ’pos’ profile.pos if ’angle’ in touch. the motion event is dispatched to the Window. self). etc. In other words. but might also have pressure information. A profile is a string that indicates what features are available inside the motion event. For example.. You can extend your interaction by checking if the ’angle’ profile exists: def on_touch_move(self.y) position of the touch (0-1 range) will be scaled to the Window size (width/height). touch. x. the window filters them. touch. push() # transform the touch coordinate to local space touch.is_double_tap: print ’Touch is a double tap !’ print ’ . ShapeRect): print ’My touch have a rectangle shape of size’. only a ShapeRect can be exposed: from kivy.. • Get coordinate from parent space to local space: to_local() • Get coordinate from local space to parent space: to_parent() • Get coordinate from local space to window space: to_window() • Get coordinate from window space to local space: to_widget() You must use one of them to get the good coordinate. touch. the coordinate will be in parent space touch. Double tap The double tap is the action of tapping twice within a time and a distance. Right now.. touch. touch. It’s calculated by the doubletap post-processing module. don’t forget to pop the transformation # after the call.interval is’.height) # . \ (touch.on_touch_down(touch) # whatever is the result.) return ret Touch shapes If the touch has a shape. You can test if the current touch is one of a double tap or not: def on_touch_down(self. self). touch): if touch. touch): if isinstance(touch.shape.width. touch): # push the current coordinate.shape.to_local) # dispatch the touch as usual to children # the coordinate in the touch are now in local space ret = super(.input. it will be reflected in the ‘shape’ property...double_tap_distance # . 40 ..shape import ShapeRect def on_touch_move(self.shape.distance between previous is’.pop() # return the result (depending what you want.must be multiplied by the scatter matrix to be able to correctly dispatch touch positions to the Scatter’s children... touch.double_tap_time print ’ .apply_transform_2d(self. Let’s take the scatter implementation: def on_touch_down(self. to be able to restore them later. we’ll see why the Kivy language was created. # you just need to check if it’s a grabbed touch event if touch. When you grab a touch. touch): # here.10 Introduction to the Kivy Language In this part of the documentation. 41 . like playing a sound. touch. because the touch is coming directly from the Window. you will always receive the move and up event.pos): # if the touch is colliding to our widget. and one time from the window (grab). But there are some limitations to grabbing: • You will receive the event at least twice: one time from your parent (the normal event). Grabbing is what you need. while it was in the grabbed state. so the parent decides not to notify its children of the movement. • You might receive an event with a grab touch. you don’t check if the touch is colliding or things like that. return True def on_touch_up(self.collide_point(*touch. like when a touch movement is outside the bounding box of the parent. touch): if self. and how it changes the way you code in Kivy. or you might have counter effects touch. Here is an example on how to use grabbing: def on_touch_down(self.grab(self) # and accept the touch. but not from you: it can be because the parent has sent the touch to its children. It’s your job to convert the coordinate to your local space. the current touch is dispatched for us. Say you started something on the down event. but not from on_touch_move or on_touch_up. • The touch coordinate is not translated to your widget space.Grabbing touch events It’s possible for the parent widget to dispatch a touch event to its child widget from within on_touch_down. But you might want to do something on_touch_up. let’s grab it.ungrab(self) # and accept the last up return True 3. and you’d like to finish things on the up event. # do something interesting here print ’Hello world!’ # don’t forget to ungrab ourself. This can happen in certain scenarios.grab_current is self: # ok. x=self. we bind on both and update a method to clear and recreate all the graphics: class YourWidget(Widget): # . how do we draw its background and text? In some toolkits.texture. . you cannot predict any optimizations. def __init__(self.__init__(**kwargs) self. like Button or Label.self.. By default.texture_size[1] / 2.texture_size) That will work.self.center_x. halign=’center’) We think this way is obsolete because: 1. y=self. A possible approach to drawing our Button could be: with self. If a widget is moving. self. 1.3.update_graphics() self.clear() with self.5. like: def draw(self): set_color(. size=self. come with some default graphics instructions to draw their background and text..width. .center_y .. size=self.height) set_color(1. **kwargs): super(YourWidget. You don’t know if the drawing will change. but we aren’t updating the Rectangle‘s position! We know that pos and size are instances of the Kivy Property class.texture. self).pos. size=self. widgets contain an empty Canvas with no graphics instructions. 1. y=self.5.pos.center_x . Consider a Button widget. cy = self.5) draw_rectangle(x=self.texture_size[1] / 2.x. 1) cx = self.canvas: Color(. height=self. or how it will change 3. . and so.pos is going to change. we can bind callbacks to update the graphics. pos=(cx.update_graphics.center_x . you create graphics instructions and draw them to the widget’s Canvas.texture_size[0] / 2.text. You don’t know what you’ll draw until you execute the method 2.5.self.self.5. cy = self.canvas: Color(. . In order to do that.5. *largs): self. size=self.y. cy). width=self. size=self.texture_size) 42 .. . Kivy’s approach In Kivy. Rectangle(texture=self. . pos=(cx.update_graphics) def update_graphics(self. cy).texture_size[0] / 2. you need to overload a draw() method and put your drawing code in it.5) Rectangle(pos=self.5.size) Color(1.5) Rectangle(pos=self.bind(pos=self.canvas. 1) draw_label(text=self. 1) cx = self. Rectangle(texture=self.1 Widget graphics Per-frame drawing Let’s take a look at drawing widgets.center_y.center_y .10. until the widget is moving or resizing itself. And because of that. 1.size) Color(1. Some widgets. instance.pos = value cx = self. So if you main class’s name is MyTestApp or MultiMapMayhem then mytest. The Kivy language has a lot of benefits for this example Button. **kwargs): super(YourWidget. You can save the graphics and update them independently: class YourWidget(Widget): # .__init__(**kwargs) # create the graphics with self.pos 43 . value): self. self).update_graphics_size) def update_graphics_pos(self.This method is still not perfect.texture_size[0] / 2.rect_bg = Rectangle( pos=self.bind(pos=self.texture_size[0] / 2. cy = self.update_graphics_pos.kv file will be auto-loaded respectively.5. cy). cy = self. self.kv or multimapmayhem.center_y . . create graphics instructions. cy That’s better.0 <YourWidget>: canvas: Color: rgb: . cy = self. we are just updating their pos and size. 1) cx = self.texture_size[0] / 2.rect_text.pos = cx.rect_bg. . and update their properties according to a python expression.center_x .texture_size) self.size = value cx = self.self.self. . 1. It can be complex to have the perfect graphics code in pure python.rect_text. value): self.kv file to be loaded is decided by the name of your main class.pos = cx. This is the “yourwidget. You can create a rule that will match your widget.center_y ..5.texture_size[1] / 2.canvas: Color(. But the code is getting more complex.5. size=self.center_x . the update code is duplicated.self.5 Rectangle: pos: self. self. def __init__(self.5. . Graphics instructions are not deleted and recreated. Here is the complete example for our widget. size=self. pos=(cx. instance.rect_text = Rectangle( texture=self. because we are deleting all the graphics.5) self. cy def update_graphics_size(self.kv” kivy language part: #:kivy 1.center_y .texture_size[1] / 2.. This is where the Kivy language can be useful. and for the text rectangle.self. self.rect_bg.texture_size[1] / 2.pos. size=self. and recreating them.self.self. Usage of the Kivy language for graphics Note: By default the name of the .center_x .texture.size) Color(1. pos will change when YourWidget.center_y .widget import Widget Builder. If one of them is changing. The instruction’s pos and size will be updated when the expression after the colon (”:”) changes..size Color: rgb: 1.uix.texture_size[1] size: self. 1.size Inside the canvas.self.py” python part: from kivy.kv’) class YourWidget(Widget): # . More complex expressions can be used.texture_size[0] / 2.texture_size[1] / 2. Rectangle: pos: self. That means. self. wouldn’t you? Good. pass Yes.self. You’d like to know how it works.texture_size[0] / 2..center_x .pos changes.texture_size And here is your “yourwidget. you put a Rectangle graphics instruction.size: self. and update the Rectangle. self. you specify the canvas’s graphics instruction: canvas: # .self.center_x . like: pos: self. To define a new property in you class through kv language: <MyAppClass> myNewProperty: ’my new property value’ Now you can access this new property in your . This expression listens for a change in center_x.. not a single line of graphics code has been written in Python. Rectangle.texture pos: self. 1 Rectangle: texture: self.py file like so: my_app_class_instance.myNewProperty 44 . center_y.pos size: self.... You can also handle on_ events inside your kv language. For example the TextInput class has a focus property whose auto-generated on_focus event can be accessed inside the kv language like so: TextInput: on_focus: print args The args is a list of arguments passed to the on_focus event.lang import Builder from kivy. The first line indicates a rule (like a CSS (Cascading Style Sheets) rule) that will match all the classes named by the rule’s name: <YourWidget>: Then.center_y .pos field.self. and texture_size.load_file(’yourwidget. the expression will be re-evaluated. app import App from kivy. we are creating a Controller class.properties import ObjectProperty.label_wid. but nothing will be shown on the screen. which will be loaded when we run the ControllerApp. that will use both of these properties.uix.App. How this is done and what files are loaded is described in the kivy.2 The layout goes in controller. and change text in the label_wid widget. StringProperty class Controller(FloatLayout): ’’’Create a controller that receives a custom widget from the kv lang file. the Python file named main.kv Executing this application without a corresponding . Add an action to be called from the kv lang file.1 The code goes in main. ’’’ label_wid = ObjectProperty() info = StringProperty() def do_action(self): self. 1 2 3 #:kivy 1.Please note that if you want to call from kv lang a widget you defined from python. We can create the UI around the Controller class in a file named controller. It will change the info text. it’s just a FloatLayout.floatlayout import FloatLayout from kivy.0.app. First. 3.require(’1.text = ’My label after button press’ self.11 Designing with the Kivy Language 3.kv.11.kv file will work.py Let’s start with a little example.info = ’New info text’ class ControllerApp(App): def build(self): return Controller(info=’Hello world’) if __name__ == ’__main__’: ControllerApp().py: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 import kivy kivy.run() In this example.11. 3.load_kv() method. we are creating a do_action() method. using the Factory object.0 <Controller>: 45 . because the Controller class has no widgets in it.5’) from kivy. You need to register it from python. with 2 properties: • info for receving some text • label_wid for receving the label widget In addition. This is expected. Any arguments or keyword arguments passed to this function will be passed on the threadedselect reactors interleave function. 2. you could do this in the on_press(): Button: on_press: root. Now when we run main.startRunning 46 . my_custom_label. 3. useable anywhere. As soon as the info property is changed in the controller. • You can use any id declared in the rule the same as root and self.py. For example. root represents the top widget in the rule and self represents the current widget.info on_press: root.kv will be loaded so that the Button and Label will show up and respond to our touch events.8. these are the arguments one would usually pass to twisted’s reactor. 3. The expression id: my_custom_label is assigning the created Label the id of my_custom_label. Creating a custom callback in the Button using the Controller‘s on_press method.0.support.install_twisted_reactor function to install a twisted reactor that will run inside the kivy event loop. using my_custom_label in the expression label_wid: my_custom_label gives the instance of that Label widget to your Controller.1 Using Twisted inside Kivy Note: You can use the kivy. 3.do_action(). • root and self are reserved keywords. Giving data to the Controller. There are 3 things going on here: 1.font_size = 18 And that’s that. Seems very simple.12. controller.info will automatically be re-evaluated.4 5 6 7 8 9 10 11 12 13 14 15 16 label_wid: my_custom_label BoxLayout: orientation: ’vertical’ padding: 20 Button: text: ’My controller info is : ’ + root. Then. Using data from the Controller. changing the text in the Button. the expression text: ’My controller info is : ’ + root.do_action() Label: id: my_custom_label text: ’My label before button press’ One label and one button in a vertical BoxLayout.12 Integrating with other Frameworks New in version 1. py • http://twistedmatrix. which you can find here: • http://twistedmatrix.listenTCP(8000.Factory): protocol = EchoProtocol def __init__(self.handle_message(data) if response: self.label. This is done to allow kivy to handle the signals as usual.app import App from kivy.label.transport. and then launch echo_client_app.app.com/documents/current/core/examples/simpleclient. unless you specifically want the twisted reactor to handle the signals (e. The kivy examples include a small example for a twisted server and client.text = "received: %s\n" % msg if msg == "ping": msg = "pong" if msg == "plop": msg = "kivy rocks" self. the installed reactor will not handle any signals unnless you set the ‘installSignalHandlers’ keyword argument to 1 explicitly. The examples are based mostly on simple Echo example from the twisted docs. SIGINT). Server App # install_twisted_rector must be called before importing from kivy. when you hit enter after typing something in the textbox.com/documents/current/core/examples/simpleserv.py To try the example run echo_server_app.g. data): response = self.label def handle_message(self.internet import protocol class EchoProtocol(protocol.Protocol): def dataReceived(self.factory.label import Label class TwistedServerApp(App): def build(self): self.py first.py.support import install_twisted_reactor install_twisted_reactor() and using the reactor from twisted.write(response) class EchoFactory(protocol.uix. The server app has a simple twisted server running and log any messages.text += "responded: %s\n" % msg return msg 47 .app = app from kivy.Warning: Unlike the default twisted reactor. msg): self. The client app can send messages to the server and will print its message and the repsonse it got.internet import reactor from twisted. app): self. EchoFactory(self)) return self. The server will reply with simple echo messages to anything the client app sends.label = Label(text="server started\n") reactor. internet import reactor.support import install_twisted_reactor install_twisted_reactor() #A simple Client that send messages to the echo server from twisted.layout = BoxLayout(orientation=’vertical’) self.uix.app.if __name__ == ’__main__’: TwistedServerApp().label import Label kivy. reason): self.run() Client App #install_twisted_rector must be called before importing the reactor from kivy. with a textbox to enter messages.print_message("connection failed") from from from from kivy. reason): self.layout def connect_to_server(self): 48 .textinput import TextInput kivy. app): self.bind(on_text_validate=self.transport) def dataReceived(self.\n’) self.app.add_widget(self.label = Label(text=’connecting.setup_gui() self.textbox = TextInput(size_hint_y=..textbox) return self. data): self.app. conn.uix. and # a large label to display all the messages received from # the server class TwistedClientApp(App): connection = None def build(self): root = self.connect_to_server() return root def setup_gui(self): self.uix. conn.send_message) self.print_message(data) class EchoFactory(protocol.app import App kivy.textbox.boxlayout import BoxLayout # A simple kivy App.factory.Protocol): def connectionMade(self): self.label) self.ClientFactory): protocol = EchoClient def __init__(self.layout.app..layout. protocol class EchoClient(protocol.factory.1.add_widget(self.on_connection(self.print_message("connection lost") def clientConnectionFailed(self.app = app def clientConnectionLost(self. multiline=False) self. Now we need to edit the spec file to add kivy hooks to correctly build the exe.pyinstaller. not only the github sourcecode) • PyInstaller 2.0 python pyinstaller. Save the icon.png file to ico with the http://www.ico file available.textbox.connection.text if msg and self. using the portable package of Kivy.bat.run() 3. If you don’t have an . 3.textbox.connection = connection def send_message(self.print_message("connected succesfully!") self.py Alternatively. The specs file is located on touchtracer/touchtracer.convertico. and the main file is named main.0: http://www. Open the spec file with your favorite editor and put theses lines at the start of the spec: 49 . using a custom icon. Double click on the Kivy.13. 8000.text)) self. *args): msg = self. and create the initial specs: cd pyinstaller-2..text = "" def print_message(self.write(str(self.py --name touchtracer --icon .\kivy\examples\demo\touchtracer\main. Requirements • Latest Kivy (the whole portable package. msg): self.label. you can convert your icon. we’ll package touchtracer example. connection): self. and can be run on both 32/64 bits windows platform.text += msg + "\n" if __name__ == ’__main__’: TwistedClientApp().. Go to the pyinstaller 2.ico .13 Packaging your application 3.reactor.ico to the main executable.0 directory. The touchtracer is the kivy/examples/demo/touchtracer/ directory.com/..org/#Downloads Create the spec file For the example.py 1.connection: self.ico in the touchtracer directory and do: python pyinstaller. EchoFactory(self)) def on_connection(self.py --name touchtracer .\kivy\examples\demo\touchtracer\icon. The package will be 32 bits.connectTCP(’localhost’.1 Create package for Windows Packaging your application for Windows platform can be done only inside the Windows OS. a console will open 2.spec inside the pyinstaller directory.textbox. The following method have been tested only inside VirtualBox and Windows Seven. you can add an icon. 6 platform can be done only inside MacOSX. since we are not supporting 32 bits MacOSX platform..2 Create package for MacOSX Packaging your application for the MacOSX 10.org/#Downloads Ensure you’ve installed Kivy DMG and installed make-symlink script.13. We have no way to do 32 bits right now..py touchtracer\\touchtracer. Double click on Kivy.. The package will be only for 64 bits MacOSX. Otherwise. particle.. 50 .). This Tree will search and add every file found in the touchtracer directory to your final package: coll = COLLECT( exe. ) 4. This is done. download and decompress the PyInstaller 2. your spec is ready to be executed ! Build the spec 1. Then. refer to the most up-to-date documentation in the Create package for MacOSX. a. The following method has only been tested inside VirtualBox and MacOSX 10.spec 3. using the portable package of Kivy.pyinstaller_hooks import install_hooks install_hooks(globals()) In the Analysis() command. Change the line to add a Tree() object. #.6. not only the github sourcecode) • PyInstaller 2.0: http://www.binaries. Then. 3.0.. Tree(’.bat 2.0 python pyinstaller. you need to change the COLLECT() call to add the data of touchtracer (touchtracer. and build the spec: cd pyinstaller-2.pyinstaller. Requirements • Latest Kivy (the whole portable package.packaging. kivy command must be accessible from the command line. remove the hookspath=None parameters.from kivy. Go to the pyinstaller directory. the kivy package hook will not be used at all.png. The package will be in the touchtracer\dist\touchtracer directory ! Including Gstreamer If you wish to use Gstreamer. ./kivy/examples/demo/touchtracer/’).tools.kv. /kivy/examples/demo/touchtracer/’). The package will be the touchtracer/dist/touchtracer directory. only pygst/gst are discovered..tools. By default.spec file too. but all the gst plugins and libraries are missing. your spec is ready to be executed ! Build the spec and create DMG 1. You will have a Touchtracer..py. Then. The touchtracer is in the . Go to the pyinstaller directory. Rename it to .py --name touchtracer .app -ov popd 4.py touchtracer/touchtracer. 1.dmg available in the touchtracer/dist directory Including Gstreamer If you wanted to read video files. or camera.spec 3.png. Open a console 2. . Otherwise. ) 4.Create the spec file For an example. #. you would need to include gstreamer. particle. Open a console 2.spec inside the pyinstaller directory. the kivy package hook will not be used at all.).kv. Now we need to edit the spec file to add kivy hooks to correctly build the exe. a.. Replace both path/filename according to your system. using a custom icon.packaging.py 3. remove the hookspath=None parameters. we’ll package the touchtracer example. The specs file is located on touchtracer/touchtracer.app: pushd touchtracer/dist mv touchtracer touchtracer./kivy/examples/demo/touchtracer/main. This is done. you need to change the COLLECT() call to add the data of touchtracer (touchtracer. audio. and create the initial specs: cd pyinstaller-2. and build the spec: cd pyinstaller-2. You need to include them in your . by adding one more argument to the COLLECT() method: 51 .. Tree(’. Go to the pyinstaller directory./kivy/examples/demo/touchtracer/ directory. Change the line to add a Tree() object... Open the spec file with your favorite editor and put theses lines at the start of the spec: from kivy.binaries. This Tree will search and add every file found in the touchtracer directory to your final package: coll = COLLECT( exe..0 kivy pyinstaller. and the main file is named main.app hdiutil create .0 kivy pyinstaller.dmg -srcfolder touchtracer./Touchtracer.pyinstaller_hooks import install_hooks install_hooks(globals()) In the Analysis() command. You can download it from here.zip is not provided anymore.app/Contents/Resources/kivy/kivy/tools/packaging/pyinstaller_hooks/.app < 1. ) For Kivy..readthedocs. ’.1..com/kivy/python-for-android Build your distribution The distribution is a “directory” containing a specialized python compiled for android. from the same python-for-android.binaries. Tree(join(gst_plugin_path..app. ’.py. a.’)). and edit the file named rthook-kivy.) • Jinja2 (python module) • Apache ant • Android SDK Setup Python for android First. Packaging your application into APK You’ll need: • A linux computer or virtual machine • Java • Python 2. you also need to update one script included in our Kivy.’. Go to /Applications/Kivy.3 Create a package for Android Changed in version 1. and type: git clone git://github. You can. ’gst-plugins’) 3.split(’:’)[0] coll = COLLECT( exe.13.6.4. follow the prerequisites needed for the project: http://python-for-android. and add this line at the end: environ[’GST_PLUGIN_PATH’] = join(root. We are using python-forandroid (doc) TestDrive There is a VirtualBox Image we provide with the prerequisites along with Android SDK and NDK preinstalled to ease your installation woes.import os gst_plugin_path = os.7 (not 2.org/en/latest/prerequisites/ Then open a console.1. Tree(’. compile multiple distribution like: 52 .environ. #.0: Kivy-XXX-android.get(’GST_PLUGIN_PATH’). including only the modules you asked for../kivy/examples/demo/touchtracer/’).. /distribute.1. openssl etc. which is the minimum required SDK version for kivy. you have a tool named build.0-debug. and install on the first connected device.android. or change the AndroidManifest.8.1. Then.0 debug installd You need to be aware that the default target Android SDK version for the build will be SDK v.html The release binary will be generated in bin/KivyTouchtracer-1. if we imagine that the touchtracer demo of Kivy is in the directory ~/kivy/examples/demo/touchtracer.) 53 . To do that./build.py --dir ~/kivy/examples/demo/touchtracer \ --package org.sh./distribute.sh -m "openssl kivy" . you can install it directly to your android device by doing: adb install -r bin/KivyTouchtracer-1.com/guide/publishing/app-signing.sh -m "kivy" The result of the compilation will be saved into dist/default.py. you must sign and zipalign the apk. Here is others examples of distribution: .> For example.0-debug.your.touchtracer \ --name "Kivy Touchtracer" --version 1. you must use the script named distribute.apk. with the release command./build.app> --version <human version> --icon <path to an icon to use> --orientation <landscape|portrait> --permission <android permission like VIBRATE> (multiple allowed) <debug|release> <installd|installr|.py --dir <path to your app> --name "<title>" --package <org.sh: . then..of.demo. You should either install this API version. Package your application Inside the distribution (dist/default by default).1. The debug and installd are commands from android project itself.0-release-unsigned. you can do: . later..• One containing a minimal support without audio / video • Another containing audio.apk (for the previous touchtracer example.apk Release on the market Launch the build.1.xml file (under dist/../) to match your own target SDK requirements.. It say it will compile the APK in debug mode.py script again. The debug binary will be generated in bin/KivyTouchtracer-1. Read the android documentation at: http://developer. This is the script that will create the APK for you: ./distribute.sh -m "pil ffmpeg kivy" Check with -h to know the available options of distribute. 4 Create a package for IOS New in version 1.txt The file android. Your application must be saved into: /sdcard/kivy/<yourapplication> Your application directory must contain: # Your main application file: main.txt must contain: title=<Application Title> author=<Your Name> orientation=<portrait|landscape> 3.3.2. then you also need to install autotools. like cython or mercurial.2 Prerequisites You need to install some dependencies. See Installation on Android.py # Some infos Kivy requires about your app on android: android. The overall method for creating a package on IOS can be explained in 4 steps: 1. We encourage you to use Homebrew to install thoses dependencies: brew install cython autoconf automake libtool pkg-config mercurial brew link libtool brew link mercurial Ensure that everything is ok before starting the second step! Compile the distribution Open a terminal.sh 54 . Populate the Xcode project with your application source code 4. If you’re using Xcode 4. and: $ git clone git://github.13. Customize The current method have been tested with Xcode 4. Create an Xcode project 3. Warning: This method is still under development. Compile python + modules for IOS 2.com/kivy/kivy-ios $ cd kivy-ios $ tools/build-all.Packaging your application for Kivy Launcher The Kivy launcher is an application to run any Kivy examples stored on your SD Card from android.0. m: putenv("KIVY_NO_CONSOLELOG=1"). orientation. If you have an issue when running your application. remove xml. Must be a name without any space / weird chars): $ tools/create-xcode-project. go in Build Phases.zip: this contain all the python modules. 55 . Go to the settings panel > build.. search for “strip” options.. just too technical to be written here.zip..py. then check the Link Binary With Libraries. Then. etc. and will strip needed symbols. According to the Apple policy :) 4. ensure your application entry point is a file named main. You can edit the zip file. and remove all the files you’ll not use (reduce encodings.sh to your needs. • Removing some libraries (like SDL_Mixer for the sound) is currently not possible cause kivy project need it. Most of the python distribution will be packed into a python27. select your target. Minimize the build/python/lib/python27. the project have few issues as (we’ll fixes them during the development): • Application configuration not writing: we are learning how IOS manage its filesystem. you should see all the Kivy log on the Xcode console. email. FAQ Application quit abnormally! By default. edit and change tools/build-all.sh test /path/to/your/appdir Now you can open the Xcode project: $ open app-test/test.. Create an Xcode project Before doing the next step. Indicate a launch image in portrait/landscape for ipad with and without retina display.) 2. • You can’t export your project outside kivy-ios directory.xcodeproj Customize You can customize the build in many ways: 1.If you don’t want to compile all the things needed for kivy. all the print on the console and files are avoided. you can activate the log by commenting the line in the main.a not used: in Xcode. Known issues Currently. • And more. and triple-check that they are all set to NO. Remove the . 3. Stripping is not working with Python dynamic modules. You can remove the libraries not used by your application. We provide a script that create an initial xcode project to start with (replace test with that you want. 5. because the libraries included in the project are relative to it. Change the icon. and run: adb logcat You’ll see all the log including your stdout/stderr. then you must handle the __name__ as: if __name__ in (’__main__’. At the end. all binaries modules are already loaded. using Python for Android. Did you already submit a Kivy application to the App store ? Yes. We made that project to be able to: • create custom Python version including only wanted modules • handle multitouch events to Kivy • create a python module for accessing to some intents • handle sleep/wakeup properly 56 . If the application will run inside the Kivy launcher.run() Create an APK The whole process is described in the Create a package for Android documentation. nothing is dynamically loaded. check: • Defletouch on iTunes. ’__android__’): YourApp(). you must have a file named main. Status of the Project The project is now stable.py in the root directory of your application.13. Connect your device. but you need a phone with: • SD Card • OpenGL ES 2.2 minimum) Requirements for android application To create an application for Android platform. Debugging your application on android platform Android SDK ship a tool named adb.How Apple can accept a python app ? We managed to merge the app binary with all the libraries into only one binary. Kivy logger.0 (Android 2. as libpython. • ProcessCraft on iTunes 3.5 Kivy on Android Kivy is able to run on android. Phones • Motorola Droid 1 • Motorola Droid 2 • HTC Desire • HTC Desire Z • Xperia 10 (custom ROM 2.0 support) • LG Optimus S • LG Optimus V • Samsung Galaxy S (mostly works. If your device is not on the list.Tested Devices These Android devices have been confirmed working with Kivy. that does not mean that it is not supported. most notably kivy splash screen doesn’t work) Tablets • Samsung Galaxy Tab • Motorola Xoom • Asus EeePad Transformer 57 . please try running Kivy and if it succeeds let us know so that we can update this list. If that is the case. Note. however.0 ES. seems to have some weird OpenGL behaviour. that your device has to support at least OpenGL 2.1 + GLES 2. 58 . 1 Pong Game Tutorial 4.1 Introduction Welcome to the Pong tutorial This tutorial will teach you how to write pong using Kivy.1. Here is a check list for things you should know before starting this tutorial: • You have a working Kivy installation.CHAPTER FOUR TUTORIALS 4. We’ll start with a basic application like the one described in the Quickstart and make it into a playable pong game describing each step along the way. See the Installation section for detailed descriptions 59 . height Label: font_size: 70 center_x: root.widget import Widget class PongGame(Widget): pass class PongApp(App): def build(self): return PongGame() if __name__ == ’__main__’: PongApp().kv file to define the look and feel of the PongGame class. So create a new file called *pong.2 Getting Started Getting Started Let’s start by getting a really simple Kivy app up and running.1. 0 size: 10. let’s get started! 4. Designing with the Kivy Language). 4.kv* and add the following contents. Since our App class is called PongApp. and understand both basic Widget concepts (Your First Widget) and basic concepts of the kv language (Introduction to the Kivy Language. you can probably skip the first 2 steps and go straight to step 3.1.• You know how to run a basic Kivy application.5.app import App from kivy.uix.0. See Quickstart if you don’t.kv We will use a . we will draw the Pong background and scores by defining how the PongGame widget looks.run() Go ahead and run the application.width / 4 60 . In the next step. 1 2 3 4 5 6 7 8 9 10 11 #:kivy 1.py 1 2 3 4 5 6 7 8 9 10 11 12 13 import kivy from kivy. What we’ve done is create a very simple Application. If you have read the programming guide.3 Add simple graphics Creation of pong.center_x . Note: You can find the entire source code. It should just show a black window at this point. self. which creates an instance of our PongGame Widget class and returns it as the root element for the applications UI.9 <PongGame>: canvas: Rectangle: pos: self. we can simply create a file called pong. and source code files for each step in the Kivy examples directory under tutorials/pong/ Ready? Sweet.kv in the same directory that will be automatically loaded when the application is run. Create a directory for the game and a file named main. width * 3 / 4 top: root.. The size of the rectangle is set to 10 pixels in width. Using the Kv language gives you automatic property binding. these properties will automatically update when the corresponding widget properties change.1). so it will be stretched to full size. you can add various blocks to define the style and contents of the widgets it will be applied to. and 0 for y. kv files use indentation to define nested blocks.50 text: "0" If you run the app now. The standard behaviour of the Window is to resize the root element based on the elements size_hint. or a canvas section in which you can add Graphics instructions that define how the widget itself is rendered.0.5. 61 . you can probably skip ahead to the next Step. Note: Try to resize the application window and notice what happens. it will be applied to any instance of the named class. we add a Rectangle to the canvas. you should see a vertical bar in the middle.9 This first line is required in every kv file. self.. That’s right. Since the pos and size of the Rectangle and score labels were defined with references to the our PongGame class. we define one rule that is applied to any PongGame instance: <PongGame>: . The default Widget size_hint is (1. It should start with #:kivy followed by a space and the Kivy version it is intended for (So Kivy can make sure. Inside a Rule section. We set the pos of the rectangle to be 5 pixels left of the horizontal center of the widget itself. A block defined with a class name inside the < and > charachters is a Widget rule. If you replaced PongGame with Widget in our example. the entire UI resizes automatically. and two zeros where the player scores will be displayed.top . If you understand what’s happening. On the very first line we have: #:kivy 1. you might want to take a closer look at the contents of the kv file we just created and figure out what is going on. In this case. 0 size: 10. You can set property values. Like python. child widgets that will be automatically added.center_x . all Widget instances would have the vertical line and the two Label widgets inside them for instance.12 13 14 15 16 17 18 19 top: root.50 text: "0" Label: font_size: 70 center_x: root. The first block inside the <PongGame> rule we have is a canvas block: <PongGame>: canvas: Rectangle: pos: self. :) Explaning Kv file syntax Before going on to the next step. you have at least the required version.top . or handle backwards compatibility later on) After that.height So this canvas block says that the PongGame widget itself should draw some graphics primitives. width / 4 top: root. is that the rendered rectangle will be automatically updated when the properties of any widgets used in the value expression change..4 Add the ball Add the ball Ok. To make it all usable. PongBall class Here is the python code for the PongBall class: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class PongBall(Widget): # velocity of the ball on x and y axis velocity_x = NumericProperty(0) velocity_y = NumericProperty(0) # referencelist property so we can use ball.top . Label: font_size: 70 center_x: root. but we still need the players and a ball to pong around. w.top .pos = Vector(*self. The root keyword can be used inside child block to refer back to the parent/root widget the rule applies to (PongGame in this case): <PongGame>: # . we’ll have to hook that up to the actual score once we have the logic for that implemented. and add the ball to the arena.g..just like e.width * 3 / 4 top: root.velocity as # a shorthand. and positioned them relatively to the root widget. look pretty similar.50 text: "0" Label: font_size: 70 center_x: root.y velocity = ReferenceListProperty(velocity_x. For now the text on both of them is just set to “0”.x and w. the entire code is listed at the end of this step.pos for w. since we set a bigger font_size. We’ll add a new PongBall class to create a widget that will be our ball and make it bounce around. you’ll also need to add the proper imports and register the PongBall class with the widget factory so you can add it as a childwidget in the <PongGame> rule. The last two section we add. velocity_y) # ‘‘move‘‘ function will move the ball one step.50 text: "0" 4. Note: We’ll just look at the python class and kv rule for PongBall first. However. Let’s start with the ball. so we have a basic pong arena to play in.1.pos 62 . The nice thing about defining the graphics like this.. don’t worry. This # will be called in equal intervals to animate the ball def move(self): self. But the labels already look good. Each of them adds a Label widget as a childwidget to the PongGame widget itself.and the widgets height in height.velocity) + self. pos = Vector(*self.register("PongBall". and the Factory singleton. just like we added the Labels before. you can add a PongBall to the <PongGame> class. 50 canvas: Ellipse: pos: self.vector import Vector from kivy. a custom classname inside a kv rule. 50 canvas: Ellipse: pos: self.9 <PongBall>: size: 50.pos size: self.pos size: self.factory import Factory class PongBall(Widget): velocity_x = NumericProperty(0) velocity_y = NumericProperty(0) velocity = ReferenceListProperty(velocity_x. so that Kivy knows what class to instantiate when you use e. PongBall) if __name__ == ’__main__’: PongApp(). the Vector. velocity_y) def move(self): self.uix.velocity) + self. Here is the entire updated python code and kv file for this step: main. you also have to add the imports for the Properties Property classes used.kv: 1 2 3 4 5 6 7 8 9 10 11 #:kivy 1.pos class PongGame(Widget): pass class PongApp(App): def build(self): return PongGame() Factory.run() pong.size To make it all work.And here is the kv rule used to draw the ball as a white circle: <PongBall>: size: 50.py: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 import kivy from kivy.app import App from kivy.properties import NumericProperty. ReferenceListProperty from kivy.g.size <PongGame>: canvas: 63 . The factory is used to register your custom classes. Once that’s done.widget import Widget from kivy.0. schedule_interval(game. would cause the update function of the game object to be called once every 60th of a second (60 times per second).0/60.top . we’ll probably need an update method for our PongGame class anyways.50 text: "0" PongBall: id: ball center: self. Furthermore given that we have a reference to the game object already. and it even has a move function.12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Rectangle: pos: self. Object Properties/References We have another problem though.width * 3 / 4 top: root.1. 1. self.top . Since we’re going to have to do more than just move the ball (e.move and other stuff pass class PongApp(App): def build(self): 64 . Luckily Kivy makes this pretty easy. by letting us schedule any function we want on the Clock and specify the interval: Clock.0) That line for example.50 text: "0" Label: font_size: 70 center_x: root. we can easily schedule its new update method when the application gets build: 1 2 3 4 5 6 7 8 9 class PongGame(Widget): def update(self): # call ball. but it’s not moving yet.update..center_x-5. 0 size: 10.. since we just added it as a child widget of our PongGame class inside the kv rule for the PongGame class.width / 4 top: root. bounce it off the walls and later the players racket). so now we have a ball.height Label: font_size: 70 center_x: root.5 Adding ball animation Making the ball move Cool. We’d like to make sure the PongBall has its move function called regularly. Let’s fix that. The only reference to our game is the one we return in the Applications build method.g.center 4.parent. but in our code we don’t have any references to the ball object. Scheduling functions on the Clock We need the move method of our ball to be called regularly. ReferenceListProperty.properties import NumericProperty.velocity_x *= -1 Don’t forget to hook it up in the kv file.ball. so we can use it later to reset the ball when a player has scored a point.parent. and hook it up to the widget created in the kv rule.ball. Once that’s done. The ball’s velocity is set to 0 on both x and y.right > self.x < 0) or (self.move() # bounce off top and bottom if (self.app import App from kivy.widget import Widget from kivy.clock import Clock from random import randint class PongBall(Widget): velocity_x = NumericProperty(1) velocity_y = NumericProperty(0) velocity = ReferenceListProperty(velocity_x. velocity_y) 65 .schedule_interval(game.velocity_y *= -1 # bounce off left and right if (self.0/60. To fix this. (canvas and Labels) PongBall: id: pong_ball center: self.ball. ObjectProperty from kivy. 1.ball.update. It sets a random x and y velocity for the ball.. and also resets the position.width): self.top > self. If your coding along as we go.ball. we can add an ObjectProperty to the PongGame class.ball. we can easily reference the ball property inside the update method and even make it bounce of the edges: 1 2 3 4 5 6 7 8 9 10 11 12 13 class PongGame(Widget): ball = ObjectProperty(None) def update(self): self.y < 0) or (self.0) return game However that still doesn’t help the fact that we don’t have a reference to the PongBall child widget created by the kv rule.10 11 12 game = PongGame() Clock.py: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import kivy from kivy.uix. Here is the entire code for this step: main.vector import Vector from kivy.factory import Factory from kivy. you might be wondering why the ball isn’t moving anywhere. In code listing below for the entire source a serve_ball method is added to the PongGame class and called in the apps build method.height): self.ball..center Note: At this point everything is hooked up for the ball to bounce around. by giving the child widget an id and setting the games property to that id: <PongGame>: ball: pong_ball # . 0 size: 10.0) return game Factory.velocity_x *= -1 class PongApp(App): def build(self): game = PongGame() game. PongBall) if __name__ == ’__main__’: PongApp().run() pong.pos = Vector(*self.ball.ball.x < 0) or (self.ball.15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 def move(self): self.y < 0) or (self.50 text: "0" 66 .velocity = Vector(4.9 <PongBall>: size: 50.kv: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #:kivy 1.register("PongBall".right > self.ball. self.top .velocity) + self.center self.height Label: font_size: 70 center_x: root. 1.0.top > self.update.width / 4 top: root.size <PongGame>: ball: pong_ball canvas: Rectangle: pos: self.pos class PongGame(Widget): ball = ObjectProperty(None) def serve_ball(self): self.ball.move() #bounce off top and bottom if (self.0/60. 50 canvas: Ellipse: pos: self.serve_ball() Clock. dt): self.ball.pos size: self.width): self.rotate(randint(0.center_x-5.ball.schedule_interval(game.height): self.center = self.ball.0).velocity_y *= -1 #bounce off left and right if (self.ball.360)) def update(self. In Kivy. Here is the code for the PongPaddle class: 1 2 3 4 5 6 7 8 9 class PongPaddle(Widget): score = NumericProperty(0) def bounce_ball(self. Pretty much done: main.width/3: self. since those concepts were already covered in the previous steps. The player class also implements a bounce_ball method.velocity) And here it is in context.width/3: self. We won’t to go over all the details of creating the class and kv rules again. Pong is pretty simple.center_y-self. Instead lets focus on how to move the Player widgets in response to user input. Check the on_touch_move handler: 1 2 3 4 5 def on_touch_move(self. ball): if self.1.center_y = touch. The only things missing now are.width * 3 / 4 top: root.02 * Vector(0.center_y) ball. By default.y if touch. the rackets just need to move up and down. so that the ball bounces differently based on where on the racket it hits.self.top .24 25 26 27 28 29 30 31 32 Label: font_size: 70 center_x: root. our ball is bouncing around.x > self. The score labels of the PongGame are kept updated by changing the static string we had in the kv file before to the score property of our new PongPaddle child widgets.py: 67 .center_y = touch. we don’t even really need to have the player widgets handle the events themselves. ball.6 Connect input event Adding Players and reacting to touch input Sweet. We’ll just implement the on_touch_move function for the PongGame class and have it set the position of the left or right player based on whether the touch occured on the left or right side of the screen. touch): if touch.collide_widget(ball): speedup = 1.velocity = speedup * (offset .center 4. When the ball get’s out of bounce on of the sides. the movable player rackets and keeping track of the score.width .player2.ball.player1.50 text: "0" PongBall: id: pong_ball center: self.y We’ll keep the score for each player in a NumericProperty. the Widget class implements these methods by just calling the corresponding method on all it’s child widgets to pass on the event until one of the children returns True. You can get the whole code and kv rules for the PongPaddle class at the end of this section. on_touch_move and on_touch_up methods.parent. a widget can react to input by implemeting the on_touch_down. In fact it’s so simple.x < self. we’ll update the score and serve the ball again by changing the update method in the PongGame class.1 offset = 0. pos = Vector(*self.velocity = vel.top): self.score += 1 self. vy) vel = bounced * 1.ball.score += 1 self.velocity offset = (ball.properties import NumericProperty.ball.center_y)/(self.ball.top > self.player1.pos class PongGame(Widget): ball = ObjectProperty(None) player1 = ObjectProperty(None) player2 = ObjectProperty(None) def serve_ball(self.velocity) + self.ball) self.player2.0)) 68 .uix.ball.player1. ObjectProperty from kivy.ball) #bounce ball off bottom or top if (self. velocity_y) def move(self): self. vel=(4.velocity = vel def update(self.0)): self.serve_ball(vel=(-4.center_y-self.velocity_y *= -1 #went of to a side to score point? if self.app import App from kivy.y + offset class PongBall(Widget): velocity_x = NumericProperty(0) velocity_y = NumericProperty(0) velocity = ReferenceListProperty(velocity_x. vy = ball.ball.center = self.bounce_ball(self.x.x < self.x > self. ball): if self.serve_ball(vel=(4.x: self. ReferenceListProperty.0)) if self.bounce_ball(self.y) or (self.ball.ball.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 import kivy from kivy.factory import Factory from kivy.vector import Vector from kivy. *args): self.clock import Clock from random import randint.ball.collide_widget(ball): vx.center self.height/2) bounced = Vector(-1*vx. random class PongPaddle(Widget): score = NumericProperty(0) def bounce_ball(self.move() #bounce of paddles self.1 ball.y < self.player2.widget import Widget from kivy. vel.width: self. width/3: self. 0 size: 10.size <PongGame>: ball: pong_ball player1: player_left player2: player_right canvas: Rectangle: pos: self.schedule_interval(game.kv: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 #:kivy 1.0.register("PongPaddle".width .width / 4 top: root.0/60. 1.pos size: self.player2. touch): if touch.x < self.61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 def on_touch_move(self.pos size:self.serve_ball() Clock.register("PongGame".y if touch.center_x-5. PongBall) Factory.50 text: str(root.update.center_y = touch.run() pong.y Factory.score) Label: font_size: 70 69 . PongGame) class PongApp(App): def build(self): game = PongGame() game.x > self.center_y = touch. PongPaddle) Factory.register("PongBall".9 <PongBall>: size: 50. 50 canvas: Ellipse: pos: self.self.width/3: self.player1.size <PongPaddle>: size: 25.0) return game if __name__ == ’__main__’: PongApp().player1.height Label: font_size: 70 center_x: root.top . 200 canvas: Rectangle: pos:self. self. • Make it a 4 player Pong Game. the pong game is pretty much complete. and source code files for each step in the Kivy examples directory under tutorials/pong/ 70 .parent.player2.center_y 4. wouldn’t it be cool to have a player on each side and play four people at the same time? Note: You can find the entire source code. Here are a few ideas of things you could do: • Add some nicer graphics / images (hint check out the source property on the graphics instructions like Circle or Rectangle.score) PongBall: id: pong_ball center: self.top .35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 center_x: root.width-self. Most tablets have Multi-Touch support.7 Where to go now? Have some fun Well.50 text: str(root. you can display a large “PLAYER 1 WINS” label and/or add a main menu to start. give yourself a pat on the back and think about how you could improve the game.1.x center_y: root. Maybe once a player has 10 points.width center_y: root.center_y PongPaddle: id: player_right x: root.center PongPaddle: id: player_left x: root. to add or remove widgets dynamically. If you understood all of the things that are covered in this turoial. pause and reset the game (hint: check out the ‘Button’ and ‘Label’ classes and figure out how to use the add_widget & remove_widget functions form the Widget class.width * 3 / 4 top: root. to set an image as the texture for it) • Make the game end after a certain score. 3. advertisement & advocating. Move your logging level to debug by editing <user_directory>/.com/. obviously. 71 . and copy/paste the complete output to http://gist. 5. documentation improvements. Screenshots and videos are also very welcome! We’re also interested in the problems you had when getting started. don’t hesitate sharing. Please feel encouraged to report any obstacles you encountered such as missing documentation. and contribute by sending us the patch :) Read the next section about how to do it. invalid spelling. graphics contributions and many different things. It doesn’t have to be a high-class enterprise app. We also welcome feedback. including the log from Kivy and the python backtrace. feature requests. missing documentation. 5. so even if it’s just a typo.github. a crash.1 Feedback This is by far the easiest way to contribute something.ini: [kivy] log_level = debug 2.com/kivy/kivy/issues/ 4. Explain how we can do to reproduce the issue + paste the link of the output previously sent on pocoo 6. you can also try to resolve the bug. We are perfectionists.2 Reporting an Issue If you found anything wrong. It’s just incredibly motivating to know that people use the things you develop and what it enables them to do. Code patches are just one thing amongst others that you can submit to help the project. you’re done ! If you feel good. If you’re using Kivy for your own project. If you have something that you would like to tell us.kivy/config. please take 2 minutes to report the issue. Just talk to us if you want to help. Validate the issue. segfault. let us know. please don’t hesitate.CHAPTER FIVE CONTRIBUTING There are many ways in which you can contribute to Kivy. and we will help you help us. Execute again your code. 1. misleading directions or similar. Write a title of your issue 5. testing. bug reports. weird example. Open https://github. the commit will be rejected. Log in to GitHub 2. Create a fork of the Kivy repository by clicking the fork button. While this part is optional. Compile and set up PYTHONPATH or install (see Installing Kivy for Development).3 Git & GitHub We use git as our version control system for our code base. Since this is so common we ask you to follow our workflow to most efficiently work with us. it allows for a tight integration between your patches and our upstream code base. The Git Community Book or the Git Screencasts are both great ways to learn git. consider using it too. Adhering to our workflow ensures that your contribution won’t be forgotten or lost. Also. but you don’t clone our repository. read Python performance tips • cpu intensive parts of Kivy are written in cython. Clone your fork of our repository to your computer. 5. 5. and check that you didn’t introduce pep8 errors.4 Code Workflow So here is the initial setup to begin with our workflow (you only need to do this once to install Kivy). If you don’t want to use GitHub. we use GitHub to host our code.3. 3. It may seem daunting at first. read the PEP8 about coding style in python. and try again. • 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. Also. 4. which basically means eternal fame in our code history (you can opt-out if you don’t want that). is well beyond the scope of this document. If you have never used git or a similar DVCS (or even any VCS) before. we strongly suggest you take a look at the great documentation that is available for git online.3 Code Contributions Code contributions (patches. your name will always be associated with the change you made.3. if so. 5. correct the errors. Trust us when we say that git is a great tool. we assume you know what you do anyway.1 Coding style • If you didn’t do it yet. 5. new features) are the most obvious way to help with the project’s development. if you are doing a lot of computation. however.5. 72 . but the fork you create with the following steps: 1.2 Performances • take care of performance issues. Teaching you git. but after a while you’ll (hopefully) love it as much as we do. In the following we will assume that you have a (free) GitHub account.3. Basically you follow the installation instructions from Installing Kivy for Development.3. Your fork will have the git remote name ‘origin’ and you will be on branch ‘master’. Don’t commit other stuff that doesn’t logically belong to this fix or feature. The make command will do that for you (see the Makefile if you want to know what it does). execute make clean. Test the code. This is not about creating one commit per line changed.git Now. run make distclean (Caution: If your changes are not under version control. Add kivy repo as a remote source: git remote add kivy https://github. 6. this command will delete them!) Now we will receive your pull request. We will check whether your changes are clean and make sense (if you talked to us before doing all of this we will have told you whether it makes sense or not). merge with our upstream repository. Send a Pull Request with a description of what you changed via the button in the GitHub interface of your repository. Give each commit an appropriate commit message. whenever you want to create a patch. We can pull your stuff. fix it). This will run our styleguide check whenever you do a commit. you should do the merge: git pull kivy master 8. 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. Your repository is linked against ours. you follow the following steps: 1.g.. Do one or more minimal. we will pull them and you will get instant karma. Push to your remote repository on GitHub: git push 9. Fix & retry. Use git add -p if necessary. If you want to get rid of all files that are not under version control. appropriately named branch in your local repository for that specific feature or bugfix. If so. 6. atomic commits per fix or per feature.com/kivy/kivy. Modify the code to do what you want (e. (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. and if there are violations in the parts that you changed. 4.5.) Warning: If you change parts of the code base that require compilation. your commit will be aborted. See if there is a ticket in our bug tracker for the fix or feature and announce that you’ll be working on it if it doesn’t yet have an assignee. (This is why we forked initially. Congratulations. 5. If you need to clean your current directory from compiled files. 7. but since you know best what you changed. Once you are satisfied with your changes. you will have to recompile in order for your changes to take effect. you’re a hero! 73 . Minimal/Atomic means keep the commit clean. You never know whether you have introduced some weird bug without testing.): git checkout -b new_feature 3. Create a new. so that others who are not familiar with the matter get a good idea of what you changed. 2. Try to do this even for small fixes. (b) Clone your fork to your computer. Following the instructions above. Keep each commit focused on a single related theme. so that others who are not familiar with the matter get a good idea of what you changed. versionchanged:: to mark the version behaviour of the feature was changed. We don’t ask you to go through all the hassle just to correct a single typo..4 Documentation Contributions Documentation contributions generally follow the same workflow as code contributions. use the following keyword when relevant • . Don’t commit other stuff that doesn’t logically belong to this update. arg): """ New feature is awesome . (c) Setup kivy repo as a remote source. Create a new. Push to your remote repository on GitHub: git push 7. • . 5.4. • . (See docs/sources/README for assistance.1. but for more complex contributions. (a) Fork the repository. and review your update.. • . 5. warning:: to indicate a potential issue the user might run into using the feature.: git checkout -b my_docs_update 2. note:: to add additional info about how to use the feature or related feature. Re-generate the HTML pages. 74 . Modify the documentation with your correction or improvement. 2. versionadded:: 1.1 Docstrings Every module/class/method/function need a docstring. just a bit more lax. Use ReStructuredText_Markup to make changes to the HTML documentation in docs/sources. Install python-sphinx.: make html 4.. 6.) 3. please follow the suggested workflow.4 versionadded:: to mark the version the feature was added. Send a Pull Request with a description of what you changed via the button in the GitHub interface of your repository. 3. To submit a documentation update.5. use the following steps: 1. 1. Examples: def my_new_feature(self. appropriately named branch in your local repository. Give each commit an appropriate commit message... .. 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 New in version 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: floatlayout FloatLayout toggle_fullscreen() Window :doc: and :mod: are essentially the same, except for an anchor in the url, this makes :doc: prefered, for the cleaner url. To build your documentation, run: make html If you updated your kivy install, and have some trouble compiling docs, run: make clean force html The doc will be generated in build/html. 5.5 Unit tests contributions For testing team, we have the document Unit tests that explain how Kivy unit test is working, and how you can create your own. Use the same approach as the Code Workflow to submit new tests. 5.5.1 Unit tests Tests are located in the kivy/tests folder, if you find a bug in kivy, a good thing to do can be to write a minimal case showing the issue, to ask core devs if the behaviour showed is intended or a real bug, if 75 you put your code as a unittest, it will prevent the bug to come back unnoticed in the future, and will make Kivy a better, stronger project. Writting unittest may be a really good way to get familiar with Kivy while doing something useful. Unit tests are seperated in two cases: • Non graphics unit tests: theses are standard unit tests that can run in console • Graphics unit tests: theses need a GL context, and work with image comparaison To be able to run unit test, you need to install nose (http://code.google.com/p/python-nose/), and coverage (http://nedbatchelder.com/code/coverage/). You can use easy_install for that: sudo easy_install nose coverage Then, in the kivy directory: make test How it’s working All the tests are located in kivy/tests, and the filename start with test_<name>.py. Nose will automatically get all theses files and class inside it, and use it as a test case. To write a test, create a file that respect the previous naming, then you can start with that template: import unittest class XXXTestCase(unittest.TestCase): def setUp(self): # import class and prepare everything here. pass def test_YYY(self): # place your test case here a = 1 self.assertEqual(a, 1) Replace XXX with an appropriate name that cover your tests cases, then replace YYY by the name of your test. If you have some doubt, check how others files are done. Then, to execute them, just run: make test If you want to execute that file only, you can run: nosetests kivy/tests/test_yourtestcase.py GL unit tests GL unit test are more difficult. You must know that even if OpenGL is a standard, the output/rendering is not. It depends on your GPU and the driver used. For theses tests, the goal is to save the output of the rendering at frame X, and compare it to a reference image. Currently, images are generated in 320x240, png. Note: Currently, image comparison is done per-pixel. This means the reference image that you generate will only be correct for your GPU/driver. If somebody can implement image comparison with “delta” support, patches are welcome :) 76 To execute gl unit test, you need to create a directory: mkdir kivy/tests/results make test The results directory will contain all the reference images, and the current generated images. At the first execution, if the results directory is empty, no comparaison will be done. It will use the generated images as reference. The second time, all the images will be compared to the reference image. A html file is available to show the comparaison before/after the test, and a snippet of the associated unit test. It will be generated at: kivy/tests/build/index.html Note: The build directory is cleaned after each call to make test. If you don’t want that, just use nosetests command. Writing GL Unit tests The idea is to create a root widget, as you would do in build(), or for kivy.base.runTouchApp(). You’ll give that root widget to a rendering function, that will capture the output in X frames. Here is an example: from common import GraphicUnitTest class VertexInstructionTestCase(GraphicUnitTest): def test_ellipse(self): from kivy.uix.widget import Widget from kivy.graphics import Ellipse, Color r = self.render # create a root widget wid = Widget() # put some graphics instruction on it with wid.canvas: Color(1, 1, 1) self.e = Ellipse(pos=(100, 100), size=(200, 100)) # render, and capture it directly r(wid) # as alternative, you can capture in 2 frames: r(wid, 2) # or in 10 frames r(wid, 10) Each call to self.render (or r in our example) will generate image named like this: <classname>_<funcname>-<r-call-count>.png r-call-count represent the number of time that self.render is called inside the test function. The reference images are named: 77 ref_<classname>_<funcname>-<r-call-count>.png You can replace the reference image with a new one easilly. Coverage reports Coverage are based on the execution of the previous tests. Statistics on code coverage are automatically grabbed during execution. You can generate an html report of the coverage with the command: make cover Then, open kivy/htmlcov/index.html with your favorite web browser. 78 CHAPTER SIX FAQ There are a number of questions that repeatedly need to be answered. The following document tries to answer some of them. 6.1 Technical FAQ 6.1.1 Fatal Python error: (pygame parachute) Segmentation Fault Most of time, this issue is due to an usage of old graphics driver. Install the latest graphics driver available for your graphics card, and it could be ok. if not, please report a detailed issue on github by following the instructions in the Reporting an Issue section of the Contributing documentation. This is very important for us because that kind of error can be very hard to debug. Give us all the informations you can give about your environment and execution. 6.1.2 undefined symbol: glGenerateMipmap You might have a too old graphics card. Update your graphics drivers to the latest available version, and retry. 6.1.3 ImportError: No module named event If you use Kivy from our development version, you must compile it before using it. In the kivy directory, do: make force 6.1.4 Pip installation failed Installing Kivy using Pip is not currently supported. Because Pip force the usage of setuptools, setuptools hack build_ext to use pyrex for generating .c, and they are no clean solution to hack against both weird behaviors to use Cython. (Reference: http://mail.scipy.org/pipermail/nipy-devel/2011March/005709.html) Solution: use easy_install, as our documentation said. 79 6.2 Android FAQ 6.2.1 could not extract public data This message error can happen in many cases. Ensure that: • you have a phone with sdcard • you are not currently in a “USB Mass Storage” mode • you have the permissions to write on sdcard In case of USB Mass Storage mode error, and if you don’t want to keep unplugging the device, set the usb option to Power. 6.2.2 Crash on touch interaction on Android 2.3.x There have been reports of crashes on Adreno 200/205 based devices. Apps otherwise run fine but crash when interacted with/through the screen. These reports also mentioned the issue being resolved when moving to a ICS or higher rom. 6.2.3 Is it possible to have a kiosk app on android 3.0 ? Thomas Hansen have wrote a detailed answer on kivy-users mailing list: https://groups.google.com/d/msg/kivy-users/QKoCekAR1c0/yV-85Y_iAwoJ Basicaly, you need to root de device, remove the SystemUI package, add some line on the xml configuration, and you’re done. 6.3 Project FAQ 6.3.1 Why do you use Python? Isn’t it slow? Let us try to give a thorough answer; please bear with us. Python is a very agile language that allows you to do many things in (by comparison) short time. For many development scenarios, we strongly prefer writing our application quickly in a high-level language such as Python, testing it, then optionally optimizing it. But what about speed? If you compare execution speeds of implementations for a certain set of algorithms (esp. number crunching) you will find that Python is a lot slower than say, C++. Now you may be even more convinced that it’s not a good idea in our case to use Python. Drawing sophisticated graphics (and we are not talking about your grandmother’s OpenGL here) is computationally quite expensive and given that we often want to do that for rich user experiences, that would be a fair argument. But, in virtually every case your application ends up spending most of the time (by far) executing the same part of the code. For Kivy for example, these parts are event dispatching and graphics drawing. Now Python allows you to do something to make these parts much faster. By using Cython, you can compile your code down to the C level, and from there your usual C compiler optimizes things. This is a pretty pain free process and if you add some hints to your code, the result becomes even faster. We are talking about a speed up in performance by a factor of anything in between 1x and up to more than 1000x (greatly depends on your code). In Kivy, we did this for you and implemented the portions of our code where efficiency really is critical on the C level. 80 For graphics drawing, we also leverage today’s GPUs which are, for some tasks such as graphics rasterization, much more efficent than a CPU. Kivy does as much as is reasonable on the GPU to maximize performance. If you use our Canvas API to do the drawing, there is even a compiler that we invented which optimizes your drawing code automatically. If you keep your drawing on the GPU mostly, much of your program’s execution speed is not determined by the programming language used, but by the graphics hardware you throw at it. We believe that these (and other) optimizations that Kivy does for you already make most applications fast enough by far. Often you will even want to limit the speed of the application in order not to waste resources. But even if this is not sufficient, you still have the option of using Cython for your own code to greatly speed it up. Trust us when we say that we have given this very careful thought. We have performed many different benchmarks and came up with quite some clever optimizations to make your application run smoothly. 6.3.2 Does Kivy support Python 3.x? No. Not yet. Python 3 is certainly a good thing; However, it broke backwards compatibility (for good reasons) which means that some considerable portion of available Python projects do not yet work with Python 3. This also applies to some of the projects that Kivy can use as a dependency, which is why we didn’t make the switch yet. We would also need to switch our own codebase to Python 3. We didn’t do that yet because it’s not very high on our priority list, but if somebody doesn’t want to wait for us doing it, please go ahead. Please note, though, that Python 2.x is still the de facto standard. 6.3.3 How is Kivy related to PyMT? Our developers are professionals and are pretty savvy in their area of expertise. However, before Kivy came around there was (and still is) a project named PyMT that was led by our core developers. We learned a great deal from that project during the time that we developed it. In the more than two years of research and development we found many interesting ways on how to improve the design of our framework. We have done numerous benchmarks and as it turns out, to achieve the great speed and flexibility that Kivy has, we had to rewrite quite a big portion of the codebase, making this a backwards-incompatible but future-proof decision. Most notably are the performance increases, which are just incredible. Kivy starts and operates just so much faster, due to heavy optimizations. We also had the opportunity to work with businesses and associations using PyMT. We were able to test our product on a large diversity of setups and made PyMT work on all of these. Writing a system such as Kivy or PyMT is one thing. Making it work under all the different conditions is another. We have a good background here, and brought our knowledge to Kivy. Furthermore, since some of our core developers decided to stop their full-time jobs and to turn to this project completely, it was decided that a more professional foundation had to be laid. Kivy is that foundation. It is supposed to be a stable and professional product. Technically, Kivy is not really a successor to PyMT because there is no easy migration path between them. However, the goal is the same: Producing high-quality applications for novel user interfaces. This is why we encourage everyone to base new projects on Kivy instead of PyMT. Active development of PyMT has stalled. Maintenance patches are still accepted. 6.3.4 Do you accept patches? Yes, we love patches. In order to ensure a smooth integration of your precious changes, however, please make sure to read our contribution guidelines. Obviously we don’t accept every patch. Your patch has to be coherent with our styleguide and, more importantly, make sense. It does make sense to talk to us before you come up with bigger changes, especially new features. 81 • Discuss that proposal with us in a timely manner. If not. • Pick an idea that you think is interesting from the ideas list (see link above) or come up with your own idea. what you would like to improve and how. Good luck! :-) 82 . • Write a draft proposal about what you want to do. • Look at the source code. If your questions don’t reflect that you’ve actually thought through what you’re asking. See: http://gsoc. we don’t know because we know neither your interests nor your skills.3.com/ Here’s a checklist: • Make sure to read through the website and at least skim the documentation. Well. Many students come up and ask what they should do.-) problems to get used to our workflow. though. It is about you trying to achieve agreed upon goals by yourself with our support. that might not be received well. Kivy will not get a slot). That also depends on the overall quality of the student proposals (i.e. if there is only one Kivy student proposal with a bad quality. that’d be a big plus. send an email and just wait. yourself. Get feedback. Show us you’re serious about it and take initiative. If we know you can work well with us. • Read our contribution guidelines. Most questions are already answered in the docs or somewhere else and can be found with some research. :-) The NUIGroup has applied as an umbrella organization and luckily got chosen as one of the mentoring organizations. The clear answer is: Indeed. if you can . slots will be dedicated to Kivy. We will try to get to you if we’re available. Given enough slots for NUIGroup. Include what you understand the current state is (very roughly). etc.nuigc. If you want to participate as a student and want to maximize your chances of being accepted. The main driving force in this should be. • Be patient! Especially on IRC. GSoC is not about us teaching you something and you getting paid for that. obviously.6.5 Does the Kivy project participate in Google’s Summer of Code 2012? Since Google announced that there will be a GSoC 2012 we have had many potential students ask whether we would participate. • Do some research yourself. start talking to us today and try fixing some smaller (or larger. freenode. If you just join. keep in mind we’re mostly based in Europe. For bugs. feel free to create a new one. there is a mailing list for support inquiries on kivy-users Google Groups. try the mailing list. a description what you did to trigger the bug and what the actual bug was.CHAPTER SEVEN CONTACT US You can contact us in several different ways: 7. please provide all the information necessary. obviously.3 IRC #Kivy on irc. but please. If there is no issue yet that matches your inquiry.net IRC is great for real-time communication. you can also use Freenode’s web chat. please see our issue tracker. Use this list if you have issues with your Kivy-based app. the full error message or any other logs. If you’re unlucky more than once. 7. ask and quit we have no way of knowing who you were and where we’re supposed to send our answer to. but please make sure to wait after you asked your question. so take into account any timezone issues.2 Mail For users of our framework. Also. like the operating system you’re using. Please make sure you receive the mails that github sends if we comment on the issue in case we need more information. we have a mailing list for matters that deal with development of the actual Kivy framework code on kivy-dev Google Groups. 83 .1 Issue Tracker If you found an issue with the code or have a feature request. Also. We can only help if you precisely tell us what the actual problem is. Just enter #kivy in the channels field. don’t close the browser window too soon. 7. and anything else that might be of interest. If you don’t have an IRC client. 84 . Download the latest version from http://kivy.org/#download 2.1 Installation of Kivy environment Kivy depends on multiples dependencies. we provide what we call a ‘portable package’. such as pygame. Then.bat. in the unzipped package. and more. gstreamer. Just unzip & run: 1. you have a script called kivy.1 Basic Kivy 8. but depending the platform you’re working on. PIL. You don’t have to install anything “system” wide. Installation on Windows For Windows. 8. cairo. All of them are not required. it can be a pain to install them. we provide a portable package that you can just unzip and use. For Windows and MacOSX. This is a work in progress.1. Unzip the package 3.CHAPTER EIGHT PROGRAMMING GUIDE 2 Warning: We are currently refactoring the whole Programming Guide. and might change at any times. use it for launching any kivy application as described below 85 . Start a Kivy Application Send-to method You can launch a . Copy the kivy. You should get the special windows directory SendTo 86 .bat in the Clipboard 2. and to go the address ‘shell:sendto’ 3. Open the explorer.py file with our Python using the Send-to menu: 1. bat as a shortcut 5. Rename it to Kivy <kivy-version> 87 .4. Paste the previously copied kivy. py file -> “Send To” -> “Kivy <version>”.. Select “Always open the file with. You are done. Browse your hard disk drive and find the file kivy. From the context menu that appears.Then.” if you don’t want to repeat this procedure every time you double click a . 4.bat from the portable package. 88 . Double-click method There are some simple steps that you need to do once in order to be able to launch any kivy application by just double-clicking it: 1.py file.. Open the file. Select it. 5.py ending) of the application you want to launch 2. select Open With 3. Right click on the main python file (. you can execute application by doing a right click on the . • easy_install • gst-inspect-0.py> Also. all other scripts and binaries are available. and download the latest development version of Kivy 5. Normally this should not be harmful as it’s just a normal version of Python with the necessary third party libraries added to the module search path.10 Use development Kivy Warning: Using the latest development version can be risky.sh <full directory path of portable kivy> # (don’t use . If you hit any bug.bat etc. such as: • cython • gcc / make. you can follow theses step: 1. Go on github.bat 89 .py file.The next time you double click a . cd <directory of portable kivy> 3.) You are now ready to launch python/kivy from the command-line! Just do: python <filename. commit as-is (no CLRF replacement!) You’ll have an icon “Git bash” on your desktop. Note: On Windows we have to ship our own version of Python since it’s not installed by default on Windows (unlike Mac OS X and Linux). it will be executed with the version of python that Kivy ships with. this is the console we want: 1.. Extract the zip into the Kivy portable directory 6. Mingw. By following the steps above. Start “Git bash” 2. we offer an alternative way with a console. Rename the directory named “kivy-<some hash>” to just “kivy” 7. please report it. 3. If you do encounter unexpected problems. where is located Python.py files for your user. kivy.. please Contact Us. If you want to use the latest development version of Kivy. You might encounter issue during the development. Start from Command-Line If you just want to use or develop with the latest stable kivy version. you will set Kivy’s version of Python as the default for opening . Launch kivy.stable 4. Go into the portable Kivy directory. You need a minimalist GNU system installed on your system. Download and install Kivy for windows as the explained before 2. source kivyenv. When you install msysGit. Rename the kivy directory to kivy. Use msysGit. you must select theses options: • Don’t replace windows shell • Checkout as-is. app • Readme. 90 . That’s all.6 and later. For versions prior to 10. Type: make force 10.txt • An Examples folder • A script to install a kivy command for shell usage To install Kivy. you have a latest development version! Package Contents The latest Windows package contains: • Latest stable kivy version • Python 2. Drag the Kivy.txt Start any Kivy Application You can run any Kivy application by simply dragging the application’s main file onto the Kivy.org/#download 2.1 • Glew 1. we provide a Kivy.7 • Pygame 1.6 or 10. Make sure to read the Readme.6 Snow Leopard 64-bit.2 • Cython 0.6 32-bit.7.9. you have to install the components yourself.8. For Mac OS X 10. We suggest using homebrew to do that.dmg file that contains: • Kivy.app into your Applications folder 4.app icon.5. Just try with any python file in the examples folder. you must: 1. Download the latest version from http://kivy. Go to the Kivy portable directory/kivy 9. Double-click to open it 3. Download it from our google code project page.14 • MinGW • GStreamer • Setuptools Installation on MacOSX Note: This method has only been tested on Mac OSX 10. It comes as a .app with all dependencies bundled. 10 or newer) $ sudo apt-get install python-setuptools python-pygame python-opengl \ python-gst0. To test if it worked: 1. 2.10-python python-enchant gstreamer0.1) $ sudo zypper install python-distutils-extra python-pygame python-opengl \ python-gstreamer-0_10 python-enchant gstreamer-0_10-plugins-good \ python-devel Mesa-devel python-pip $ zypper install -t pattern devel_C_C++ $ sudo pip install --upgrade cython Mageia (1 and 2(cauldron)) $ su $ urpmi python-setuptools python-pygame python-opengl \ gstreamer0.10-plugins-good \ python-cython lib64python-devel lib64mesagl1-devel lib64mesaegl1-devel \ lib64mesaglesv2_2-devel make gcc $ sudo easy_install pip $ sudo pip install --upgrade cython Installation If you’re installing Kivy for the first time. you can upgrade it with: 91 .10-plugins-good python-dev \ build-essential libgl1-mesa-dev libgles2-mesa-dev python-pip $ sudo pip install --upgrade cython Fedora (16) $ sudo yum install python-distutils-extra python-enchant freeglut PyOpenGL \ SDL_ttf-devel SDL_mixer-devel pygame pygame-devel khrplatform-devel \ mesa-libGLES mesa-libGLES-devel gstreamer-plugins-good gstreamer \ gstreamer-python mtdev-devel python-pip $ sudo pip install --upgrade cython OpenSuse (12. Open Terminal. do: $ sudo easy_install kivy If you already installed kivy before. If it just goes to the next line without errors.app and run kivy. double-click the Make Symlinks script after you dragged the Kivy. You should get a Python prompt. In there.app into the Applications folder. enter import kivy. Running any Kivy application from the command line is now simply a matter of executing a command like the following: kivy yourapplication.10 python-enchant gstreamer0.Start from Command Line If you want to use Kivy from the command line.py Installation on Linux Prerequisites Ubuntu (11. it worked. 3. For example: 1.6-linux-x86_64. you can create a link directly in your home directory.4_beta-py2. for an easier access.org/pygame/pygame pip install kivy The development version can be installed with git: git clone https://github.. and go to the example directory: $ python -c "import pkg_resources. you must known first where easy_install have installed your current kivy package.6/dist-packages/Kivy-1.0.resource_filename(’kivy’./share/kivy-e And you should have a path similar to: /usr/local/lib/python2. That’s mean. ensure that you have at least Cython. Then. ’. A typical pip installation look like: pip install cython pip install hg+http://bitbucket. you can access to kivy-examples directly in your Home directory: $ cd ~/kivy-examples If you want to install everything yourself.com/kivy/kivy make 92 . Pygame <http://pygame.egg/share/kivy-examples Then you can go to the example directory. Paste in your console: $ ln -s <path to kivy-examples> ~/ 3.org>. Get the example path from the command line above 2. print pkg_resources. However.$ sudo easy_install --upgrade kivy Start from Command Line We are shipping some examples ready-to-run. and run it: # $ $ $ # $ $ $ launch touchtracer cd <path to kivy-examples> cd demo/touchtracer python main. theses examples are packaged inside the package.py launch pictures cd <path to kivy-examples> cd demo/pictures python main.py If you don’t know about Unix and symbolic link. 93 . 4 Introduction to properties 8.1.2.3 Drawing instructions 8.4.5.3 Instanciate children 8.5.4.5 Declaration of a Property 8.4 Manipulating instructions 8.3 Organize with Layouts 8.4.1 Introduction to Canvas 8.5.3 Widgets 8.5.4 94 Extend canvas 8.4 Graphics 8.5 Templating .5 Platform specifics 8.3.1.2.2.2.1 Introduction to Event Dispatcher 8.2.2 Rule context 8.2 Events and Properties 8.3 Running the application 8.4 Customize the application 8.1 Introduction to Widget 8.4.5 Kv language 8.6 Dispatching a Property event 8.2 Context instructions 8.3.1.3.4 Seperate with Screen Manager 8.2 Creating custom events 8.3.2.8.3 Attaching callbacks 8.2 Manipulating the Widget tree 8.2 Create an application 8.5.1 Concept behind the language 8.1. 95 . methods and features that Kivy offers.Part II API REFERENCE The API reference is a lexicographic list of all the different classes. 96 . except -dev.CHAPTER NINE KIVY FRAMEWORK Kivy is an open source library for developing multi-touch applications. Asking for a ‘dev’ version will just warn the user if the current Kivy version is not a -dev.kivy_configure() Call post-configuration of Kivy.kivy_register_post_configuration(callback) Register a function to be called when kivy_configure() is called.0. 97 .org for more information. you can start your application code like this: import kivy kivy. or ‘beta’. but it will never raise an exception. The tagrevision is the revision of the tag. For example.Z[-tag[-tagrevision]] X is the major version Y is the minor version Z is the bugfixes revision The tag is optional.require(’1.1’) If a user attempts to run your application with a version of Kivy that is older than the specified version. Warning: You must not ask for a version with a tag. It is completely cross-platform (Linux/OSX/Win) and released under the terms of the GNU LGPL. This function must be called if you create the window yourself.Y. kivy. You must not ask for a version with a tagrevision. kivy. There are thousands of highquality. ‘alpha’. performance-critical parts are implemented in the C language. The Kivy version string is built like this: X. free libraries that can be integrated in your application. but may be one of ‘dev’.require(version) Require can be used to check the minimum version required to run a Kivy application. Warning: Internal use only. See http://kivy. a growing library of multi-touch aware widgets and hardware accelerated OpenGL drawing. At the same time. With Kivy. kivy. It comes with native support for many multi-touch input devices. you can take full advantage of the dynamic nature of Python. an Exception is raised. Kivy is designed to let you focus on building custom and highly interactive applications as quickly and easily as possible. follow these steps: • Setup an Animation object • Use the Animation object on a Widget 9.start(widget) Note that the t= parameter can be the string name of a method in the AnimationTransition class. ‘camera’: (‘opencv’.kivy_config_fn = ‘’ Kivy configuration filename kivy.1 Animation Animation and AnimationTransition are used to animate Widget properties.start() is called.kivy_userexts_dir = ‘’ Kivy user extensions directory kivy. or your own animation function. size=(80.start(widget) The animation will last for 1 second unless duration is specified.1. 9.2 Multiple properties and transitions You can animate multiple properties and use built-in or custom transition functions using transition (or t= shortcut).1 Simple animation To animate a Widget’s x or y position. ‘ Global settings options for kivy kivy. For example. 100). the Widget will move smoothly from the current x/y position to (100. ‘video’: (‘ffmpeg’. to animate the position and size using the ‘in_quad’ transition: anim = Animation(x=50. When anim.kivy_usermodules_dir = ‘’ Kivy user modules directory 9. 80). t=’in_quad’) anim. You must specify (minimum) a property name and target value. To use Animation.kivy_modules_dir = ‘/home/kivy/Buildbot/kivy-full-ref/build/kivy/modules’ Kivy modules directory kivy.kivy_data_dir = ‘/home/kivy/Buildbot/kivy-full-ref/build/kivy/data’ Kivy data directory kivy. simply specify the target x/y values where you want the widget positioned at the end of the animation: anim = Animation(x=100.kivy_base_dir = ‘/home/kivy/Buildbot/kivy-full-ref/build/kivy’ Kivy directory kivy.kivy_icons_dir = ‘/home/kivy/Buildbot/kivy-full-ref/build/kivy/data/icons/’ Kivy icons config path (don’t remove the last ‘’) kivy. ‘gstreamer’. 98 . ‘videocapture’).1.kivy_home_dir = ‘’ Kivy user-home storage directory kivy.kivy_shader_dir = ‘/home/kivy/Buildbot/kivy-full-ref/build/kivy/data/glsl’ Kivy glsl shader directory kivy.). y=100) anim.kivy.kivy_options = {‘window’: (‘pygame’. 0: Added s/step parameter.3 Sequential animation To join animations sequentially. Duration of the animation.EventDispatcher Create an animation definition that can be used to animate a Widget Parameters duration or d: float.0. *largs) Cancel all animations that concern a specific widget / list of properties.event.4 Parallel animation To join animations in parallel. 800). The following example will animate position to (80. use the ‘+’ operator.cancel_all(widget.1. Same effect as stop.9.start(widget) 9. 80). The following example will animate to x=50 over 1 second. use the ‘&’ operator.0. animated_properties Return the properties used to animate cancel(widget) Cancel the animation previously applied on a widget. except the on_complete event will not be triggered! New in version 1.4. ’x’) New in version 1. 800): anim = Animation(pos=(80. Default to 1 / 60.4. in seconds transition or t: str or func Transition function for animate properties. duration=2.) anim.4. It can be the name of a method from AnimationTransition step or s: float Step in milliseconds of the animation.) anim. see cancel Example: anim = Animation(x=50) anim. 10) over 1 second. default to 1. then animate size to (80.Animation(**kw) Bases: kivy. 99 . progression Fired when the progression of the animation is changing Changed in version 1.start(widget) # and later Animation.1. while in parallel animating the first half of size=(800. duration=2.start(widget) class kivy. Events on_start: widget Fired when the animation is started on a widget on_complete: widget Fired when the animation is completed or stopped on a widget on_progress: widget.animation. static cancel_all(widget. 80) over the next two seconds: anim = Animation(x=50) + Animation(size=(80. 10)) anim &= Animation(size=(800. clutterproject. It will not be animated further. the widget.html progress parameter in each animation functions is between 0-1 range. It will not be animated further. Easing Functions ported into Kivy from Clutter Project http://www. remove a property.animation.0. prop) Even if an animation is running. *largs) Stop all animations that concern a specific widget / list of properties.AnimationTransition Bases: object Collection of animation function. If it was the only/last property being animated on. If it was the only/last property being animated on.org/docs/clutter/stable/ClutterAlpha. the animation will be stopped (see stop) transition Return the transition of the animation class kivy.4. the animation will be canceled (see cancel) New in version 1.stop_all(widget. ’x’) stop_property(widget. triggering on_complete event static stop_all(widget.start(widget) # and later Animation.cancel_property(widget. static in_back(progress) static in_bounce(progress) 100 . Example: anim = Animation(x=50) anim. to be used with Animation object. prop) Even if an animation is running. duration Return the duration of the animation start(widget) Start the animation on a widget stop(widget) Stop the animation previously applied on a widget. remove a property. the widget. static in_circ(progress) static in_cubic(progress) static in_elastic(progress) static in_expo(progress) 101 . static in_out_back(progress) static in_out_bounce(progress) static in_out_circ(progress) static in_out_cubic(progress) 102 . static in_out_elastic(progress) static in_out_expo(progress) static in_out_quad(progress) static in_out_quart(progress) 103 . static in_out_quint(progress) static in_out_sine(progress) static in_quad(progress) static in_quart(progress) 104 . static in_quint(progress) static in_sine(progress) static linear(progress) static out_back(progress) 105 . static out_bounce(progress) static out_circ(progress) static out_cubic(progress) static out_elastic(progress) 106 . static out_expo(progress) static out_quad(progress) static out_quart(progress) static out_quint(progress) 107 . run() method. 9.require(’1. you call your instance’s App.2 Application The App class is the base for creating Kivy applications. when you are ready to start the application’s life cycle. You create an instance of your specific app class and then. you subclass this class and make your own app.button import Button class TestApp(App): 108 .static out_sine(progress) 9. or if you set self. ’’’ import kivy kivy. Think of it as your main entry point into the Kivy run loop.uix.1 Creating an Application Method using build() override To initialize your app with a widget tree. Here’s an example of a very simple application that just shows a button: ’’’ Application example using build() + return ========================================== An application can be build if you return a widget on build().7’) from kivy.app import App from kivy. In most cases.root.2.0. override the build() method in your app class and return the widget tree you constructed. The App is able to handle an INI file automatically. Here is the same example as the Button one in a kv file. no widget tree was constructed (or if you will. Here.py.kv’: #:kivy 1.kv file to see what will be the root widget.run() The file is also available in the examples folder at kivy/examples/application/app_with_build. Check the test. 9. a tree with only the root node). Contents of ‘test.run() See kivy/examples/application/app_with_kv.kv can contain rules and root widget definitions at the same time.py’: ’’’ Application from a .0 Button: text: ’Hello world’ Contents of ‘main. Use the configuration file Your application might want to have its own configuration file.app import App class TestApp(App): pass if __name__ == ’__main__’: TestApp(). Method using kv file You can also use the Kivy Language for creating applications.2 Application configuration New in version 1.2.kv. The relation between main. You add your section/key/value in the App.def build(self): # return a Button() as a root widget return Button(text=’hello world’) if __name__ == ’__main__’: TestApp().kv ====================== The root application is created from the corresponding .0.load_kv().py.py and test.kv is explained in App.0.7.7’) from kivy. The .build_config() method by using the config parameters (instance of ConfigParser: 109 . ’’’ import kivy kivy.require(’1. class TestApp(App): def build_config(self. “TestApp” will give a config file-name “test.Settings about how to create a panel. ’key2’: ’42’ }) def build(self): config = self. { ’key1’: ’value1’.config return Label(text=’key1 is %s and key2 is %d’ % ( config. Check the class:~kivy.ini” will be automatically loaded at runtime. config): config.build_settings() method. { ’key1’: ’value1’. and you can access the configuration in your App.getint(’section1’. Let’s take as an example the previous snippet of TestApp with custom config. ’key1’).setdefaults(’section1’. We could create a JSON like this: 110 . because you need a JSON file / data first. ’key2’))) Create a settings panel Your application can have a settings panel to let your user configure some of your config tokens.get(’section1’.build() method: class TestApp(App): def build_config(self. and named from the mangled name of your class:. a file is created on the disk. config): config.ini” with the content: [section1] key1 = value1 key2 = 42 The “test. config.settings. ’key2’: ’42’ }) As soon as you add one section in the config.uix. Here is an example done in the KinectViewer example (available in the examples directory): You can extend the default application settings with your own panel by extending the App.setdefaults(’section1’. There are some case your application could crash on resume.. "title": "My second key". "options": ["value1".""" settings. data=jsondata) That’s all ! Now you can press F1 (default keystroke) to toggle the settings panel. and designed for phones/tablets. or press the “settings” key on your android device. "desc": "Description of my first key". Every change in the panel is automatically saved in the config file.. value): if config is self. def on_config_change(self. we can create a panel using this JSON to create automatically all the options. You can manually call App. put the json data here . "desc": "Description of my second key". "key": "key2" } ] Then.. "section": "section1".config ConfigParser instance: class TestApp(App): # . If you don’t want it. and link them to our App.config.add_json_panel(’Test application’.. def build_settings(self. you can declare your Application like this: class TestApp(App): use_kivy_settings = False # .1. "section": "section1". { "type": "options"... section..0. in order to adapt or reload your UI. self.. you might want to know when a config value has been changed by the user. settings): jsondata = """.2.[ { "type": "title".open_settings() and App. 111 . You can overload the on_config_change() method: class TestApp(App): # . "key": "key1". { "type": "numeric". key. "title": "My first key".. However. ’key2’): print ’Our key2 have been changed to’. "title": "Test application" }. config. value One last note.close_settings() if you want. Warning: This mode is experimental.config: token = (section. 9. value elif token == (’section1’. ’key1’): print ’Our key1 have been changed to’..3 Pause mode New in version 1. key) if token == (’section1’. "value2". "another value"] }. the Kivy configuration panel is added by default in the settings instance. class kivy. By default. 4. on_pause: Fired when the application is paused by the OS. By default. will be called only once. default to None If a kv_directory is set.On tablets and phones.on_resume() is called. if Pause mode is activated by the Operating System. If our app memory has been reclaimed by the OS. the application goes into Pause mode and waits infinitely until the user switches back to your application. because after on_pause call. you have no garantee that this event will be fired after the on_pause event has been called. Events on_start: Fired when the application is being started (before the runTouchApp() call. then nothing will be called. the user can switch at any moment to another application.on_stop() is called. due to user switching to another application. 2.on_stop() behavior.root exist. on_resume: Fired when the application is resumed from pause by the OS. beware. it will be used as the root widget and added to the window. then App. The current implemented Pause mechanism is: 1. App. phone shutdown or any other reason. it will be used to get the initial kv file. You can support the Pause mode: when switching to another application. If False is returned (default case). on_resume may not be called at all. This is where you can put any default section / key / value for your config.7. Otherwise the application will sleep until the OS will resume our App 5. If this method returns a widget (tree). Parameters kv_directory: <path>. Kivy checks every frame.0. your application will reach App. 6. on_stop: Fired when the application stops.app. The mechanism for restoring all the OpenGL data is not yet implemented into Kivy(we are looking for device with this behavior). There is an issue with OpenGL on Android devices: you’re not ensured that the OpenGL ES Context is restored when your app resumes. Returns None or a root Widget instance is no self.event. App. the file is searched in the same directory as the current App definition file.App(**kwargs) Bases: kivy. see module documentation for more information. If anything is set. We got a resume. build_config(config) New in version 1. This method is called before the application is initialized to construct your ConfigParser object. build() Initializes the application. Warning: Both on_pause and on_stop must save important data.on_pause() is called: 3. Parameters config (ConfigParser) – Use this to add defaults section / key / value 112 . the configuration will be automatically saved in the file returned by get_application_config().EventDispatcher Application class. ini •otherwise: <appdir>/<appname>. Can be used to query some config token in the build() directory New in version 1.ini •on Android: /sdcard/.<appname>.Changed in version 1. static get_running_app() Return the current runned application instance. You could overload this method to change the default behavior. This will be called only once.4.0.%(appname)s.ini’) Some notes: •The tilda ‘~’ will be expanded to the user directory. This method is called when the user (or you) want to show the application settings.png’ The icon can be located in the same directory as your main file.0.7. then the user might not have any write-access to the application directory. the first time when the user will show the settings.7.ini When you are distributing your application on Desktop. New in version 1. Icon of your application.<appname>.0. You can set by doing: class MyApp(App): icon = ’customicon. •%(appdir)s will be replaced with the application directory •%(appname)s will be replaced with the application name get_application_icon() Return the icon of the application.0.ini’) New in version 1.get_application_config( ’~/. get_application_name() Return the name of the application. 113 .5. please note than if the application is meant to be installed system-wise. Add defaultpath parameter for desktop computer (not applicatable for iOS and Android.1. the application file will be stored at different places: •on iOS: <appdir>/Documents/. Depending the platform. Return the directory where the application live get_application_config(defaultpath=’%(appdir)s/%(appname)s.build_settings(settings) New in version 1.0: Customize the default path for iOS and Android platform. self).) Return the filename of your application configuration. Returns True if the settings have been closed config = None Instance to the ConfigParser of the application configuration. and save the configuration file in the user directory by default: class TestApp(App): def get_application_config(self): return super(TestApp. Parameters settings (Settings) – Settings instance for adding panels close_settings(*largs) Close the previously opened settings panel.7.0. icon = None New in version 1. Create an instance of a ConfigParser 2. ClassName: # this is a root widget .root. on_start() Event handler for the on_start event. on_pause() Event handler called when pause mode is asked. key.py. load the application configuration file. You must return True if you can go to the Pause mode. or create it if it’s not existing. The name of the kv file has to be the lowercase name of the class.1. if you have a file named main. You cannot control when the application is going to this mode. For example. Default is False. on_resume() Event handler called when your application is resuming from the Pause mode. Otherwise.0. You can define rules and a root widget in your kv file: <ClassName>: # this is a rule . This method then looks for a matching kv file in the same directory as the file that contains the application class. This is where you should reconstruct some of your OpenGL state. There must be only one root widget. without the ‘App’ postfix at the end if it exists.Load the default configuration by calling build_config(). Returns ConfigParser instance load_kv() This method is invoked the first time the app is being run if no widget tree has been constructed before for this app. Warning: When resuming. then 3. It’s doing 3 things: 1. Return the name of the application. which is fired after initialization (after build() has been called).py that contains: class ShowcaseApp(App): pass This method will search for a file named showcase.. section. 114 .0.1.7. return False. See the Kivy Language documentation for more information on how to create kv files. OpenGL Context might have been damaged / freed. New in version 1. like FBO content.load_config() (internal) This function is used for returning a ConfigParser with the application configuration. New in version 1.. it will be used as self. the root widget for the application. It’s mostly used for embed devices (android/ios).kv in the directory that contains main.0. If your kv file contains a root widget.. and your application will be stopped. based on the class name on_config_change(config. value) Event handler fired when one configuration token have been changed by the settings page. name New in version 1.If exist. and before the application is being run. and for resizing.. loader. You can use it to load an image and use it. the application settings will include also the Kivy settings. By default. change this to False. the whole application will stop by issuing a call to stopTouchApp().LoaderBase Bases: object Common base for Loader and specific implementation.loading_image = Image(’another_loading. 115 .com/test.png’) class kivy.image(’mysprite. If you use this method. stop(*largs) Stop the application.on_stop() Event handler for the on_stop event.image(’http://mysite.s or each frame if we have less than 25 FPS. run() Launches the app in standalone mode.5. you can do: Loader. If you don’t want the user to change any kivy settings from your settings UI. the window is about to be closed).png’) If you want to change the default loading image. Loader will be the best available loader implementation. open_settings(*largs) Open the application settings panel. title = None New in version 1.3 Asynchronous data loader This is the Asynchronous Loader. You must specify a default loading image for using a such loader: from kivy import * image = Loader. even if data are not yet available. which is fired when the application has finished running (e. You can set by doing: class MyApp(App): title = ’Custom title’ use_kivy_settings = True New in version 1.0. Title of your application.7. If True. 9. The _update() function is called every 1 / 25.0.g. Then the settings panel will be added to the Window attached to your application (automatically done by run()) Returns True if the settings have been opened options = None Options passed to the __init__ of the App root = None Root widget set by the build() method or by the load_kv() method if the kv file contains a root widget. It will be created the very first time.png’) You can also load image from url: image = Loader. <y>.atlas: 116 .image(filename) # img will be a ProxyImage.. A Proxy image is returned with a loading image.0. Properties loaded: bool.Image Image returned by the Loader. } Example of the Kivy defaulttheme. you are reducing the number of image to load and speedup the application loading.. start() Start the loader thread/process stop() Stop the loader thread/process class kivy.png": { "id1": [ <x>. <y>.loader. load_callback=None. An Atlas is composed of: • a json file (.4.atlas) that contain all the information about the image contained inside the atlas. With it. <height> ].image property # to the new loaded image loading_image Image used for loading (readonly) run(*largs) Main loop for the loader. # .atlas is a json file formatted like this: { "<basename>-<index>.image.ProxyImage(arg. # . <height> ]. # You’ll use it the same as an Image class..atlas A file with <basename>.1 Definition of .error_image Image used for error (readonly) image(filename. post_callback=None. }. 9. <width>. # the loader will change the img. # Later. default to False It can be True if the image is already cached Events on_load Fired when the image is loaded and changed 9. when the image is really loaded. **kwargs) Load a image using loader. :: img = Loader.image() function. <width>. **kwargs) Bases: kivy.. "id2": [ <x>. Atlas is a class for managing textures atlases: packing multiple texture into one.1.4 Atlas New in version 1.core. • one or multiple atlas image associated to the atlas definition. 4.> Let’s say you have a list of image that you want to put into an Atlas..atlas myatlas 256 *./images/button.png myatlas. This will be removed in the future when Kivy core Image will be able to support loading / blitting / save operation. } } 9..png’) In our previous example. 24].png button.png button-down. and get the image ‘‘id‘‘ 117 . and more .atlas and myatlas-0.png": { "progressbar_background": [431. You can use the url notation to reference them: atlas://path/to/myatlas/id # will search for the ‘‘path/to/myatlas. 224.png..png button-down.png Atlas created at myatlas. the id for this image will be button. 207. So if you are going to give a filename . The directory is named images with lot of png: $ ls images $ cd images $ ls bubble. Note: When using this script. "image-missing": [253. 9.. 174. we have created the atlas containing both of them.atlas 1 image have been created $ ls bubble.atlas. 344.{ "defaulttheme-0. 59.png’. and put it in images/myatlas. 48.4.. 32.3 How to use an atlas Usually.png As you can see. 118. 48].atlas‘‘. and generate the atlas file with: $ python -m kivy. 118]. 32]. background_down=’images/button_down. "bubble_btn": [83. "filechooser_selected": [1... You can directly use this module to create atlas file with this command: $ python -m kivy. # . you are doing something like this: a = Button(background_normal=’images/button.png bubble-red.2 How to create an atlas Warning: The atlas creation require Imaging/PIL.atlas myatlas-0.png You can combine all the png into one. the ids referenced in the atlas is the basename of the image. we got 2 new files: myatlas. without the extension.atlas <basename> <size> <list of images.png.png bubble-red.png button. we’ll automatically generate a “border” of 1px of your image. If you’re using a padding < 2.graphics. it will be: atlas://images/myatlas/button Note: In the atlas url. See module documentation for more information.4. Be careful.Atlas(filename) Bases: kivy. ’bubble-red’.atlas creation and -<idx>. around the image. it might take the pixels of the adjacent image.atlas. If you’re using a padding >= 2. Parameters outname: str Basename to use for . size. you might get issues with border of the images.atlas extension.TextureRegion object at 0x2404d10> class kivy.4 Manual usage of the Atlas >>> from kivy. static create(outname. 9. their is no need to put the . default to {} 9. it will be automatically append to the filename. ’button-down’] >>> print atlas[’button’] <kivy.atlas import Atlas >>> atlas = Atlas(’path/to/myatlas. The cache can be controlled in different manner.keys() [’bubble’. default to None textures List of available textures within the atlas. padding=2) This method can be used to create manually an atlas from a set of images. with a object limit or a timeout.textures. default to 2 Padding to put around each image.atlas’) >>> print atlas. Because of the OpenGL linearization. For example. filename Filename of the current Atlas filename is a AliasProperty. If you look at the result. we can create a new cache with a limit of 10 objects and a timeout of 5 seconds: 118 .event. filenames.EventDispatcher Manage texture atlas. ’button’.In our case.png associated images. filenames: list List of filename to put in the atlas size: int Size of an atlas image padding: int. don’t be scared if the image inside it are not exactly the same as yours :).5 Cache manager The cache manager can be used to store python object attached to an uniq key. textures is a DictProperty.texture. instance) # retrieve the cached object instance = Cache. default=None) Get the object last access time in cache.cache. key. static append(category. text. key. default to None] Default value to be returned if key is not found static get_lastaccess(category. limit=10.get(’mycache’. default=None) Get the object timestamp in cache. because you’ve not used the label since 5 seconds. default to None] Default value to be returned if key is not found static get_timestamp(category. Parameters category [str] Identifier of the category key [str] Uniq identifier of the object to store default [anything. key. timeout=5) # create an object + id text = ’objectid’ instance = Label(text=text) Cache.Cache Bases: object See module documentation for more information. default=None) Get a object in cache. and you’ve reach the limit. the cache may have trash it. key.register(’mycache’. obj. Parameters category [str] Identifier of the category key [str] Uniq identifier of the object to store default [anything. timeout=None) Add a new object in the cache. static get(category.append(’mycache’. default to None] Default value to be returned if key is not found 119 . Parameters category [str] Identifier of the category key [str] Uniq identifier of the object to store default [anything.# register a new Cache Cache. class kivy. label) If the instance is NULL. Parameters category [str] Identifier of the category key [str] Uniq identifier of the object to store obj [object] Object to store in cache timeout [double (optionnal)] Custom time to delete the object if it’s not used. schedule_once(my_callback.6 Clock object The Clock object allows you to schedule a function call in the future.) Clock. if None.callback) 120 .5 seconds Clock. no limit is applied.static print_usage() Print the cache usage on the console static register(category.5) Important: The callback is weak-referenced: you are responsible to keep a reference to your original object/callback. the Clock will never execute your callback. static remove(category.partial python module: from functools import partial def my_callback(value. key=None) Purge the cache Parameters category [str (optionnal)] Identifier of the category key [str (optionnal)] Uniq identifier of the object to store 9. 5) # call my_callback as soon as possible (usually next frame.schedule_once(my_callback) Note: If the callback returns False. 0. 0. with limit Parameters category [str] Identifier of the category limit [int (optionnal)] Maximum number of object in the cache. timeout [double (optionnal)] Time to delete the object when it’s not used. If you don’t keep a reference. If None. limit=None. For example: class Foo(object): def start(self): Clock. timeout=None) Register a new category in cache. ’my value’.5) # call my_callback in 5 seconds Clock.schedule_interval(self. key. If you want to schedule a function to call with default arguments.schedule_interval(my_callback.schedule_interval(partial(my_callback. you can use functools. once or on interval: def my_callback(dt): pass # call my_callback every 0. ’my key’). no timeout is applied. *largs): pass Clock. the schedule will be removed. Starting from 1. # and the instance of foo is deleted # Because nobody keep a reference to the instance returned from Foo(). The callback will only be scheduled once per frame.0.0.def callback(self. A triggered event is a way to defer a callback exactly like schedule_once(). 0) # call after the next frame Clock. then continue after the next frame.schedule_once(my_callback.schedule_once(self. Clock has an iteration limit for these callbacks.max_iteration = 20 9.callback) 121 .callback) Clock.6. If you need to increase the limit.schedule_once(my_callback. Foo(). *largs): Clock. you may have used this approach in a widget: def trigger_callback(self. However. it will leave the loop and send a warning to the console.6. If you schedule a callback that schedules a callback that schedules a .schedule_once(): # will run the callback twice before the next frame Clock. you can use a timeout of -1: Clock. set the max_iteration property: from kivy. Sometimes you need to schedule a callback BEFORE the next frame. but with some added convenience.5.create_trigger(my_callback) t() t() Before triggered events.start() # and keep the instance of foo.5.start() # So you must do: foo = Foo() foo. And you’re # callback will be never called. even if you add a new callback with -1 from a running callback.2 Triggered Events New in version 1. This is not the case with Clock.unschedule(self. # the object will be collected by Python Garbage Collector.schedule_once(my_callback) Clock.0.schedule_once(my_callback) # will run the callback once before the next frame t = Clock. until you don’t need it anymore! 9.1 Schedule before frame New in version 1. even if you call the trigger twice (or more). the method start is called. dt): print ’In callback’ # a Foo object is created.. etc more than 10 times. This is implemented to prevent bugs from hanging or crashing the application.clock import Clock Clock.5. -1) # call before the next frame The Clock will execute all the callbacks with a timeout of -1 before the next frame. it defaults to 10. timeout=0) Schedule an event in <timeout> seconds.clock.5. Check module documentation for more information.bind(x=self. this function returns a counter of the number of frames. It is more convenient to create and bind to the triggered event than using Clock._trigger = Clock. New in version 1. 122 .As soon as you call trigger_callback(). Note: Clock._trigger) def cb(self. frametime Time spent between last frame and current frame (in seconds) get_boottime() Get time in seconds from the application start get_fps() Get the current average FPS calculated by the clock get_rfps() Get the current “real” FPS calculated by the clock. kivy. That is here to prevent too much relayout.0. This counter reflects the real framerate displayed on the screen. **kwargs): self. self).0.clock import Clock from kivy. y=self. In contrast to get_fps().clock.__init__(**kwargs) self. available for everybody class kivy. timeout) Schedule an event to be called every <timeout> seconds schedule_once(callback.create_trigger() also has a timeout parameter that behaves exactly like Clock._trigger. it will correctly schedule the callback once in the next frame.widget import Widget class Sample(Widget): def __init__(self. *largs): pass Even if x and y changes within one frame.Clock = None Instance of the ClockBase. the callback is only run once. not an average of frames per second get_time() Get the last tick made by the clock max_iteration New in version 1.cb) super(Sample.uix.schedule_once().5: When a schedule_once is used with -1.schedule_once() in a function: from kivy. you can add a limit on how iteration will be allowed. timeout=0) Create a Trigger event.0.create_trigger(self. Changed in version 1.5: If the timeout is -1. schedule_interval(callback. the callback will be called before the next frame (at tick_draw()).ClockBase Bases: object A clock object with event support create_trigger(callback. normalized inside the range 0 . 50) >>> Config. jitter_distance: int Maximum distance for jitter detection.write() 9. Otherwise. ’show_fps’) 0 Change the configuration and save it: >>> Config. Argument should be an int between 0 and 1000. 9.1 Usage of Config object Read a configuration token from a particular section: >>> from kivy.2 Available configuration tokens kivy log_level: (debug.set(’kivy’. Kivy will decide for you what is the best for your current platform.1000 123 . warning. it will not be retained. 1) Activate file logging keyboard_mode: (‘’.tick() Advance clock to the next step. See ConfigParser documentation for more information. ‘multi’ (one virtual keyboard everytime a widget ask for. in milliseconds double_tap_distance: float Maximum distance allowed for a double tap. Must be called every frame.config import Config >>> Config.7. normalized inside the range 0 .7. ‘system’. ‘dock’. If empty.getint(’kivy’.) keyboard_layout: string Identifier of the layout to use postproc double_tap_time: int Time allowed for the detection of double tap. ‘dock’ (one virtual keyboard docked in a screen side). critical) Set the minimum log level to use log_dir: string Path of log directory log_name: string Format string to use for the filename of log file log_enable: (0. info.1000 retain_time: int Time allowed for a retain touch. error. in milliseconds retain_distance: int If the touch moves more than is indicated by retain_distance.7 Configuration object Config object is an instance of a modified Python ConfigParser. 9. ’retain_time’. ‘multi’) Keyboard mode to use. you can set one of ‘system’ (real keyboard). The default clock have the tick() function called by Kivy tick_draw() Tick the drawing counter unschedule(callback) Remove a previously scheduled event. graphics maxfps: int. fullscreen: (0. top: int Top position of the Window left: int Left position of the Window window_icon: string Path of the window icon.192. the window will have a fixed size. Check the widget documentation for more information.0. 180. If auto is used. 90. force-hardware) Select the FBO backend to use.parameters # example for tuio provider default = tuio..providers for the syntax to use inside the configuration file. 1) If 0. Check the widget documentation for more information. rotation: (0. Use this if you want to replace the default pygame icon. show_cursor: (0.input. 1) Show the cursor on the screen position: (auto. a resolution of width times height pixels will be used. 1. scroll_timeout: int Default value of scroll_timeout property in Scrollview widget. input Input section is particular.1:3333 mytable = tuio.168. height. This is most likely what you want. ymax). 124 . seperated with comma List of devices to ignore from jitter detection ignore: list of tuples List of regions where new touches are ignored.] All the values must be inside 0 . If you want to place the window in another display. xmax.jitter_ignore_devices: string. If set to 1. software. the window will be resizable. .127. If 1.. default to 60 Maximum FPS allowed. fake. Check the widget documentation for more information. If set to auto.0. scroll_friction: float Default value of scroll_friction property in Scrollview widget. top and left. not used if in auto fullscreen height: int Height of the Window. auto) Activate fullscreen. width: int Width of the Window. use fake and adjust width. This configuration token can be used to resolve hotspot problems with DIY hardware.0. ymin.1 range. your current display’s resolution will be used instead.1:3334 See Also: Check all the providers in kivy. widgets scroll_distance: int Default value of scroll_distance property in Scrollview widget. The format of the list must be: ignore = [(xmin. not used if in auto fullscreen fbo: (hardware. You can create new input device with this syntax: # example of input provider instance yourid = providerid. custom) Position of the window on your display. you have no control of the initial position: top and left are ignored. 270) Rotation of the Window resizable: (0. setdefault(section. section=None. Check the widget documentation for more information. list_friction. set(section. getdefault(section. kivy.config.7. value) Functions similarly to PythonConfigParser’s set method.2. Callbacks will receive 3 arguments: the section.ConfigParser Bases: ConfigParser.1. Changed in version 1. The latest read file will be used for the write() method. If not found. scroll_moves: int Default value of scroll_moves property in Scrollview widget.1. New in version 1. option. this one is able to read only one file at a time.0: tuio is not listening by default anymore. Return True if the write finished successfully. that supports addition of default sections and default values. keyboard_type and keyboard_layout have been removed from widget. value) Set the default value of a particular option setdefaults(section. list_trigger_distance and list_friction_bound have been removed. 125 . You can still set a new window icon by using window_icon config setting.Changed in version 1.scroll_stoptime: int Default value of scroll_stoptime property in Scrollview widget. add_callback(callback.0: resizable has been added to graphics sectionChanged in version 1. modules You can activate modules with this syntax: modulename = Anything after the = will be passed to the module as arguments. key and value. defaultvalue) Get an option. it will return the default value read(filename) Read only one filename. windows icons are not copied to user directory anymore. keyvalues) Set a lot of keys/values in one section at the same time write() Write the configuration to the latest file opened with read() method. option. scroll_distance and scroll_friction have been added. option. except that the value is implicitly converted to a string.ConfigParser Enhanced ConfigParser class. key=None) Add a callback to be called when a specific section/key changed.0. Check the specific module’s documentation for a list of accepted arguments. If you don’t specify a section or a key.0.config. keyboard_mode and keyboard_layout have been added to kivy section.Config = None Kivy configuration object class kivy. Check the widget documentation for more information.8: scroll_timeout. In contrast to the original ConfigParser of Python. New in version 1. it will call the callback for all section/keys.4. adddefaultsection(section) Add a section if the section is missing. New in version 1. Warning: This function is designed for the Kivy language. value def my_width_callback(obj.custom True dispatch() Dispatch an event across all the handler added in bind(). obj.custom = True >>> print mywidget. value self.8 Event dispatcher All objects that produce events in Kivy implement EventDispatcher. value): print ’on object’. it will always be an ObjectProperty class. value): print ’on object’. >>> mywidget = Widget() >>> mywidget.bind(on_press=self.EventDispatcher Bases: object Generic event dispatcher interface See the module docstring for usage. value create_property() Create a new property at runtime.bind(x=my_x_callback. You should declare the property in your class instead of using this method.9. Parameters name: string Name of the property The class of the property cannot be specified. As soon as a handler return True.event. Changed in version 1.my_callback) #bind event self.9: Properties discovering and methods have been moved from Widget to EventDispatcher class kivy.add_widget(btn) def my_callback(self. until you set a new value. The default value of the property will be None.obj.bind(on_press=self.value): print ’press on button’. ’width changed to’. the dispatching stop 126 . bind() Bind an event type or a property to a callback Usage: # With properties def my_x_callback(obj.0. ’x changed to’. obj. width=my_width_callback) # With event self.my_press_callback) Usage in a class: class MyClass(BoxLayout): def __init__(self): super(MyClass. providing a consistent interface for registering and manipulating event handlers. don’t use it in your code.0. self).create_property(’custom’) >>> mywidget. ’with date:’.__init__(**kwargs) btn = Button(text=’click on’) btn.9. obj. For example. if you want to position one widget next to you: self.9. New in version 1.9.0.event.getter() Return the getter of a property. Same usage as bind(). self).start with the prefix on_ 2. properties() Return all the properties in that class in a dictionnary of key/property class. Registering event types allows the dispatcher to validate event handler names as they are attached.9 Event loop management kivy. register_event_type() Register an event type with the dispatcher.setter(’x’)) unbind() Unbind properties from callback functions.dispatch(’on_swipe’) setter() Return the setter of a property. Each event type declaration must : 1.EventLoopBase object at 0xa291dac> EventLoop instance class kivy. is_event_type() Return True if the event_type is already registered.9.4.register_event_type(’on_swipe’) def on_swipe(self): pass def on_swipe_callback(*largs): print ’my swipe is called’. New in version 1.EventDispatcher 127 . and to search attached objects for suitable handlers. New in version 1. **kwargs): super(MyWidget.0. Useful if you want to directly bind a property to another.0.__init__(**kwargs) self. Can be used for introspection. property() Get a property instance from the name.EventLoopBase Bases: kivy. Returns A Property derivated instance corresponding to the name.0. largs w = MyWidget() w.bind(right=nextchild.9.base.EventLoop = <kivy.base. New in version 1. New in version 1.0.have a default handler in the class Example of creating custom event: class MyWidget(Widget): def __init__(self. unregister_event_types() Unregister an event type in the dispatcher 9.base. will be fired when the event loop is paused. By default : * it “tick” the clock to the next frame * read all input and dispatch event * dispatch on_update + on_draw + on_flip on window on_pause() Event handler for on_pause. stop() Stop all input providers and call callbacks registered using EventLoop. auto_remove=False) Add a new input provider to listen for touch event add_postproc_module(mod) Add a postproc input module (DoubleTap. and close the window idle() This function is called every frames. it’s dispatched through grabbed widgets remove_event_listener(listener) Remove a event listener from the list remove_input_provider(provider) Remove an input provider remove_postproc_module(mod) Remove a postproc module run() Main loop set_window(window) Set the window used for event loop start() Must be call only one time before run().add_stop_callback() touches Return the list of all touches currently in down or move state 128 . will be fired right after all input providers have been stopped.Main event loop. pass event to postproc. will be fired right after all input providers have been started. ensure_window() Ensure that we have an window exit() Close the main loop. RetainTouch are default) close() Exit from the main loop. This start all configured input providers. This loop handle update of input + dispatch event add_event_listener(listener) Add a new event listener for getting touch event add_input_provider(provider. post_dispatch_input(etype. and if grabbed. dispatch_input() Called by idle() to read events from input providers. and stop all configured input providers. The event is dispatched into all listeners. on_stop() Event handler for on_stop. and dispatch final events. me) This function is called by dispatch_input() when we want to dispatch a input event. on_start() Event handler for on_start. base. You got some magic things.ExceptionHandler Base handler that catch exception in runTouchApp(). Example for registering a class/module: 129 . (like Qt. add_handler(cls) Add a new exception handler in the stack handle_exception(inst) Called when an exception happend in runTouchApp() main loop remove_handler(cls) Remove a exception handler from the stack kivy. The class list and available modules are automatically generated by setup.base.runTouchApp(widget=None. slave=False) Static main function that starts the application loop.exception(inst) return ExceptionManager. a MTWindow will be created.PASS ExceptionManager. This will be your job. If not.ExceptionManager = <kivy.base.py.base. widget + slave No event dispatching are done. by specifying the module to import instead of the class instance. default return ExceptionManager. This will be your job. and your widget will be added on the window as the root widget.base. inst): Logger.add_handler(E()) All exceptions will be set to PASS.ExceptionManagerBase ExceptionManager manage exceptions handlers. and logged to console ! handle_exception(exception) Handle one exception.base.class kivy.STOP class kivy. if you are using argument like this : Parameters <empty> To make dispatching work. but we are trying to get the window (must be created by you before). you need at least one input listener. application will leave. and add the widget on it. You can derivate and use it like this: class E(ExceptionHandler): def handle_exception(self. (MTWindow act as an input listener) widget If you pass only a widget.stopTouchApp() Stop the current application by leaving the main loop 9. Very usefull for embedding Kivy in another toolkit. slave No event dispatching are done.ExceptionManagerBase instance at 0xa20058c> Kivy Exception Manager instance kivy. check kivydesigned) kivy.10 Factory object The factory can be used to automatically import any class from a module. but you would need a lot more points. module=’kivy.gesture.add_stroke(point_list=[(1..register(’Widget’.factory import Factory >>> widget = Factory. Optional point_list argument is a list of the mouse points for the stroke.find(g2) Warning: you don’t really want to start from such an example. and reload them to compare latter.factory import Factory >>> Factory. this is more to get the idea how one would construct gestures dynamically.1)]) g. it’s better to record gestures in a file.com). try to find him ! g2 = Gesture() # .vector’) Example of using the Factory: >>> from kivy. 2) Example using a class name: >>> from kivy. (3. (2.add_gesture(g) # And for the next gesture.FactoryBase object at 0xa28206c> Factory instance to use for getting new classes 9. add_stroke(point_list=None) Adds a stroke to the gesture and returns the Stroke instance. module=’kivy. GestureDatabase # Create a gesture g = Gesture() g. and compare them: from kivy. cls=MyWidget) kivy.uix. dot_product(comparison_gesture) Calculates the dot product of the gesture with another gesture get_rigid_rotation(dstpts) Extract the rotation to apply to a group of points to minimize the distance to a second group 130 .net/reference/articles/article2039..11 Gesture recognition You can easily use these class to create new gesture.factory. class kivy.Vector(9.widget’) >>> Factory. gdb.register(’MyWidget’.gamedev.factory. look into the examples/gestures directory for an example of how to do that.4).register(’Vector’.factory import Factory >>> Factory.gesture import Gesture.Factory = <kivy.asp Implemented by Jeiel Aranal (chemikhazi@gmail.>>> from kivy.Widget(pos=(456.Gesture(tolerance=None) A python implementation of a gesture recognition algorithm by Oleg Dopertchouk: http://www.normalize() # Add him to database gdb = GestureDatabase() gdb.456)) >>> vector = Factory.1). released into the public domain. add_gesture(gesture) Add a new gesture in database find(gesture. rotation_invariant=True) Returns the matching score of the gesture against another gesture normalize(stroke_samples=32) Runs the gesture normalization algorithm and calculates the dot product with self class kivy. get_score(comparison_gesture. False if it can’t be normalized.3. Methods that can normally be called during the course of an application will work as intended.12 Interactive launcher New in version 1. finds the length of that list. sample_points control the resolution of the stroke.GestureDatabase Bases: object Class to handle a gesture database. points_distance(point1=GesturePoint. but specifically overriding methods such as on_touch() dynamically leads to trouble. Note: The Kivy API intends for some functions to only be run once or before the main EventLoop has started. 131 .gesture.GestureStroke Gestures can be made up of multiple strokes add_point(x=x_pos.90000000000000002.of points. The InteractiveLauncher provides a user-friendly python shell interface to an App so that it can be prototyped and debugged interactively. The two groups of points are assumed to be centered.0. point2=GesturePoint) Returns the distance between two GesturePoint scale_stroke(scale_factor=float) Scales the stroke down by scale_factor stroke_length(point_list=None) Finds the length of the stroke. 9. rotation_invariant=True) Find current gesture in database gesture_to_str(gesture) Convert a gesture into a unique string str_to_gesture(data) Convert a unique string to a gesture class kivy. Returns True if stroke is normalized.gesture. offset_y) Centers the stroke by offseting the points normalize_stroke(sample_points=32) Normalizes strokes so that every stroke has a standard number of points. minscore=0. If a point list is given. This is a simple version that just pick an angle based on the first point of the gesture. y=y_pos) Adds a point to the stroke center_stroke(offset_x. ’ operator and pressing ‘tab.1 Creating an InteractiveLauncher Take you existing subclass of App (this can be production code) and pass an instance to the InteractiveLauncher constructor. can be quickly listed by using the ‘.root.2 Interactive Development IPython provides a fast way to learn the kivy API.: from kivy.button import Button class MyApp(App): def build(self): return Button(test=’Hello Shell’) interactiveLauncher = InteractiveLauncher(MyApp()). The App instance itself.add_widget(MyPaintWidget()) i.9. 9.12. i.y . 0) d = 30.x .d/2. Ellipse class MyPaintWidget(Widget): def on_touch_down(self. # Click on the screen several times.’ Try this code in an Ipython shell. all of it’s attributes. including methods and the entire widget tree.uix.root.run() i.interactive import InteractiveLauncher from kivy. # press ’tab’ to list attributes of the root widget # App is boring. # press ’tab’ to list attributes of the app i. touch): with self.app import App from kivy.safeOut() # The clicks will show up now # Erase artwork and start over i.run() The script will return. allowing an interpreter shell to continue running and inspection or modification of the App can be done safely through the InteractiveLauncher instance or the provided SafeMembrane class instances.widget import Widget kivy.interactive import InteractiveLauncher kivy. Ellipse(pos=(touch.safeIn() # The application is now blocked.canvas.canvas: Color(1.clear() 132 .app import App kivy. touch.root. d)) class TestApp(App): def build(self): return Widget() i = InteractiveLauncher(TestApp()) i.: from from from from kivy. Attach a new widget! i.12. size=(d. 1.uix.graphics import Color.d/2). The InteractiveLauncher can have attributes added to it exactly like a normal object. such as for getting doc strings.3 Directly Pausing the Application Both InteractiveLauncher and SafeMembrane hold internal references to EventLoop‘s ‘safe’ and ‘confirmed’ threading.Clock. and more understanding of which methods are safe in a running application would be nice.Note: All of the proxies used in the module store their referent in the _ref attribute. help() and type() will access the proxy. they will not be threadsafe because the external references to them in the python interpreter do not go through InteractiveLauncher’s membrane behavior. which can be accessed directly if needed.interactive import SafeMembrane interactiveLauncher.12. simply assign them to SafeMembrane instances of themselves like so: from kivy.safeIn() will cause the applicaiton to pause and InteractiveLauncher. All three would be excellent. This is potentially useful for scripting actions into functions that need the screen to update etc.attribute = myNewObject # myNewObject is unsafe myNewObject = SafeMembrane(myNewObject) # myNewObject is now safe. myNewObject.schedule_once() and occurs before the start of each frame.safeOut() will allow a paused application to continue running. ie: with safe: foo() Any use cases besides compacting code? 133 . To threadsafe these external referencess. You can use their safing methods to control the application manually.method() TODO Unit tests. not its referent. Deadlocks and memory corruption can occur if making direct references inside the thread without going through the provided proxy(s). 9.4 Adding Attributes Dynamically Note: This module uses threading and object proxies to encapsulate the running App.12. and if these were created from outside the membrane. Could be re-written with a context-manager style. an example.Event objects.clock. Interactive. Note: The pausing is implemented via kivy. inherited from SafeMembrane. 9. Call at will. 9. templating and so on. A Root Widget You can use the language to create your entire user interface.Rule2>: # .._ref) Threadsafe proxy that also returns attributes as new thread-safe objects and makes thread-safe method calls. If you want to design the look of an entry in a list (icon on the left. For now.g. **kwargs) Bases: object This help is for a proxy object. Note the braces. use 1. text on the right).com). **kwargs) Bases: kivy.interactive.interactive.13.5. where version must be replaced with the Kivy language version you’re using.InteractiveLauncher(app=None. *args.SafeMembrane(ob. cls=MyTestWidget). A kv file must contain only one root widget at most. You can use rules to specify interactive behaviour or use them to add graphical representations of the widgets they apply to.. They are part of the definition. <Rule3>: # .0: #:kivy ‘version‘ # content here The content can contain rule definitions.) Templates will be used to populate parts of your application.class kivy.13 Kivy Language The Kivy language is a language dedicated to describing user interface and interactions. You can target a specific class of widgets (similar to CSS’ concept of a class) by using the cls attribute (e. Templates (introduced in version 1.nokia. preventing thread-unsafe objects from leaking into the user’s environment. <Rule1. a root widget and templates: # Syntax of a rule definition.2 Syntax of a kv File A Kivy language file must have .. Did you want help on the proxy’s referent instead? Try using help(<instance>. you will use a template for that. You could compare this language to Qt’s QML (http://qt. A rule applies to specific widgets (or classes thereof) in your widget tree and modifies them in a certain way.interactive. definitions . 9. class kivy. but we included new concepts such as rule definitions (which are somewhat akin to what you may know from CSS). such as a list’s content. Note that several Rules can share the same # definition (as in CSS). definitions .kv as filename extension.0. *args.1 Overview The language consists of several constructs that you can use: Rules A rule is similar to a CSS rule.13. The content of the file must always start with the Kivy header.SafeMembrane Proxy to an application instance that launches it in a thread and then returns and acts as a proxy to the application in the thread 9. 134 .. # Syntax for create a template [TemplateName@BaseClass1. which means that the value can use the values of other properties using reserved keywords. the definition should look like this: # With the braces it’s a rule.3 Value Expressions and Reserved Keywords When you specify a property’s value. Tabs are not allowed.BaseClass2]: # . an ObjectProperty will be automatically created and added to the instance.. • The indentation is important. Here is a simple example of a kv file that contains a root widget: #:kivy 1. the value is evaluated as a python expression. root widget or template you’re defining. Without them it’s a root widget.state root This keyword is available only in rule definitions.. Regardless of whether it’s a rule.. definitions . AnotherClass will be created and added as a child of the ClassName instance. <ClassName>: prop1: value1 prop2: value2 canvas: CanvasInstruction1: canvasprop1: value1 CanvasInstruction2: canvasprop2: value2 AnotherClass: prop3: value1 Here prop1 and prop2 are the properties of ClassName and prop3 is the property of AnotherClass. and represents the root widget of the rule (the first instance of the rule): 135 . and must be 4 spaces.0 Button: text: ’Hello world’ 9. definitions . If the widget doesn’t have a property with the given name. • The value of a property must be given on a single line (for now at least). self The keyword self references the “current widget instance”: Button: text: ’My state is %s’ % self. This expression can be static or dynamic.13.# Syntax for creating a root widget RootClassName: # .. • The canvas property is special: You can put graphics instructions in it to create a graphical representation of the current class. By default. We now want this button to display its own state as text.13.pos 136 . 9.13. 9. but when the button is being pressed.state == ’normal’ else ’Release me!’ The Button text changes with the state of the button. Remember: The value is a python expression! That means that you can do something more interesting like: Button: text: ’Plop world’ if self. we use the state property of the Button and use it in the value expression for the button’s text property. you passively observe the property for potential changes).4 Relation Between Values and Properties When you use the Kivy language. The state property of the button can change at any moment (when the user touches it). You should know that Properties implement the observer software design pattern: That means that you can bind your own function to be called when the value of a property changes (i. the parser detects that self. you might notice that we do some work behind the scenes to automatically make things work properly. which controls what text is displayed on the button (We also convert the state to a string representation). The id attribute will be not used. Here’s a simple example that demonstrates this behaviour: Button: text: str(self. the text will change to ‘Release me!’.custom Furthermore.state Please note that the id will not be available in the widget instance. To do this. Now. 1) Rectangle: size: self. you can use it as a keyword: <Widget>: Button: id: btn1 Button: text: ’The state of the other button is %s’ % btn1.e. the button text will be ‘Plop world’. the text property will be updated automatically. whenever the button state changes. This concerns the ‘canvas’ property definition: Widget: canvas: Color: rgb: (1.size pos: self. if a class definition contains an id.5 Graphical Instructions The graphical instructions are a special part of the Kivy language.state is a dynamic value (a property).state) In this example. even as the state changes. 1.<Widget>: custom: ’Hello world’ Button: text: root. The Kivy language detects properties in your value expression and will create create callbacks to automatically update the property via your expression when changes occur. Syntax of template Using a template in Kivy require 2 things : 1. you can create your own kv file and put something like this: <Button>: canvas: Color: rgb: (1. 137 . You can clear all the previous instructions by using the Clear command: <Button>: canvas: Clear Color: rgb: (1... In our case.All the classes added inside the canvas property must be derived from the Instruction class. If you want to do theming. 0. definitions .pos size: self.pos size: self. the rules are executed in processing order (i.pos size: self. If you want to change how Buttons are rendered.0. you’ll have the same question as in CSS: You don’t know which rules have been executed before.texture This will result in buttons having a red background.e. You cannot put any Widget class inside the canvas property (as that would not make sense because a widget is not a graphics instruction). # With more than one base class [
[email protected]_size texture: self.13. 0) Rectangle: pos: self.size Rectangle: pos: self. with the label in the bottom left. 0.BaseClass2]: # . 9.texture_size texture: self. in addition to all the preceding rules. definitions ..pos size: self.size Rectangle: pos: self.6 Templates New in version 1.texture Then.. a kv definition of the template Syntax of a template: # With only one base class [ClassName@BaseClass]: # . top-down). only your rules that follow the Clear command will be taken into consideration.5. 0) Rectangle: pos: self. a context to pass for the context (will be ctx inside template) 2. None on_touch_down: self. title=’Hello world’. So. we’ll create a Toolbar.png’ size: self. and put many Image that will react to on_touch_down: <MyToolbar>: BoxLayout: Image: source: ’data/text.png’} icon2 = Builder.collide_point(*args[1].collide_point(*args[1].template(’IconItem’. for a list. None on_touch_down: self. Template example Most of time.collide_point(*args[1].template # function icon1 = Builder.title Then in Python. More than that. and a label on the right.lang import Builder # create a template with hello world + an image # the context values should be passed as kwargs to the Builder. we’ll create a template that require 2 entry in the context: a image filename and a title: [IconItem@BoxLayout]: Image: source: ctx.png’) # create a second template with another information ctx = {’title’: ’Another hello world’.pos) and root. ’image’: ’myimage2. when you are creating screen into kv lang. you’ll need to create a entry with a image on the left. Let’s try to create a template for the Image: [ToolbarButton@Image]: # This is the same as before source: ’data/%s.texture_size size_hint: None. the callback in on_touch_down and the image are changing.image 138 .png’ size: self. Theses can be the variable part of the template that we can put into a context. you can create instanciate the template with: from kivy. None on_touch_down: self.pos) and root.png’ % ctx. image=’myimage. you have lot of redefinition. In our example. You can create a template for making that definition more easy to use.pos) and root.create_text() Image: source: ’data/image.create_video() We can see that the size and size_hint attribute are exactly the same.image Label: text: ctx.png’ size: self. based on a BoxLayout.texture_size size_hint: None.For example.template(’IconItem’.texture_size size_hint: None. **ctx) # and use icon1 and icon2 as other widget.create_image() Image: source: ’data/video. callback() The template can be used directly in the MyToolbar rule: <MyToolbar>: BoxLayout: ToolbarButton: image: ’text’ callback: root.create_image ToolbarButton: image: ’video’ callback: root. you cannot use references other than “root”: <MyRule>: Widget: id: mywidget value: ’bleh’ Template: ctxkey: mywidget. Directive is done with a comment line starting with: #:<directivename> <options> import <package> New in version 1. None # Now. this reference mywidget id 2.collide_point(*args[1].pos) and self.5.texture_size size_hint: None.create_text ToolbarButton: image: ’image’ callback: root.prop1 else ’value2’ # << even if # root. Syntax: #:import <alias> <package> You can import a package by writing: 139 .7 Lang Directives You can use directive to control part of the lang files.prop1 is a property. we are using the ctx for the variable part of the template on_touch_down: self.value # << fail.13. the context will not update the # context 9.size: self.create_video That’s all :) Template limitations When you are creating a context: 1.0. all the dynamic part will be not understood: <MyRule>: Template: ctxkey: ’value 1’ if root. 0.lang.6. 140 .animation. Syntax: #:set <key> <expr> Set a key that will be available anywhere in the kv. apply(widget) Search all the rules that match the widget. that you can use to load other kv file in addition to the default one. Builder is the global Kivy instance used in widgets. merging the results to its internal rules. .Animation <Rule>: on_prop: Animation(x=.4. By default. and apply them.4. **kwargs) Insert a file into the language builder.5).5.getcwd() Or more complex: #:import ut kivy. Parameters rulesonly: bool.get_random_color() New in version 1.utils <Rule>: canvas: Color: rgba: ut.5) <Rule>: state: ’normal’ canvas: Color: rgb: my_color if self.#:import os os <Rule>: Button: text: os. .0. .3.state == ’normal’ else my_color_hl kivy. You can directly import class from a module: #: import Animation kivy.start(self) set <key> <expr> New in version 1. etc. templates.7.lang. the Builder will raise an exception if you have a root widget inside the definition. . load_file(filename. For example: #:set my_color (.4) #:set my_color_hl (.lang. default to False If True.BuilderBase object at 0xa123c6c> Main instance of a BuilderBase. class kivy.BuilderBase Bases: object Builder is responsible for creating a Parser for parsing a kv file.Builder = <kivy. I. message) Bases: exceptions. a comment line’s first non-whitespace character must be a #.0. Examples of usage: from kivy. e: Logger. **kwargs) Insert a string into the Language Builder Parameters rulesonly: bool. class kivy.0.ParserException Exception raised when the Builder failed to apply a rule on a widget. It will act only for the next widget creation or template invocation. strip_comments(lines) Remove all comments from all lines in-place. parse_level(level. message) Bases: kivy.e..lang. . you can construct custom widget from a kv lang definition by giving them a context.BuilderException(context. parse(content) Parse the contents of a Parser file and return a list of root objects.load_string(string.logger import Logger Logger.debug(’title: This is a debug’) try: raise Exception(’bleh’) except Exception. lines) Parse the current level (level * 4) indentation. line. error. default to False If True. unload_file(filename) Unload all rules associated to a previously imported file.lang. match(widget) Return a list of ParserRule matching the widget.info(’title: This is a info’) Logger. 9.lang. class kivy. the Builder will raise an exception if you have a root widget inside the definition. template(*args.5 With template.ParserException(context. versionadded:: 1. Warning: This will not remove rule or template already applied/used on current widget. critical. line. warning. **ctx) Create a specialized template using a specific context.lang.exception(e) 141 . Check Template usage. info.14 Logger object Differents level are available : trace. New in version 1. Comments need to be on a single line and not at the end of a line.Exception Exception raised when something wrong happened in a kv file.8.Parser(**kwargs) Bases: object Create a Parser object to parse a Kivy language file or Kivy content.. debug. class kivy. resolution. you’ll need new measurement unit to work with. Prefer to use sp instead of pt. This way. mm Millimeters . In Kivy.5.Based on the physical size of the screen 142 . all our graphics pipeline is working with pixels.LoggerHistory(level=0) Bases: logging.logger. 9. Units pt Points .1 Dimensions As you design your UI for different screen sizes.15. 9. because the size will changes according to the screen. density. you can “categorize” your message easily: Logger.2 Logger history Even if the logger is not enabled.Handler Kivy history handler 9.info(’Application: This is a test’) # will appear as [INFO ] [Application ] This is a test 9.logger. and the right part is used as a message. The left part is used as a title.logger import LoggerHistory print LoggerHistory.Logger = <logging. A screen is defined by its actual physical size. But using pixels as a measurement unit is wrong.0. These factors are essential for creating UI with correct size everywhere.14.1 Logger configuration Logger can be controled in the Kivy configuration file: [kivy] log_level = info log_enable = 1 log_dir = logs log_name = kivy_%y-%m-%d_%_.config module.Logger instance at 0x97a24cc> Kivy default logger instance class kivy.14.history kivy.The message passed to the logger is splited to the first :. you can still have the history of latest 100 messages: from kivy.1/72 of an inch based on the physical size of the screen.15 Metrics New in version 1.Based on the physical size of the screen cm Centimeters .txt More information about the allowed values is described in kivy. • KIVY_DPI: if set.5 python main. if you want to simulate an high-density screen (like HTC One X): KIVY_DPI=320 KIVY_METRICS_DENSITY=2 python main.0 <MyWidget>: Label: text: ’Hello world’ font_size: ’15sp’ size_hint_y: None height: self. used everywhere in the code class kivy. Once a value has been converted to pixels. and set a manual height with a 10dp margin: #:kivy 1. sp Scale-independent Pixels .2 python main.3 Manual control of metrics The metrics cannot be changed in runtime.15. the value varies between 0.metrics.75. 1. the number of pixels used to draw 1dp is scaled up by the factor of appropriate screen’s dpi. On android.py kivy.2 Examples An example of creating a label with a sp font_size. With a Metrics.15.An abstract unit that is based on the physical density of the screen.metrics. 1. Please note that settings the DPI will not impact dp/sp notation.Metrics Bases: object 143 .8-1.py --size 854x480 You can also simulate an alternative user preference for fontscale. It’s not like you’ll change the DPI or density in runtime. because thoses are based on the density.dpi. and the inverse for lower dpi.metrics. it provides consistency for the real-world size of your UI across different devices. 2. but it is also scaled by the user’s font size preference. It is recommended to use this unit when specifying font sizes.fontscale instead of the system one. this value will be used for Metrics. We provide new environment variables to control the metrics: • KIVY_METRICS_DENSITY: if set. On android.py --size 1280x720 Or a medium-density (like Motorola Droid 2): KIVY_DPI=240 KIVY_METRICS_DENSITY=1.density instead of the system one.in Inches . Using dp unit is a simple solution to making the view dimensions in your layout resize properly for different screen densities. In others words. The ratio dp-to-pixes will change with the screen density. • KIVY_METRICS_FONTSCALE: if set. 1dp is equal to 1px. so they will be adjusted for both the screen density and the user’s preference. For example. this value will be used for Metrics.5. you don’t have the original value anymore.2. this value will be used for Metrics. but not necessarily in direct proportions.This is like the dp unit. like: KIVY_METRICS_FONTSCALE=1. When running on a higher density screen.texture_size[1] + dp(10) 9. 9. the value varies between 0.Metrics object at 0xa2dd6cc> default instance of Metrics.density of 1.Based on the physical size of the screen dp Density-independent Pixels .5.metrics = <kivy. g. or from platform-specific module (like android/ios). This value is 1 by default.mm(value) Convert from millimeters to pixels kivy. ignoring case.8-1. Don’t use the class directly. rounded to the nearest of 120. 240. This value is 1 by default on desktop.inch(value) Convert from inches to pixels kivy. and varies on android depending the screen.parser.metrics.metrics.Class that contain the default attribute for metrics.dp(value) Convert from density-independent pixels to pixels kivy.metrics.parse_bool(text) Parse a string to a boolean. b) * rgba(r. g. 160. dpi() Return the DPI of the screen.2.metrics. Supported formats : * rgb(r.parse_float alias of float kivy. a) * aaa * rrggbb * #aaa * #rrggbb kivy.parser. and can varies between 0.parse_color(text) Parse a string to a kivy color.metrics.parse_int2(text) Parse a string to a list of exactly 2 integers >>> print parse_int2("12 54") 12. kivy.16 Parser utilities Helper functions used for CSS kivy.parser. Depending of the platform. dpi_rounded() Return the dpi of the screen.parser.sp(value) Convert from scale-independent pixels to pixels 9. b.pt(value) Convert from points to pixels kivy. fontscale() Return the fontscale user preference. kivy. the DPI can be taken from the Window provider (Desktop mainly). “false”/”0” is False.parse_int alias of int kivy. but use the metrics instance. “true”/”1” is True. Anything else throws an exception.parser.parser. 54 144 .cm(value) Convert from centimeters to pixels kivy.parse_string(text) Parse a string to a string (remove single and double quotes) kivy. 320. density() Return the density of the screen.metrics. 0) Value checking If you wanted to add a check such a minimum / maximum value allowed for a property. for example. validation for OptionProperty will make sure that the value is in a predefined list of possibilities.0): super(MyClass. 9. otherwise return the unmodified filename (as specified by the caller). you want a piece of code to be called when a widget’s pos property changes. here is a possible implementation in Python: 145 . Better Memory Management The same instance of a property is shared across multiple widget instances..e. a=1. For example.parse_filename(filename) Parse a filename and search for it using resource_find(). the @property decorator and the <property> type). 35 0’) 54. This prevents many errors early on.parser. the value is checked to pass constraints implemented in the class such as validation. 9. the resource path is returned.17 Properties The Properties classes are used when you create a EventDispatcher.a = a With Kivy. self). 0 kivy. Kivy’s property classes support: Value Checking / Validation When you assign a new value to a property. 87.parser. If found.1 Comparison Python / Kivy Basic example Let’s compare Python and Kivy properties by creating a Python class with ‘a’ as a float: class MyClass(object): def __init__(self.__init__() self.parse_float4(text) Parse a string to a list of exactly 4 floats >>> parse_float4(’54 87. you can do: class MyClass(EventDispatcher): a = NumericProperty(1. 35. you can bind a function to it. Observer Pattern You can specify what should happen when a property’s value changes. Warning: Kivy’s Properties are not to be confused with Python’s properties (i.17. Validation for NumericProperty will check that your value is a numeric type. If.kivy. You can bind your own function as a callback to changes of a Property. Kivy’s Properties implement the Observer pattern.a_max: raise ValueError(’a out of bounds’) self.17.a_min or value > self. max=500. _set_a) The disadvantage is you have to do that work yourself.a_max = 0 self. a=1): super(MyClass. you have two options to handle the error gracefully within the property. And it becomes laborious and complex if you have many properties.class MyClass(object): def __init__(self.a = a def _get_a(self): return self. Multiple ways are available to observe the changes. errorvalue=0) errorvalue parameter: # returns a the boundary value when exceeded bnp = BoundedNumericProperty(0. With Kivy. An errorvalue is a substitute for the invalid value. min=0. max=100) That’s all! Error Handling If setting a value would otherwise raise a ValueError. self). value): if value < self.a_min = 0 self._a = 0 self. Observe using bind() You can observe a property change by using the bind() method. errorhandler=lambda x: 500 if x > 500 else -500) Conclusion Kivy properties are easier to use than the standard ones. max=500. you can simplify like this: class MyClass(EventDispatcher): a = BoundedNumericProperty(1._a def _set_a(self. min=-500. That means you can bind() to a property and have your own function called when the value changes. See the next chapter for examples of how to use them :) 9. An errorhandler is a callable (single argument function or lambda) which can return a valid substitute.2 Observe Properties changes As we said in the beginning._a = a a = property(_get_a.__init__() self. errorhandler parameter: # simply returns 0 if the value exceeds the bounds bnp = BoundedNumericProperty(0. min=-500. outside the class: 146 . class kivy. print ’and the a value changed to’. value ins = MyClass() ins.properties. the observer list and storage initialisation. instance.hello = None # working too. you must not forget to call the subclass function too. None type handling. value): print ’My property a changed to’. value Warning: Be careful with ‘on_<propname>’. If you really want to do that. For example. you must declare the Property with allownone=True: class MyObject(Widget): hello = ObjectProperty(None. because the StringProperty will check the default value. you can’t set a list to a StringProperty. because allownone is True. By default. This class handles all the basic setters and getters. because the value didnt change ins. If you are creating such a callback on a property you are inherit. but you can’t set None to a property afterward.class MyClass(EventDispatcher): a = NumericProperty(1) def callback(instance. instance.a = 5 # callback called ins.a = 5 # callback not called. Parameters 147 .Property Bases: object Base class for building more complex properties. None is a special case: you can set the default value of a Property to None. you can use the ‘on_<propname>’ callback: class MyClass(EventDispatcher): a = NumericProperty(1) def on_a(self. any change to the a property will call your callback. allownone=True) # then later a = MyObject() a.bind(a=callback) # At this point. This class should not be directly instantiated.a = -1 # callback called Observe using ‘on_<propname>’ If you created the class yourself.hello = ’bleh’ # working a. a Property always takes a default value: class MyObject(Widget): hello = Property(’Hello world’) The default value must be a value that agrees with the Property type. ins. value): print ’My callback is call from’. but the instance doesn’t know anything about its name in the widget class: class MyWidget(Widget): uid = NumericProperty(0) In this example.0: The method is now accessible from Python. set() Set a new value for the property.x = "plop" Traceback (most recent call last): File "<stdin>".x = 42 >>> print wid.x 42 >>> wid.set 148 . in kivy.NumericProperty Bases: kivy. line 93. in kivy. class kivy.Property Property that represents a numeric value.1.property(’text’) # dispatch this property on the button instance prop.dispatch(button) get() Return the value of the property. >>> wid = Widget() >>> wid.properties. The link function is also used to create the storage space of the property for this specific widget instance.pyx".2: Parameters errorhandler and errorvalue added bind() Add a new observer to be called only when the value is changed. the uid will be a NumericProperty() instance.Property.pyx".Property. Changed in version 1. dispatch() Dispatch the value change to all observers. line 111. link() Link the instance with its real name. but the property instance doesn’t know its name. The NumericProperty accepts only int or float. When a widget is defined and uses a Property class.properties.errorhandler: callable If set. in <module> File "properties. This can be used to force the dispatch of the property.properties. the creation of the property object happens. even if the value didn’t change: button = Button() # get the Property class instance prop = button. line 1. That’s why link() is used in Widget.properties.4. unbind() Remove the observer from our widget observer list. Warning: Internal usage only.__set__ File "properties. will replace an invalid property value (overrides errorhandler) Changed in version 1. must take a single argument and return a valid substitute value errorvalue: object If set.__new__. ‘cm’. with the value of min max: numeric If set.Property Property that represents a string value. you must reassign a new python object.4. min=-5. class kivy. line 159.properties.ListProperty Bases: kivy. Tuple or any other classes are forbidden. class kivy.File "properties. New in version 1.property(’number’). get_format() Return the format used for Numeric calculation.properties. maximum bound will be used. in the format: ‘10pt’ or (10. Return None if no minimum value is set: class MyWidget(Widget): number = BoundedNumericProperty(0. “cm”.properties.Property Property that represents a list.BoundedNumericProperty Bases: kivy. get_max() Return the maximum value acceptable for the BoundedNumericProperty in obj.get_min(widget) # will output -5 149 . Otherwise.Property Property that represents only a boolean value.properties.properties.Property Property that represents a Python object. ‘mm’. ‘pt’. with the value of max bounds Return min/max of the value.9.Property Property that represents a numeric value within a minimum bound and/or maximum bound – within a numeric range. ‘pt’).0.properties.pyx". Warning: To mark the property as changed.1. Return None if no maximum value is set. get_min() Return the minimum value acceptable for the BoundedNumericProperty in obj. class kivy.properties. “mm”. minimum bound will be used.NumericProperty. “pt”. “px”. in kivy. Only a string or unicode is accepted. class kivy. New in version 1.properties. Default is px (mean the value have not been changed at all).StringProperty Bases: kivy. class kivy. Only lists are allowed.check ValueError: NumericProperty accept only int/float Changed in version 1.ObjectProperty Bases: kivy.BooleanProperty Bases: kivy.properties. it can be one of ‘in’.properties. Parameters min: numeric If set. Check get_min for a usage example.properties. like “in”.1: NumericProperty can now accept custom text and tuple value to indicate a type. max=5) widget = MyWidget() print widget.0. Parameters options: list (not tuple.1.0. Example from kivy/uix/widget.AliasProperty Bases: kivy. If you change the value of pos. New in version 1.set_min(widget. value): 150 .property(’number’).properties.width def set_right(self.9.OptionProperty Bases: kivy.ReferenceListProperty Bases: kivy. class kivy.properties. Check set_min for a usage example.x + self.set_min(widget.) List of valid options options Return the options available. New in version 1. it will automatically change the values of x and y accordingly.0.New in version 1.1. a ValueError exception will be raised. only for the obj instance. class kivy. it will return a tuple with the values of x and y. max=5) widget = MyWidget() # change the minmium to -10 widget.0.Property Property that represents a string from a predefined list of valid options. For example.property(’number’). If the string set in the property is not in the list of valid options (passed at property creation time). -10) # or disable the minimum check widget.properties. Set to None if you want to disable it: class MyWidget(Widget): number = BoundedNumericProperty(0. only for the obj instance.py: def get_right(self): return self. we can create a :class:‘ReferenceListProperty for the pos. class kivy.Property Property that allows the creaton of a tuple of other properties. Set to None if you want to disable it.Property Create a property with a custom getter and setter.properties. If you don’t find a Property class that fits to your needs. you can make your own by creating custom Python getter and setter methods. Warning: Changing the bounds doesn’t revalidate the current value.0. if x and y are NumericProperty‘s. set_min() Change the minimum value acceptable for the BoundedNumericProperty.1. None) Warning: Changing the bounds doesn’t revalidate the current value.properties. If you read the value of pos.properties. min=-5. New in version 1. set_max() Change the maximum value acceptable for the BoundedNumericProperty. resource_remove_path(path) Remove a search path New in version 1.0.install_android() Install hooks for android platform. these are the arguments one would usually pass to twisted’s reactor. kivy. the installed reactor will not handle any signals unnless you set the ‘installSignalHandlers’ keyword argument to 1 explicitly. Any other classes are forbidden. 151 . the value will be cached. This is done to allow kivy to handle teh signals as usual.properties.startRunning Unlike the default twisted reactor. Use resource_add_path to add a custom path to search.install_gobject_iteration() Import and install gobject context iteration inside our event loop.x = value . unless you specifically want the twisted reactor to handle the signals (e.g.4.self.resources.self. SIGINT).support.install_twisted_reactor(**kwargs) Installs a threaded twisted reactor. 9. Only dict are allowed. which will schedule one reactor iteration before the next frame only when twisted needs to do some work.Property Property that represents a dict. We are offering you 2 functions for searching specific resources across a list of paths.properties. 9. class kivy.support. as property name strings cache: boolean If True. kivy. ’width’)) Parameters getter: function Function to use as a property getter setter: function Function to use as a property setter bind: list/tuple Properties to observe for changes.resource_find(filename) Search a resource in list of paths. set_right.width right = AliasProperty(get_right. any arguments or keyword arguments passed to this function will be passed on the the threadedselect reactors interleave function.resources.support.resource_add_path(path) Add a custom path to search in kivy. This is used as soon as gobject is used (like gstreamer) kivy.19 Support Activate other framework/toolkit inside our event loop kivy. until one of the binded elements will changes Changed in version 1. bind=(’x’.8.0: Parameter cache added.DictProperty Bases: kivy. kivy.18 Resources management Resource management can be a pain if you have multiple path and project.resources. intersection(set1.utils.utils.deprecated(func) This is a decorator which can be used to mark functions as deprecated.SafeList Bases: list List with clear() method Warning: Usage of iterate() function will decrease your performance.strtotuple(s) Convert a tuple string into tuple.get_color_from_hex(s) Transform from hex string color to kivy color kivy. default to 1.20 Utils kivy.pos = interpolate(self. Can be useful to smooth some transition. minvalue. class kivy. For example: # instead of setting directly self. and you’ll have a nice transition self. with some security check. 68)’ # return (12. kivy. step=10) Interpolate a value to another.is_color_transparent(c) Return true if alpha channel is 0 kivy.utils.interpolate(value_from.utils. value_to.get_random_color(alpha=1.utils. 152 .•Automaticly sleep when the device is paused •Auto kill the application is the return key is hitted 9. set2) Return intersection between 2 list kivy. 68) kivy. 54. 54.0] if alpha == ‘random’ a random alpha value is generated kivy.utils.boundary(value. maxvalue) Limit a value between a minvalue and maxvalue kivy. 68) b = str(a) c = strtotuple(b) # return ’(12. 54. Designed to be used with eval() function: a = (12.pos.utils.pos = pos # use interpolate.utils.utils. It will result in a warning being emitted the first time the function is used.difference(set1.0) Returns a random color (4 tuple) Parameters alpha [float.utils. set2) Return difference between 2 list kivy. No test are done if the dimension is not the same. new_pos) Warning: This interpolation work only on list/tuple/double with the same dimension. This New will return one in version 1.utils.34 v = Vector(82.class kivy. Exemple for constructing a Vector: >>> >>> >>> 82 >>> 82 >>> 34 >>> 34 # Construct a point at 82. with the value 1 d.QueryDict Bases: dict QueryDict is a dict() that can be queried with dot.0.reify(func) Bases: object Put the result of a method which uses this (non-data) descriptor decorator in the instance dict after the first call. the value is cached as a regular attribute. 45) 153 .utils. 9.21 Vector The Vector represent a 2D vector (x. markup=True) New in version 1. linux. ios. y). except that the function is only ever called once. unknown Warning: ios is not currently reported.8.utils.y >>> # Construct by giving a list of 2 values >>> pos = (93. class kivy.3. Our implementation is made in top of a Python list.escape_markup(text) Escape markup characters found in the text.platform() Return the version of the current platform. android. New in version 1. 34) v[0] v.0. Intended to be used when markup text is activated on the Label: untrusted_text = escape_markup(’Look at the example [1]’) text = ’[color=ff0000]’ + untrusted_text + ’[/color]’ w = Label(text=text. Taken from Pyramid project. effectively replacing the decorator with an instance variable. This gives you lazy attribute creation on objects that are meant to be immutable.utils. It acts like @property. d = QueryDict() # create a key named toto.4.x v[1] v. after that. kivy. of: win. macosx.0.toto = 1 # it’s the same as d[’toto’] = 1 kivy. See module documentation for more information.5] >>> Vector(10. 10) / Vector(2. 0] >>> Vector(10. Vector(a).5] class kivy.distance(b) # non-optimized method va = Vector(a) vb = Vector(b) print ’distance between a and b:’.2 Vector operators The Vector support some numeric operator like +.1 Optimized usage Most of time. 154 . 10) b = (87.distance(vb) 9. if you want to have the distance between 2 points: a = (10.>>> >>> 93 >>> 93 >>> 45 >>> 45 v = Vector(pos) v[0] v.x v[1] v. 7. 5) .21.) [5.21. 1) >>> v += 2 >>> v [3.Vector(*largs) Bases: list Vector class. 5) [4. va. 3] >>> v *= 5 [15. /: >>> Vector(1. 6] >>> Vector(9. 1) + Vector(9.Vector(5. 2.vector. 34) # optimized method print ’distance between a and b:’. For example. you can use a list for arguments. -.y 9.0] You can also do in-place operations: >>> v = Vector(1.. [7. 15] >>> v /= 2. 10) / 5. 2.0.0. 5) [10. instead of using a Vector. 4.5. [2. angle((-77. 2)) 12 static in_bbox(point. 10) >>> Vector(pos).0 >>> Vector(87. 10)) 5. v2. 34) >>> Vector(a). >>> Vector(10. bmax) True >>> Vector. v3.length() 14. 50). 33) >>> b = (76. bmax) False length() Returns the length of a vector.angle(a) Computes the angle between a and b.length2() 200 static line_intersection(v1.in_bbox((50. >>> Vector(2.035668847618199 distance2(to) Returns the distance between two points squared.distance((5. 10) >>> Vector(pos). 100)) -90.angle((0.length2() 200 >>> pos = (10.length() 14.142135623730951 >>> pos = (10. 100) >>> Vector. 10)) -157.dot((2. >>> bmin = (0. >>> a = (90. 10). bmin.distance2((5. >>> Vector(10. a. b) Return a true if point is in bbox defined by a and b.7920283010705 distance(to) Returns the distance between two points. 23). 0). 10)) 25 dot(a) Computes the dot product of a and b. 4). 0) >>> bmax = (100. >>> Vector(10. >>> Vector(10. and return the angle in degrees. 155 .in_bbox((647. bmin. >>> Vector(100. 10).142135623730951 length2() Returns the length of a vector squared. v4) Finds the intersection point between the lines (1)v1->v2 and (2)v3->v4 and returns it as a vector object. -10). 10). 10).distance(b) 14. >>> v = Vector(88.rotate(45) >>> v [70.22 Weak Method WeakMethod is used in Clock class to prevent the clock from taking memory if the object is deleted.length() 1.WeakMethod(method) Bases: object Implementation of weakref for function and bounded method. 33).normalize() >>> v [0. 0.weakmethod.wikipedia. >>> v = Vector(12. >>> v = Vector(100. This WeakMethod class is taken from the recipe http://code. d) [15.com/recipes/81253/.line_intersection(a.710678118654755. 28) >>> b = (72. 23) >>> v[0] 12 >>> v. based on the nicodemus version. 156 . -5) >>> d = (20.>>> a = (98.911669367909241] Warning: This is a line intersection method.y 23 9.93632917756904444. 23) >>> v[1] 23 >>> v.3511234415883917] >>> v. but has a length of one.org/wiki/Line-line_intersection normalize() Returns a new vector that has the same direction as vec. For math see: http://en. c. not a segment intersection.py for more information. 88) >>> Vector.0 rotate(angle) Rotate the vector with an angle in degrees. 0) >>> v.710678118654741] x x represent the first element in the list.activestate. 70. 43. b.x 12 y y represent the second element in the list. >>> v = Vector(12. Check examples/core/clock_method.25931928687196. 33) >>> c = (10. (thanks to him !) class kivy. is_dead() Returns True if the referenced callable was a bound method and the instance no longer exists. 157 . Otherwise. return False. 158 . For example. The result will use the best sound provider for reading the file.1 Audio Load an audio sound and play it with: from kivy.uix instead.3f seconds" % sound.core. class kivy. For further information.audio. Always try to use our providers first.source print "Sound is %.core.event. You have to use the image widget class instead.load(’mytest. please let us know by opening a new Bug report instead of relying on your library. you cannot add a core image to your window.wav’) if sound: print "Sound found at %s" % sound. so you might have a different Sound class depending the file.Sound(**kwargs) Bases: kivy.play() You should not use directly the sound class yourself. please refer to Architectural Overview and the Core Providers and Input Providers section of the documentation. Use SoundLoader to load a sound ! Events on_play [None] Fired when the sound is played on_stop [None] Fired when the sound is stopped filename Deprecated since version 1. please refer to kivy. you shouldn’t directly use a library that’s already covered by the core abstraction. 10.CHAPTER TEN CORE ABSTRACTION This module defines the abstraction layers for our core providers and their implementations.length sound. Note: Recording audio is not supported. In most cases.EventDispatcher Represent a sound to play.3.0: Use source instead 159 .audio import SoundLoader sound = SoundLoader. This class is abstract. Warning: These are not widgets! These are just abstractions of the respective functionality. In case we are missing a feature or method. and cannot be used directly. If you’re really looking for widgets. and convert the input to a Texture. returns 0 if not playing New in version 1. default to None.0.0.1. 0 mean mute. New in version 1. with usage of the best loader for a given filename.3. read-only.3. class kivy. Use the SoundLoader. 160 . state State of the sound.load() for loading audio. int)] Size at which the image is drawn. Parameters index: int Source index of the camera. class kivy.EventDispatcher Abstract Camera Widget class. one of ‘stop’ or ‘play’ New in version 1. and return a Sound() instance static register(classobj) Register a new class to load sound state is an 10.core. If no size is specified.3. OptionProperty. static load(filename) Load a sound.2 Camera Core class for acquiring the camera. New in version 1.SoundLoader Load a sound.audio.CameraBase(**kwargs) Bases: kivy. read-only. source a StringProperty. size [tuple (int. it defaults to resolution of the camera image. default to 1. status Deprecated since version 1. in the range 0-1.0.0: Use state instead stop() Stop playback unload() Unload the file from memory volume Volume.core.4. length Get length of the sound (in seconds) load() Load the file into memory play() Play the file seek(position) Seek to the <position> (in seconds) source Filename / source of your image.3. Concrete camera classes must implement initialization and frame capturing to buffer that can be uploaded to gpu. volume is a NumericProperty.get_pos() get the current position of the audio file. 1 mean full volume.camera.event. height) start() Start the camera acquire stop() Release the camera texture Return the camera texture with the latest capture 10. ’UTF8_STRING’. 161 .clipboard import Clipboard >>> Clipboard. int)] Resolution to try to request from the camera. ’TEXT’. and the texture became available on_frame Fired each time the camera texture is updated index Source index of the camera init_camera() Initialise the camera (internal) resolution Resolution of camera capture (width.4 OpenGL Select and use the best OpenGL library available. ’SAVE_TARGETS’. ’UTF8_STRING’) >>> Clipboard. Anything else might not work the same on all platform.get(’TEXT’) ’Hello World’ >>> Clipboard. ’STRING’.get(’UTF8_STRING’) ’Great’ Note: The main implementation rely on Pygame. If the camera doesnt support the resolution a negotiation error might be thrown.core. and works great with text/string.charset=utf-8’. Used in the gstreamer pipeline by forcing the appsink caps to this resolution.put(’Great’.get_types() [’UTF8_STRING’] >>> Clipboard.3 Clipboard Core class for accessing to the Clipboard.resolution [tuple (int. ’TARGETS’. ’COMPOUND_TEXT’. ’text/plain. Depending on your system. If we are not able to access to the system clipboard.get_types() [’TIMESTAMP’. Events on_load Fired when the camera is loaded. the core provider can select an OpenGL ES or a ‘classic’ desktop OpenGL library. ’text/plain’] >>> Clipboard. a fake one will be used. ’MULTIPLE’. Usage example: >>> from kivy. 10. In the latter case. class kivy. New methods for handling sequenced animation too.event. New in version 1. Image widget might change itself the texture.0. and store the size and texture. default to False] Create mipmap for the texture anim_delay: float. default to False] Keep the image data when texture is created scale [float. anim_available Return True if this Image instance have animation available.0. Usage: # start/reset animation image. filename Get/set the filename of image 162 . anim_delay Delay betwean each animation frame. default to . Note: Saving image is not yet supported.anim_delay = 1 / 20. New in version 1. You can also provide a texture object or an already existing image object.EventDispatcher Load an image. Parameters arg [can be str or Texture or Image object] A string is interpreted as a path to the image to be loaded.core.New in version In: 1. A new event ‘on_texture’ have been introduced.8. texture_mipmap and texture_rectangle have been deleted.7. New in version 1. anim_reset(allow_anim) Reset an animation if available.0.anim_reset(True) # or stop the animation image.Image(arg. **kwargs) Bases: kivy.0. New in version In: 1. Lower means faster animation. mipmap attribute have been added. The raw image data can be keep in memory for further access. Lower means faster animation. default to 1.25 Delay in seconds between each animation frame. keep_data [bool.0.0.5 Image Core classes for loading image and convert them to Texture.8.10.0] Scale of the image mipmap [bool.8.image.8. a real copy of the given image object will be returned. anim_index Return the index number of the image currently in the texture New in version 1.anim_reset(False) You can change the animation speed in live: # Set to 20 FPS image. Parameters allow_anim: bool Indicate if the animation should restart playing or not.8. New in version 1. data) Add a image for a specific mipmap level.ImageData(width. Warning: This function can be used only with images loaded with keep_data=True keyword.image. **kwargs) Load an image Parameters filename [str] Filename of the image keep_data [bool. For examples: m = Image. keep_data=True) color = m.3. 150) Parameters x [int] Local x coordinate of the pixel in question.height Image height image Get/set the data image object static load(filename.read_pixel(150.0.do something -im. New in version 1.jpg’) # this time image will be re-loaded from disk size Image size (width. it will use the level 0) 163 . read_pixel(x.core. width.jpg’) # -. height. This facilitates re-loading of image from disk in case of contents having been changed.8.remove_from_cache() im = CoreImage(’1. The container will always have at least the mipmap level 0. flip_vertical=True) Bases: object Container for image and mipmap images. return the color at that position. height) texture Texture of the image width Image width class kivy. fmt.0. remove_from_cache() Remove the Image from cache.7. It’s actually used for sequenced images. y) For a given local x/y position.0.png’. default to False] Keep the image data when texture is created on_texture(*largs) This event is fired when the texture reference or content have been changed. New in version 1. Usage: im = CoreImage(’1. add_mipmap(level.load(’image. y [int] Local y coordinate of the pixel in question. data. source=None. (If the image is mipmapped. height. data Image data. SpellingBase(language=None) Bases: object Base class for all spelling providers. u’helot’.g. >>> from kivy. E. return True.spelling import Spelling >>> s = Spelling() >>> s.. u’helm’. Parameters word [str] The word to check.0. but other backends can be added that implement the same API. .: [’en’. size Image (width. Spelling currently require python-enchant for all platform.6 Spelling Provide abstracted access to a range of spellchecking backends.flip_vertical Indicate if the texture will need to be vertically flipped fmt Decoded image format.spelling. list_languages() Return a list of all languages supported by the registered languages. (If the image is mipmapped.7. u’he-lo’] class kivy. mipmaps Data for each mipmap. ‘en_GB’. Supports some abstract methods for checking words and getting suggestions. return None (e. it will use the level 0) 10. u’hell’. True is returned. it will use the level 0) source Image source. ‘en_US’. u’hero’. u’held’. u’halo’. for ‘’). height Image height in pixels. If the word shouldn’t be checked. ‘de’. If the word is a valid word in the currently active language.core.0. ’en_GB’. (If the image is mipmapped. height) in pixels.select_language(’en_US’) >>> s.7. The API is inspired by enchant.g. one of a available texture format get_mipmap(level) Get the mipmap image at a specific level if exist New in version 1.check(’helo’) [u’hole’. Also provides word suggestions. ’en_US’] >>> s. if available width Image width in pixels. it will use the level 0) iterate_mipmaps() Iterate over all mipmap images available New in version 1.core.] 164 . ’en_CA’. u’help’. where a native implementation exist.._language. u’hello’. except OSX. (If the image is mipmapped. check(word) If word is a valid word in self.list_languages() [’en’. : ‘foo’ might become ‘of’.7: The LabelBase don’t generate any texture is the text have a width <= 1. select the first language for language.8. color=None. text_size=None.Exception Exception to be raised when a specific language could not be found.spelling. class kivy.NoLanguageSelectedError Bases: exceptions.0.0.text. E. ‘food’ or ‘foot’. Depending of the selected backend. default to 0.core. size have been deprecated and replaced with text_size Parameters font_size: int. halign=’left’.7 Text Abstraction of text creation.e.New in version In: 1.select_language(language) From the set of registered languages..Exception Exception to be raised when a language-using method is called but no language was selected prior to the call.LabelBase(text=’‘. mipmap=False. suggest(fragment) For a given fragment (i. This wasn’t the case before.core. New in version In: 1. class kivy. bold=False. default to (None. font_size=12. default to False Activate “italic” text style text_size: tuple. Sets the language used for spell checking and word suggestions. default to False Activate “bold” text style italic: bool. shorten=False. it will set padding_x and padding_y padding_x: float. default to None If it’s a float. you must recreate one. the valign is now respected.spelling. default to 12 Font size of the text font_name: str. the text rendering can be more or less accurate. font_name=’DroidSans’. Changed in version 1. italic=False.0.7. padding: float. This is the abstract class used for different backend to render text.0 Left/right padding 165 . None) Add constraint to render the text (inside a bounding box) If no size is given.NoSuchLangError Bases: exceptions. provide corrections (fragment may be misspelled) or completions as a list of strings. Parameters language [str] Language identifier. Parameters fragment [str] The word fragment to get suggestions/corrections for. You might have issue in your application if you never think about that before. Needs to be one of the options returned by list_languages().g.core. default to DEFAULT_FONT Font name of the text bold: bool. class kivy. valign=’bottom’. **kwargs) Bases: object Core text label. the label size will be set to the text size. part of a word or a word by itself). Warning: The core text label can’t be changed at runtime. 10. height) for a text. render(real=False) Return a tuple(width. Example of a markup text: 166 . default to 0. then you need to register it and use the alias instead. default to “left” Horizontal text alignement inside bounding box valign: str. splitting line and calculate max width + height • if user set a width. Setting this to True without an appropriately set size will lead unexpected results. fn_bolditalic=None) Register an alias for a Font. default to “bottom” Vertical text alignement inside bounding box shorten: bool. The syntax look the same as the BBCode. default to False] Create mipmap for the texture content_height Return the content height content_size Return the content size (width. height) content_width Return the content width fontid Return an uniq id for all font parameters get_extents(text) Return a tuple with (width. you might not be able to use bold/italic of the ttf version. We provide a simple text-markup for inline text styling.1 Text Markup New in version 1.resources. If the font is delivered with different version of it (one regular.1. height) of the contrained rendering box usersize (deprecated) Use text_size instead. 10. height) to create the image with the user constraints.padding_y: float. fn_regular.0.0. blit per glyph text Get/Set the text text_size Get/set the (width. one italic and one bold). fn_bold=None. 2 differents methods are used: • if user don’t set width. If fn_italic/fn_bold are None.1. New in version 1. label Get/Set the text refresh() Force re-rendering of the text static register(name. A tag is defined as [tag]. defaults to False Indicate whether the label should attempt to shorten its textual contents as much as possible if a size is given.resource_find(). and might have a closed tag associated: [/tag].0 Top/bottom padding halign: str. fn_italic=None. fn_regular will be used instead. All the fn_regular/fn_italic/fn_bold parameters are resolved with kivy.7. mipmap [bool. If you’re using a ttf directly. **kwargs) Bases: kivy. versionchanged:: added ‘pause’ 167 . .graphics. y2). ’anchorB’: (x. class kivy.core. Can be one of ‘pause’.]: { ’refA’: ((x1.text. use kivy.[b]Hello [color=ff0000]world[/b][/color] The following tags are availables: [b][/b] Activate bold text [i][/i] Activate italic text [font=<str>][/font] Change the font [size=<integer>][/size] Change the font size [color=#<color>][/color] Change the text color [ref=<str>][/ref] Add an interactive zone. anchors Get the position of all the [anchor=.anchors If you need to escape the markup from the current text. (x1. eos [str. ’Hello world’. x2.]: { ’anchorA’: (x.markup. Note: Recording is not supported.MarkupLabel(*largs...text.core. See module documentation for more informations. Parameters filename [str] Filename of the video. class kivy.Texture video. } 10.VideoBase(**kwargs) Bases: kivy. y1.. y).. ‘stop’ or ‘loop’ . a class to implement a video reader.. default to ‘pause’] Action to do when EOS is hit.core. } markup Return the text with all the markup splitted: >>> MarkupLabel(’[b]Hello world[/b]’).markup >>> (’[b]’. x2.escape_markup(). ’[/b]’) refs Get the bounding box of all the [ref=.8 Video Core class for reading video file and manage the kivy. Can be a file or an URI.event.video.LabelBase Markup text label. y)..utils.texture. .. You can get the position of your anchor within the text with MarkupLabel. y2)).refs [anchor=<str>] Put an anchor in the text. The reference + all the word box inside the reference will be available in MarkupLabel..EventDispatcher VideoBase.. y1. Don’t try to create more than one. modifiers Fired when a new key is down 168 .9 Window Core class for create the default Kivy window.0 play() Play the video position Get/set the position in the video (in seconds) seek(percent) Move on percent position state Get the video playing status stop() Stop the video playing texture Get the video texture unload() Unload the actual video volume Get/set the volume in the video (1. you’ll receive event though this instance.request_keyboard(). default to False] Auto play the video at init Events on_eos Fired when EOS is hit on_load Fired when the video is loaded. When you request a keyboard.Keyboard(**kwargs) Bases: kivy.4. class kivy.. versionadded:: 1. that is returned by WindowBase.0 = 100%) 10.event.async [bool. texture is available on_frame Fired when a new frame is written on texture duration Get the video duration (in seconds) filename Get/set the filename/uri of current video load() Load the video from the current filename pause() Pause the video . text. Events on_key_down: keycode. default to True] Asynchronous loading (may be not supported by all providers) autoplay [bool.core. Whatever is the keyboard input (system or virtual keyboard).window.EventDispatcher Keyboard interface. you’ll get an instance of this class. Kivy support only one window creation. modifiers are %r’ % modifiers # Keycode is composed of an integer + a string # If we hit escape.require(’1. according to the current configuration: import kivy kivy. ‘screenlock’: 145. keycode._on_keyboard_down) self. release the keyboard if keycode[1] == ’escape’: keyboard. it will return -1. ‘numpaddecimal’: 268. If the value is not found inside the keycodes. release() Call this method to release the current keyboard. string_to_keycode(value) Convert a string to a keycode number._keyboard.keycodes. target = None 169 .release() # Return True to accept the key. ‘8’: 56. ‘\\’ Keycodes mapping.base import runTouchApp runTouchApp(MyKeyboardListener()) callback = None Callback that will be called when the keyboard is released keycode_to_string(value) Convert a keycode number to a string.key. modifiers): print ’The key’. it will be used by # the system.bind(on_key_down=self. according to the Keyboard. ‘‘’: 96.0. Theses keycode are currently taken from pygame.unbind(on_key_down=self.text is %r’ % text print ’ . self) self._keyboard. ‘0’: 48. This will ensure that keyboard is not attached to you anymore. return True if __name__ == ’__main__’: from kivy. between str <-> int.uix._keyboard = Window.keycodes. it must do the translation to theses keycodes too.core. ‘. ‘<’: 60. Otherwise._keyboard = None def _on_keyboard_down(self.’: 44.widget import Widget class MyKeyboardListener(Widget): def __init__(self. **kwargs): super(MyKeyboardListener. text._keyboard_closed.8’) from kivy. keycodes = {‘pause’: 19. If the value is not found in the keycodes. keycode. keyboard. ‘4’: 52.request_keyboard( self.__init__(**kwargs) self.window import Window from kivy. according to the Keyboard. ’have been pressed’ print ’ .on_key_up: keycode Fired when a key is up Here is an example about how to request a Keyboard. it will return ‘’. self). But when a new provider will be used._on_keyboard_down) def _keyboard_closed(self): print ’My keyboard have been closed!’ self. and will be removed completely in future versions on_key_down: key. Parameters fullscreen: str. scancode.0 The unicode parameter has be deprecated in favor of codepoint. scancode. ‘1’. scancode. if allowed by the configuration window = None Window which the keyboard is attached too class kivy.3.event. codepoint Fired when a key is up .core. versionchanged:: 1. 170 ..3. for any window implementation.3.window. check config documentation for more explaination about the values. codepoint Fired when a key is down .. and will be removed completely in future versions on_dropfile: str Fired when a file is dropped on the application add_widget(widget) Add a widget on window center Center of the rotated window.EventDispatcher WindowBase is a abstract window widget. versionchanged:: 1.Target that have requested the keyboard widget = None VKeyboard widget. motionevent Fired when a new MotionEvent is dispatched on_touch_down: Fired when a new touch appear on_touch_move: Fired when an existing touch is moved on_touch_up: Fired when an existing touch disapear on_draw: Fired when the Window is beeing drawed on_flip: Fired when the Window GL surface is beeing flipped on_rotate: rotation Fired when the Window is beeing rotated on_close: Fired when the Window is closed on_keyboard: key. and will be removed completely in future versions on_key_up: key. ‘fake’) Make window as fullscreen. versionchanged:: 1.0 The unicode parameter has be deprecated in favor of codepoint. one of (‘0’.0 The unicode parameter has be deprecated in favor of codepoint. modifier Fired when the keyboard is in action . width: int Width of window height: int Height of window Events on_motion: etype.. codepoint. ‘auto’. center is a AliasProperty.WindowBase(**kwargs) Bases: kivy. 0. This method exist to permit the creation of a new OpenGL context AFTER closing the first one. Use kivy.core. Again. children is a ListProperty instance.clearcolor = None close() Close the window create_window(*largs) Will create the main window and configure it. default to an empty list. it will recreate a RenderContext and Canvas. modifiers List of keyboard modifiers currently in action mouse_pos 2d position of the mouse within the window. Warning: This method is called automatically at runtime. This method have been only tested in unittest environment. “auto”.2. it will just return 96. That’s mean the screen size will not change.window import Window # red background color Window.base. height is a AliasProperty. clear() Clear the window with background color clearcolor Color used to clear window. Use add_widget() and remove_widget() for manipulate children list. Warning: This value is not cross-platform.EventLoop. height Rotated window height. and will be not suitable for Applications.clearcolor = (1.0. Don’t manipulate children list directly until you know what you are doing. on_close(*largs) Event called when the window is closed 171 . and use the current one to set the app fullscreen New in version 1. This mean you’ll have a new graphics tree. 0. If the implementation doesn’t support any DPI lookup. 1) # don’t clear background at all Window.children List of children of this window. (Like using runTouchApp() and stopTouchApp()). the window will be put in fullscreen mode. New in version 1.2.dpi instead. and the old one will be unusable. :: from kivy. If you call it. don’t use this method unless you know exactly what you are doing ! dpi() Return the DPI of the screen. 0. flip() Flip between buffers fullscreen If true. ‘end’ me: MotionEvent Motion Event currently dispatched on_mouse_down(x. All will be closed. modifiers) Event called when mouse is in action (press/release) on_mouse_move(x.0. height) Event called when the window is resized on_rotate(rotation) Event called when the screen have been rotated on_touch_down(touch) Event called when a touch is down on_touch_move(touch) Event called when a touch move on_touch_up(touch) Event called when a touch up parent Parent of this window parent is a ObjectProperty instance. button. scancode=None. When created. android etc. modifier=None. release_all_keyboards() New in version 1. 172 . modifier=None. Parameters etype: str One of ‘begin’. y. codepoint=None. This will ensure that no virtual keyboard / system keyboard are actually requested. the parent is set to the window itself. modifiers) Event called when mouse is moving. codepoint=None. with buttons pressed on_resize(width. codepoint and/or modifier! on_motion(etype. on_flip() Flip between buffers (event) on_key_down(key. me) Event called when a Motion Event is received. modifier=None. scancode=None. default to None. Warning: This event is actually used only on MacOSX with a patched version of pygame. y. button. modifiers) Event called when mouse is moving.on_dropfile(filename) Event called when a file is dropped on the application.2.8. with buttons pressed on_mouse_up(x. ‘update’. scancode=None.) New in version 1. codepoint=None. **kwargs) Event called when a key is down (same arguments as on_keyboard) on_key_up(key. But this will be a place for a further evolution (ios. **kwargs) Event called when keyboard is in action Warning: Some providers may omit scancode. y.0. **kwargs) Event called when a key is up (same arguments as on_keyboard) on_keyboard(key. You must take care of it if you are doing recursive check. New in version 1.0. and if configuration allowed it. If set. or if the user itself closed it. to release the real-keyboard.Window = None Instance of a WindowBase implementation 173 . kivy. width is a AliasProperty. 90. rotation Get/set the window content rotation. a VKeyboard instance. you don’t want to share it with another widget. This method is not intented to be used by end-user. If rotation is set. Check request_keyboard() to understand how it works. A widget can request the keyboard. Internal method for widget.0. without taking care of the rotation.release_keyboard(target=None) New in version 1.png’) Save the actual displayed image in a file set_icon(filename) Set the icon of the window New in version 1. It can be because somebody else requested the keyboard. to request the keyboard. that will be called from the vkeyboard. Can be one of 0. Changed in version 1.5.8.0.vkeyboard. target) New in version 1. Ensure you have a target attached if you’re using the keyboard in a multi users mode. set_title(title) Set the window title. set_vkeyboard_class(cls) New in version 1.uix.8: target have been added. and must be the widget source that request the keyboard.window. if you want to use the real-keyboard (not virtual keyboard).core. Return An instance of Keyboard. Parameters callback: func Callback that will be called when the keyboard is closed.0. remove_widget(widget) Remove a widget from window request_keyboard(callback. it will use the size Get the rotated size of the window. screenshot(name=’screenshot%(counter)04d. however.VKeyboard. Internal method for widget. the widget must have one method named on_keyboard_text. then the size will change to reflect the rotation. target: Widget Attach the keyboard to the specified target. system_size Real size of the window. containing the callback. If None set. indicating a callback to call when the keyboard will be released (or taken by another widget). kivy. 180.0. 270 degrees. target.0.5.4. toggle_fullscreen() Toggle fullscreen on window width Rotated window width. Set the VKeyboard class to use.4. 174 . kex files on your own. With Kivy’s extension system. This prevents clashes with modules with the same name that might 175 . Kivy will do that for you as soon as it’s appropriate to do so.g. your application can use specially packaged third-party libraries in a backwards compatible way (by specifying the version that you require) even if the actual third-party library does not guarantee backwards-compatibility.load(extname. put in a special directory and then offers the functionality of the wrapped library to Kivy applications. If you want to provide an extension on your own. but you must not unzip them yourself. This is because we cannot make the same backwardscompatibility guarantee that we make with Kivy for third-party extensions. Warning: Again. consider the documentation of the load() function. It can be found at kivy/tools/extensions/makekivyext.CHAPTER ELEVEN EXTENSION SUPPORT Sometimes your application requires functionality that is beyond the scope of what Kivy can deliver. Some libraries require special wrappers being written for them to be compatible with Kivy. This is different from kivy’s require() in that it will always use the exact same major version you specify. version) Use this function to tell Kivy to load a specific version of the given Extension. if they open their own OpenGL context to draw in and don’t support proper offscreen rendering). That is where Kivy extensions come in handy. There will be no breakage if newer versions are installed (as a properly suited old version will still be used). there is already a great number of software libraries that you can simply import and use right away. Sticking with this example. it’s not as easy as that though. For more information about that behaviour. Kivy will not be able to load the extension and will simply ignore it. These extensions will not pollute the global Python environment (as they might be unusable on their own after potential patches have been applied) because they reside in special directories for Kivy that are not accessed by Python by default. The function will then return the loaded module as a Python module object and you can bind it to a name of your choosing. do not try to unzip *. They are really just zip files. Some libraries might even need to be patched so that they can be used (e. A Kivy extension represents a single third-party library that is provided in a way so that it can simply be downloaded as a single file. In those cases it is necessary to resort to external software libraries. You will still get fixes and optimizations that don’t break backwards compatibility via minor version upgrades of the extension. In those occasions it is often possible to patch the library in question and to provide a Python wrapper around it that is compatible with Kivy. there is a helper script that sets up the initial extension folder structure that Kivy requires for extensions. even if a newer (major) version is available. Kivy extensions are provided as *.py kivy. Given the richness of the Python ecosystem. you can’t just use the wrapper with a ‘normal’ installation of the library because the patch would be missing.ext. While unzipping will work.kex files. For some third-party libraries. e. but between major versions it is not.path or elsewhere in the system. kivy. increase the major version number (and reset the minor to 0). All names that should be usable when the extension is loaded need to be exported (i. It is important to note that between minor versions. Usage example for this function: from kivy. How the extension accesses the code of the library that it wraps (be it pure Python or binary code) is up to the extension. Internal usage only. minor).myextension/ |-. •We require that the extension internally obeys the common Kivy extension format. it has to fulfil a few requirements: •We require that the file has the *.unzip_extensions() Unzips Kivy extensions. backwards-compatible feature.e. 2) would be akin to 1. •We require that the version of the extension be specified in the setup.data/ The __init__. 2). Parameters extname: str The exact name of the extension that you want to use.g. Don’t use it yourself unless you know what you’re doing and really want to trigger installation of new extensions.2. # but with the added benefit of using the proper version.ext import load myextension = load(’myextension’. The two ints major and minor can both be in range(0. if you change your extension in a backwards incompatible way. For example there could be another Python module adjacent to the __init__. (1. (2. made available) in the namespace of that file. For your file to be recognized as an extension. 176 .py file that is created by the Kivy extension wizard and that the version specification format as explained in load() be used. If the application then requires version (1. •We require that the *.py |-. infinity). backwards compatibility is guaranteed.ext.e.kivy/extensions and extensions/ inside kivy’s base dirextory. 1)) # You can now use myextension as if you had done ‘‘import myextension‘‘.py file from which the __init__. I. If you just do a bug fix or add an optional. where major and minor are ints that specify the major and minor version number for the extension.be installed in a system directory. which looks like this: |-.py file imports the usable names that it wants to expose.__init__. version: two-tuple of ints A tuple of the form (major.kex extension to make the distinction between a Kivy extension and an ordinary zip file clear. you can just increase the minor version number. •We require that the Kivy extension is zipped in a way so that Python’s zipfile module can extract it properly.kex extension files be put into any of the directories listed in EXTENSION_PATHS which is normally ~/. every version starting with that version number will be ok and by default the latest version will be choosen.py file is the main entrypoint to the extension. We do not look for extensions on sys. FBO. During the lifetime of the application.2. but pygame is not available on it by default yet.1 The basics For drawing on a screen.CHAPTER TWELVE GRAPHICS This package assemble all low level function to draw object. If self is your current widget.0. on MacOSX and Windows platform. The whole graphics package is compatible OpenGL ES 2. cause of SDL 1..2. it need to recreate a GL context everytime the window is resized. VBO. This is happening: • When window is resized. This is fixed in SDL 1.0. and will be used when the window drawing will happen.canvas: # Add a red color Color(1. and have a lot of rendering optimizations. a Canvas object. 12. the OpenGL context might be lost. In the SDL 1.2 GL Reloading mechanism New in version 1. you can create all the instructions needed for drawing.graphics import * with self. We have all the data to reconstruct when reloading. When the user switch back to your application.2. we introduced a mechanism for reloading all the graphics resources using the GPU: Canvas.2 design. if you’re using pygame as window provider. 10). When you are creating a widget. 500)) The instructions Color and Rectangle are automaticly added to the canvas object. Shader. 12. • when Android release the app resources: when your application goes to background. Starting from 1. Instruction objects. 0) # Add a rectangle Rectangle(pos=(10. VertexBatch: • VBO and VertexBatch are constructed by our graphics instructions. 177 . size=(500. 2.0. a newly gl context is given to you. you will need : 1.3. Each widget in Kivy already have by default their Canvas. android system might reclaim your opengl context to give the resource to another app. you can do: from kivy. 0. Texture. graphics. segments Property for getting/setting the number of segments of the curve class kivy.instructions.graphics. and manually blit data / buffer to it. dash_length Property for getting/stting the length of the dashes in the curve dash_offset Property for getting/setting the offset between the dashes in the curve points Property for getting/settings points of the triangle Warning: This will always reconstruct the whole graphics from the new points list. an atlas. the image is reloaded from the source. (The text rendering is generating the texture.0. changing this makes it dashed.ContextInstruction BindTexture Graphic instruction. We don’t keep a history of the instruction put on it.BindTexture Bases: kivy. default 0..8. Parameters texture: Texture specifies the texture to bind to the given index source Set/get the source (filename) to load for texture. Check the Texture to learn how to manage that case.graphics. class kivy.graphics.Bezier Bases: kivy.graphics. we store the source and values used in the shader. The BindTexture Instruction will bind a texture and enable GL_TEXTURE_2D for subsequent drawing.. class kivy. default to 180 Define how much segment is needed for drawing the ellipse..) • FBO: if you added / removed / drawed things multiple times on the FBO. you must handle the reloading yourself. • Texture: if the texture have a source (an image file. Check the Framebuffer to learn how to manage that case. we are able to recreate the vertex/fragment/program. New in version 1. dash_length: int length of a segment (if dashed). default 1 dash_offset: int distance between the end of a segment and the start of the next one. default to False Set the bezier curve to join last point to first.graphics. Parameters points: list List of points in the format (x1.vertex_instructions. and reuploaded to the GPU.VertexInstruction A 2d Bezier curve. loop: bool. y2.instructions. and handle already the reloading.). You don’t need to reload text yourself. y1.Rectangle 178 . You should cover theses cases yourself: • Texture without source: if you manually created a texture. As texture without source.BorderImage Bases: kivy. It can be very CPU expensive.• Shader: same as VBO.) segments: int. The drawing will be smoother if you have lot of segment.. we can’t reload it. x2. The drawing of your canvas can not happen until something new happens.Callback Bases: kivy. New in version 1.size) Callback(self. The behavior of the border image is similar to the concept of CSS3 borderimage.graphics.4.pos. 1) Rectangle(pos=self. When adding instructions to a canvas. You can have glitches.instructions. Use this class to add graphics or context instructions that you want to be used for drawing.cb = Callback(self. 1. A Callback is an instruction that will be called when the drawing operation is performed. From your callback. This is useful when you need to trigger a redraw due to some value having changed for example. bottom.0.my_callback) The definition of the callback must be: def my_callback(self. The OpenGL state may have been manipulated by the other toolkit. Warning: The reset_context is not a full OpenGL reset. reset_context Set this to True if you want to reset the OpenGL context for Kivy after the callback has been called.instructions. black holes might occur. left). you can ask for an update: with self. If you have issues regarding that. etc. after the call to your callback.A 2d border image. Each value is in pixels. crashes. 179 . please contact us. size=self. you can activate the reset_context option.graphics. border Property for getting/setting the border of the class class kivy. instr): print ’I have been called!’ Warning: Note that if you perform many and/or costly calls to callbacks.graphics.Instruction New in version 1. you might potentially slow down the rendering performance significantly.ask_update() If you use the Callback class to call rendering methods of another toolkit. you will have issues with the OpenGL context. it will just break.graphics.canvas: self. right.cb. It will reset the OpenGL context state to make Kivy’s rendering correct.canvas: Color(1. you can do this: with self.my_callback) # then later in the code self.4.CanvasBase The important Canvas class. and as soon as program flow returns to Kivy. To avoid that. ask_update() Inform the parent canvas that we’d like it to update on the next frame. class kivy. Parameters border: list Border information in the format (top.0.Canvas Bases: kivy. 5) using hsv mode = Color(0. opacity Property for get/set the opacity value of the canvas. Usage of a canvas without the with statement: self. 1. 50)) after Property for getting the ‘after’ group.0. 0) Rectangle(size=(50. In Python.2. 1. mode=’hsv’) 180 . not 0 and 255.. 0. 1. 0) create blue color with 50% alpha = Color(0. 1. and one children have an opacity of 0. draw() Apply the instruction on our window. 0) create blue color = Color(0. 1. 50))) Usage of a canvas with Python’s with statement: with self.canvas. the opacity is applied on the shader as: frag_color = color * vec4(1.graphics. 1. ask_update() Inform the canvas that we’d like it to update on the next frame. and the result is applied to the current context color.graphics import Color # c # c # c # c # c create red color = Color(1.add(Color(1. 1.Color Bases: kivy.instructions.2 = 0. .0.canvas: Color(1. the real opacity of the children will be 0. before Property for getting the ‘before’ group.graphics. you can do: from kivy. 1. Then. .5.. 1. This is useful when you need to trigger a redraw due to some value having changed for example. 0)) self... For example: if your parent have an opacity of 0.1.add(Rectangle(size=(50. 1.Note: The Canvas supports Python’s with statement and its enter & exit semantics. All the values passed are between 0 and 1.1. Be careful. The opacity attribute controls the opacity of the canvas and its children. 0. it’s a cumulative attribute: the value is multiplied to the current global opacity.0.5 * 0.ContextInstruction Instruction to set the color state for any vertices being drawn after it. mode=’hsv’) using hsv mode + alpha = Color(0.2. New in version 1.canvas.4. class kivy. opacity). 0.graphics. 0 # blue color Color: rgb: 0. alpha will be 1. rgba RGBA color. between 0-1 class kivy. texture binding.graphics.graphics. matrix manipulation and so on. list of 3 values in 0-1 range. 0.ContextInstruction Bases: kivy. 1 # using hsv mode + alpha Color: hsv: 0. between 0-1 hsv HSV color.5 a Alpha component.Instruction The ContextInstruction class is the base for the creation of instructions that don’t have a direct visual representation. 0. list of 3 values in 0-1 range. but instead modify the current Canvas’ state. r Red component. alpha will be 1. between 0-1 h Hue component.graphics. 1. 0 # blue color with 50% alpha Color: rgba: 0.vertex_instructions.g. setting color parameters. 1. .In kv lang: <Rule>: canvas: # red color Color: rgb: 1. class kivy. between 0-1 v Value component. between 0-1 g Green component. list of 4 values in 0-1 range s Saturation component. New in version 1. between 0-1 b Blue component.7: added angle_start + angle_end 181 . 1. e.Ellipse Bases: kivy.Rectangle A 2D ellipse. 1 a: . 1. between 0-1 rgb RGB color.instructions.5 # using hsv mode Color: hsv: 0. of the disk portion angle_end: int default to 360 Specifies the ending angle.2. add_reload_observer() Add a callback to be called after the whole graphics context have been reloaded. 0.RenderContext Fbo class for wrapping the OpenGL Framebuffer extension. angle_start: int default to 0 Specifies the starting angle. 1024) Default size of the framebuffer push_viewport: bool.Fbo Bases: kivy.fbo. New in version 1. default to 180 Define how much segment is needed for drawing the ellipse. default to False If True. default to 0 segments Property for getting/setting the number of segments of the ellipse class kivy.0. the OpenGL viewport will be set to the framebuffer size. Parameters callback: func(context) -> return None The first parameter will be the context itself bind() Bind the FBO to the current opengl context. with_depthbuffer: bool. a default texture will be created. and will be automatically restored when the framebuffer released.fbo = FBO() self. until release() is called. default to 360 angle_start Angle start of the ellipse in degrees. default to None If None. Bind mean that you enable the Framebuffer. texture: Texture.texture 182 .bind() # do any drawing command self.fbo.release() # then. in degrees. 0) Define the default color for clearing the framebuffer size: tuple. But if you want to manipulate a Framebuffer yourself. of the disk portion angle_end Angle end of the ellipse in degrees.graphics. default to True If True. The Fbo support “with” statement. the framebuffer will be allocated with a Z buffer. you can use it like this: self. The drawing will be smoother if you have lot of segment.graphics. Parameters clear_color: tuple. 0.instructions.Parameters segments: int. in degrees.fbo. your fbo texture is available at print self. default to (0. This is where you can reupload your custom data in GPU. The bind/release operation are automatically done when you add graphics object in it. and all the drawing operations will act inside the Framebuffer. default to (1024. VertexInstruction A 2d line. This class is for internal usage only. size Size of the framebuffer.graphics. You need to bound the framebuffer yourself before calling this method: fbo. remove_reload_observer() Remove a callback from the observer list. Drawing a line can be done easily: 183 . the framebuffer content will be lost. don’t use it directly. green. alpha) format. previously added by add_reload_observer().InstructionGroup Bases: kivy.GraphicException Bases: exceptions. class kivy.instructions. insert() Insert a new Instruction in our list at index.graphics. texture Return the framebuffer texture class kivy.graphics. add() Add a new Instruction to our list. clear() Remove all the Instruction. get_group() Return an iterable with all the Instruction with a specific group name.Line Bases: kivy. release() Release the Framebuffer (unbind).Instruction Group of Instruction.graphics.clear_buffer() Clear the framebuffer with the clear_color. in (width.instructions.clear_buffer() fbo. Adds the possibility of adding and removing graphics instruction.2. class kivy.Instruction Bases: object Represents the smallest instruction available. New in version 1.Exception Exception fired when a graphic error is fired. blue. class kivy. height) format.release() clear_color Clear color in (red. If you change the size.graphics.graphics. remove() Remove an existing Instruction from our list.0.bind() fbo. remove_group() Remove all Instruction with a specific group name. Additionally. stencil will be used internally to draw the line. x2. dash_length and dash_offset works. while properties for cap and joint have no sense for this.. if the current color have an alpha < 1.with self. 100. default 1 dash_offset: int Offset between the end of a segments and the begining of the next one. based on triangles. changing this makes it dashed. 200]. default to ‘round’ See cap for more information.0.If the width is 1.) dash_length: int Length of a segment (if dashed). then we will use a custom drawing method. 184 . 100. default 1.If the width is > 1.0. 100. width: float Width of the line.0. y1.0 cap: str. dash_length and dash_offset is not working on that mode. 2. y2.. 200. width=10) Actually. default 0. Parameters points: list List of points in the format (x1. the line have 3 internal drawing mode that you should know about if you want to get the best performance of it: 1.canvas: Line(points=[100. then we will use standard GL_LINE drawing from OpenGL. rectangle have been added. bezier_precision Number of iteration for drawing the bezier between 2 segments. the points will be set to build an ellipse. width. segments): •center_x and center_y represent the center of the circle •radius represent the radius of the circle •(optional) angle_start and angle_end are in degree. circle: list If set. y. ellipse: list If set. Usage: Line(rectangle=(0. without calculate the points. not get it. Check rectangle for more information. height) angle_end. cap_precision.4. cap Determine the cap of the line. bezier_precision have been added.1. the points will be set to build a circle. joint_precision.2.4. radius. New in version 1. ellipse.0. joint. Can be one of ‘none’.8: dash_offset and dash_length have been addedNew in version 1. the line will be closed. ‘square’ or ‘round’ New in version 1. The argument must be a tuple of (x. New in version 1. New in version 1. bezier_precision: int. 200)) New in version 1. segments): •x and y represent the bottom-left position of the rectangle •width and height represent the size The line is automatically closed. Check circle for more information. cap_precision: int.1: width.1: bezier. 185 The . 0. The cap_precision must be at least 1.1.4. not get it. bezier Use this property to build a rectangle. the points will be set to build a rectangle. You can only set this property. default to 180 Precision of the Bezier drawing. bezier_precision must be at least 1. default to 10 See cap_precision for more information joint_precision: int. default to 10. rectangle: list If set.New in version 1. circle Use this property to build a circle. default to 180. without calculate the points.4. default to ‘round’. 200. center_y. bezier: list If set. Check bezier for more information. The default value is 0 and 360. the points will be set to build a bezier line. default to False If True.4. You can only set this property. angle_end. default to ‘round’ See joint for more information. The argument must be a tuple of (center_x. angle_start. default to 10 See joint_precision for more information close: bool. cap. cap_precision Number of iteration for drawing the “round” cap. close.2. Check ellipse for more information.4.joint: str. angle_start.8. default to ‘round’. The default value is 0 and 360. the line will be closed. ‘bevel’. Can be one of ‘none’.4. segments): •x and y represent the bottom left of the ellipse •width and height represent the size of the ellipse •(optional) angle_start and angle_end are in degree. 50. close If True. 90.4. 20)) is calculated New in version 1. for building a simple ellipse.1. Note that it’s up to you to close the ellipse or not. in python: # simple circle Line(circle=(150. 150. y. •(optional) segments is the precision of the ellipse. 150.1. 180. 50)) # only from 90 to 180 degrees Line(circle=(150.1. 90. with few segments Line(ellipse=(0. 0. 90.4. 150.0.4. 20)) is calculated New in version 1. dash_offset Property for getting/setting the offset between the dashes in the curve New in version 1. New in version 1. 150.0.•(optional) segments is the precision of the ellipse. Note that it’s up to you to close the circle or not. 50.4. The default value from the range between angle. 150)) # only from 90 to 180 degrees Line(ellipse=(0. For example. For example. height. dash_length Property for getting/setting the length of the dashes in the curve New in version 1. 180)) # only from 90 to 180 degrees. 150.8. The argument must be a tuple of (x. ‘miter’. New in version 1. in python: # simple ellipse Line(ellipse=(0. The joint_precision must be at least 1. 0. not get it. with few segments Line(circle=(150. New in version 1. 90. angle_end. 150. joint_precision Number of iteration for drawing the “round” joint. You can only set this property. 180)) # only from 90 to 180 degrees. 150. 186 . 0. 180. without calculate the points. for building a simple ellipse. default to 10. ‘round’. ellipse Use this property to build an ellipse. joint Determine the join of the line. width. 150.1. The default value from the range between angle.1. You can only set this property. y2.1. height) angle_end. default to 1.) indices: list List of indices in the format (i1. x2.Mesh Bases: kivy.graphics. i2.graphics.1. The argument must be a tuple of (x. u2. this might change in a future release... 1. x2. width.graphics. Numpy matrix from transformation module setting the matrix using this porperty when a change is made is important. v1. y. v1. v2.VertexInstruction A 2d mesh. Check mode for more information. each vertex is described with 2D coordinates (x.instructions.graphics. Default to ‘points’. A list of vertices is described as: vertices = [x1.. Usage: Line(rectangle=(0.. becasue it will notify the context about the update class kivy. y2. In OpenGL ES 2..4. . y) and a 2D texture coordinate (u. you cannot have more than 65535 indices. not get it.1. It can be very CPU expensive. v2.points Property for getting/settings points of the line Warning: This will always reconstruct the whole graphics from the new points list.0 and in our graphics implementation.4. rectangle Use this property to build a rectangle. 200)) New in version 1.i1 ----+ +---.. 2] New in version 1. u2. class kivy. then you can make an indices list as: indices = [0. 200.ContextInstruction Base class for Matrix Instruction on canvas matrix Matrix property. u1. v). i3.) mode: str Mode of the vbo. 0. width Determine the width of the line. 187 . u1. put 3 vertices.MatrixInstruction Bases: kivy. The format of vertices are actually fixed.0. y1. Right now.] | | | | +---.i2 ----+ If you want to draw a triangles.0.instructions. without calculate the points. Parameters vertices: list List of vertices in the format (x1. y1. segments): •x and y represent the bottom-left position of the rectangle •width and height represent the size The line is automatically closed. New in version 1. 0.PushMatrix Bases: kivy. the Mesh instruction doesn’t allow you to change the format of the vertices.graphics. mean the real size will be 2) Warning: Starting from version 1. add_point() Add a point into the current points list.Rectangle Bases: kivy.graphics. x3.) pointsize: float. x2. y. 2 entry in the list (x + y) will be converted to 4 vertices. ‘line_loop’. If you use add_point. mode VBO Mode used for drawing vertices/indices. points Property for getting/settings points of the triangle pointsize Property for getting/setting point size class kivy. If you intend to add multiple point.instructions. used to construct the Mesh. class kivy.graphics. x2.ContextInstruction PushMatrix on context’s matrix stack class kivy. ‘triangle_fan’ Can be one of: ‘points’. Parameters 188 .graphics.PopMatrix Bases: kivy.instructions. it will only upload the changes.graphics. y4) points Property for getting/settings points of the quads class kivy.. y3.VertexInstruction A 2d line.Quad Bases: kivy.instructions. default to 1. y1..instructions. Parameters points: list List of point in the format (x1.graphics. vertex instruction have a limit of 65535 vertices (indices of vertex to be accurate).. ‘line_strip’. u. Size of the point (1.ContextInstruction Pop Matrix from context’s matrix stack onto model view class kivy. Right now. mean it’s only x/y + one texture coordinate. y2.graphics. ‘lines’.7.indices Vertex indices used to know which order you wanna do for drawing the mesh. v.VertexInstruction A 2d rectangle..graphics. ‘triangle_strip’.graphics. prefer to use this method.Point Bases: kivy.graphics.VertexInstruction A 2d quad. So the limit inside Point() class is 2^15-2. Parameters points: list List of points in the format (x1. x4. vertices List of x. y1. . Assigning a new points list will recalculate and reupload the whole buffer into GPU. instead of reassign a new points list.instructions. y2. StencilPush Bases: kivy.: rot.graphics.Instruction Push the stencil stack.Instruction Use current stencil buffer as a mask. height) pos Property for getting/settings the position of the rectangle size Property for getting/settings the size of the rectangle class kivy.instructions.instructions.graphics..graphics..graphics.Canvas The render context stores all the necessary information for drawing. in the format (x.instructions. class kivy.Scale Bases: kivy.instructions. matrix.graphics.graphics.Transform Rotate the coordinate space by applying a rotation transformation on the modelview matrix.StencilPop Bases: kivy.context_instructions. Check module documentation for more information. You can set the properties of the instructions afterwards with e. y.Instruction Pop the stencil stack.g.: •The vertex shader •The fragment shader •The default texture •The state stack (color.Transform Instruction to perform a uniform scale transformation scale Property for getting/setting the scale.RenderContext Bases: kivy. See module documentation for more information.context_instructions.) class kivy. See module documentation for more information. y) size: list Size of the rectangle. in the format (width.angle = 90 rot.axis = (0.graphics.graphics. 189 .StencilUse Bases: kivy. class kivy.graphics.graphics. class kivy. texture. The same scale value is applied on all axis. set() Set the angle and axis of rotation >>> rotationobject.0.Rotate Bases: kivy. z).graphics. 1) class kivy.1) angle Property for getting/settings the angle of the rotation axis Property for getting/settings the axis of the rotation The format of the axis is (x. 0. 0. i.e.set(90.pos: list Position of the rectangle.graphics. If you want to use an image as source. y3) points Property for getting/settings points of the triangle class kivy. do it like this: with self.Translate Bases: kivy.graphics.VertexInstruction A 2d triangle. y1.graphics.size Note: The filename will be searched with the kivy. pos=self.class kivy. x2. such as Rectangles.graphics. x3.resources. y2.canvas: Rectangle(source=’mylogo. y.graphics. Lines.pos. size=self. and z axis y Property for getting/setting the translation on Y axis z Property for getting/setting the translation on Z axis class kivy. 190 . class kivy.graphics.Instruction The VertexInstruction class is the base for all graphics instructions that have a direct visual representation on the canvas.StencilUnUse Bases: kivy.instructions. source This property represents the filename to load the texture from.context_instructions.graphics. Ellipse and so on.instructions. Parameters points: list List of point in the format (x1.graphics.VertexInstruction Bases: kivy.resource_find() function.Instruction Use current stencil buffer to unset the mask.graphics.instructions.size) Here’s the equivalent in Kivy language: <MyWidget>: canvas: Rectangle: source: ’myfilename.Transform Instruction to create a translation of the model view coordinate space x Property for getting/setting the translation on X axis xy 2 tuple with translation vector in 2D for x and y axis xyz 3 tuple translation vector in 3D in x.png’.Triangle Bases: kivy. Triangles.pos size: self.png’ pos: self. 0. the color buffer will be cleared clear_depth If true. pos=self. Depending on the image and label providers. clear_color If true.graphics. texture Property that represents the texture used for drawing this Instruction. y + h. between 0-1 b Blue component. and a size (w. you will use the source attribute instead of the texture. list of 3 values in 0-1 range.texture with self.png’). h). because of the order in which the image is internally stored. Clear the buffers specified by the instructions buffer mask property.core. between 0-1 r Red component. The value must be a list of 8 values.graphics. the coordinates are flipped vertically.0.instructions. the depth buffer will be cleared 191 .ClearBuffers Bases: kivy. v. rgba RGBA used for clear color.canvas: Rectangle(texture=texture. New in version 1. u + w. if you want to achieve fancy effects. only the coloc buffer is cleared. class kivy.Instruction Clearbuffer Graphic Instruction New in version 1. Instead of flipping the image data. a Alpha component. alpha will be 1. or ClearBuffers graphics instructions. the tex_coords are: [u. between 0-1 g Green component.3. and would represent the ‘flipped’ texture. list of 4 values in 0-1 range class kivy.graphics. u.graphics. between 0-1 rgb RGB color.tex_coords This property represents the texture coordinates used for drawing the vertex instruction.image import Image texture = Image(’logo. By default. A texture coordinate has a position (u. v.pos.instructions. You can set a new texture like this: from kivy.Instruction ClearColor Graphic Instruction.ClearColor Bases: kivy. we are just flipping the texture coordinates to be faster. v). size=self. Warning: The default value as mentioned before can be negative.3. By default. y + h] You can pass your own texture coordinates. Sets the clear color used to clear buffers with glClear function.size) Usually. The size can be negative. u + w. Check the class documentation for more information about the usage of Canvas. pos=self. class kivy.instructions.size) Here’s the equivalent in Kivy language: <MyWidget>: canvas: Rectangle: source: ’myfilename. Triangles.png’ 192 . get_group() Return an iterable with all the Instruction with a specific group name.instructions.Instruction Group of Instruction.Instruction The ContextInstruction class is the base for the creation of instructions that don’t have a direct visual representation.png’. remove() Remove an existing Instruction from our list.3 Canvas The Canvas is the root object used for drawing by a Widget.VertexInstruction Bases: kivy.g. such as Rectangles.graphics.pos.graphics.InstructionGroup Bases: kivy.graphics. don’t use it directly. Lines.instructions.clear_stencil If true.Instruction Bases: object Represents the smallest instruction available. insert() Insert a new Instruction in our list at index. class kivy. This class is for internal usage only. source This property represents the filename to load the texture from.graphics.graphics. matrix manipulation and so on.instructions. the stencil buffer will be cleared 12. setting color parameters. texture binding. add() Add a new Instruction to our list. do it like this: with self.canvas: Rectangle(source=’mylogo.graphics. Adds the possibility of adding and removing graphics instruction. but instead modify the current Canvas’ state. Ellipse and so on.instructions.ContextInstruction Bases: kivy. size=self. e.Instruction The VertexInstruction class is the base for all graphics instructions that have a direct visual representation on the canvas.instructions. clear() Remove all the Instruction.graphics. If you want to use an image as source. class kivy. remove_group() Remove all Instruction with a specific group name.instructions. class kivy. core.image import Image texture = Image(’logo. 1.pos size: self. u.texture with self.graphics. 0)) self. you will use the source attribute instead of the texture. y + h] You can pass your own texture coordinates.size Note: The filename will be searched with the kivy. y + h.CanvasBase The important Canvas class. and would represent the ‘flipped’ texture. the coordinates are flipped vertically.resources.graphics.size) Usually. Usage of a canvas without the with statement: self. Warning: The default value as mentioned before can be negative.png’).canvas: Rectangle(texture=texture. texture Property that represents the texture used for drawing this Instruction. Depending on the image and label providers. 50)) after Property for getting the ‘after’ group..resource_find() function.. and a size (w. The value must be a list of 8 values. 1. we are just flipping the texture coordinates to be faster.canvas. Use this class to add graphics or context instructions that you want to be used for drawing. tex_coords This property represents the texture coordinates used for drawing the vertex instruction. 0) Rectangle(size=(50.. You can set a new texture like this: from kivy. 193 .pos: self. if you want to achieve fancy effects.add(Color(1. Note: The Canvas supports Python’s with statement and its enter & exit semantics. By default.canvas: Color(1.instructions.Canvas Bases: kivy.pos. v. A texture coordinate has a position (u.add(Rectangle(size=(50. The size can be negative. Instead of flipping the image data. u + w.. h). size=self. class kivy. v. pos=self. because of the order in which the image is internally stored. v).instructions.canvas. the tex_coords are: [u. u + w. 50))) Usage of a canvas with Python’s with statement: with self. canvas: self.instructions.Canvas The render context stores all the necessary information for drawing. For example: if your parent have an opacity of 0. This is useful when you need to trigger a redraw due to some value having changed for example. Then.instructions.4. texture. Be careful.0. it’s a cumulative attribute: the value is multiplied to the current global opacity. class kivy.pos. 1) Rectangle(pos=self. before Property for getting the ‘before’ group. you can ask for an update: with self. the real opacity of the children will be 0.) class kivy.my_callback) # then later in the code self. When adding instructions to a canvas.RenderContext Bases: kivy. you might potentially slow down the rendering performance significantly. A Callback is an instruction that will be called when the drawing operation is performed.my_callback) The definition of the callback must be: def my_callback(self. draw() Apply the instruction on our window. opacity).canvas: Color(1. 1. The drawing of your canvas can not happen until something new happens.instructions.2.0.instructions.. and the result is applied to the current context color. 1.Callback Bases: kivy.size) Callback(self.e.: •The vertex shader •The fragment shader •The default texture •The state stack (color.cb = Callback(self.graphics.Instruction New in version 1. i.graphics. 1.. and one children have an opacity of 0.0.1. instr): print ’I have been called!’ Warning: Note that if you perform many and/or costly calls to callbacks.graphics.5 * 0.0. matrix.4. New in version 1. the opacity is applied on the shader as: frag_color = color * vec4(1.ask_update() Inform the canvas that we’d like it to update on the next frame.1. The opacity attribute controls the opacity of the canvas and its children. opacity Property for get/set the opacity value of the canvas. you can do this: with self.5.graphics.2 = 0. size=self.ask_update() 194 . From your callback.cb. New in version 1. 0) create blue color with 50% alpha = Color(0. 1. . after the call to your callback. PopMatrix.0. You can have glitches. It will reset the OpenGL context state to make Kivy’s rendering correct. black holes might occur. All the values passed are between 0 and 1.8: LineWidth instruction have been removed.0. 0. We need to do more experimentation to get it right. . 1. This is useful when you need to trigger a redraw due to some value having changed for example. In Python. 1. To avoid that.Color Bases: kivy. Rotate. reset_context Set this to True if you want to reset the OpenGL context for Kivy after the callback has been called. Scale. 1.2. Warning: The reset_context is not a full OpenGL reset.If you use the Callback class to call rendering methods of another toolkit.ContextInstruction Instruction to set the color state for any vertices being drawn after it. etc.4. mode=’hsv’) In kv lang: <Rule>: canvas: # red color Color: 195 . The OpenGL state may have been manipulated by the other toolkit.instructions. please contact us.graphics import Color # c # c # c # c # c create red color = Color(1. 12. you can activate the reset_context option. Check the bug #207 for more informations.graphics. 1. It wasn’t working before. ask_update() Inform the parent canvas that we’d like it to update on the next frame. 0) create blue color = Color(0. not 0 and 255. you can do: from kivy.context_instructions. Translate. 0. If you have issues regarding that.graphics. and as soon as program flow returns to Kivy.4 Context instructions The context instructions represent non graphics elements like: • Matrix manipulation (PushMatrix. mode=’hsv’) using hsv mode + alpha = Color(0. 1. you will have issues with the OpenGL context. and we actually no implementation working. crashes. class kivy. it will just break.5) using hsv mode = Color(0. MatrixInstruction) • Color manipulation (Color) • Texture binding (BindTexture) Changed in version 1. list of 3 values in 0-1 range.graphics.context_instructions. 0 # blue color with 50% alpha Color: rgba: 0. between 0-1 g Green component.5 # using hsv mode Color: hsv: 0. The BindTexture Instruction will bind a texture and enable GL_TEXTURE_2D for subsequent drawing. between 0-1 hsv HSV color.ContextInstruction BindTexture Graphic instruction. 0.BindTexture Bases: kivy. class kivy. 1. 0 # blue color Color: rgb: 0. .graphics.instructions. list of 4 values in 0-1 range s Saturation component.graphics.PushMatrix Bases: kivy. r Red component. between 0-1 v Value component. alpha will be 1. between 0-1 h Hue component. 1.5 a Alpha component. list of 3 values in 0-1 range. alpha will be 1.rgb: 1.ContextInstruction PushMatrix on context’s matrix stack 196 . between 0-1 rgb RGB color. 1 # using hsv mode + alpha Color: hsv: 0. rgba RGBA color. 1 a: . 1. between 0-1 b Blue component.context_instructions. 0.graphics. between 0-1 class kivy. Parameters texture: Texture specifies the texture to bind to the given index source Set/get the source (filename) to load for texture.instructions. 1. Scale Bases: kivy.class kivy. class kivy.: rot. set() Set the angle and axis of rotation >>> rotationobject.context_instructions.context_instructions.graphics.MatrixInstruction Bases: kivy.Rotate Bases: kivy.graphics.graphics.g.Translate Bases: kivy.graphics. y. 1) class kivy.1) angle Property for getting/settings the angle of the rotation axis Property for getting/settings the axis of the rotation The format of the axis is (x.ContextInstruction Base class for Matrix Instruction on canvas matrix Matrix property.graphics.context_instructions. becasue it will notify the context about the update 197 .context_instructions. and z axis y Property for getting/setting the translation on Y axis z Property for getting/setting the translation on Z axis class kivy.set(90.instructions. y.0.Transform Instruction to perform a uniform scale transformation scale Property for getting/setting the scale. 0. Numpy matrix from transformation module setting the matrix using this porperty when a change is made is important.PopMatrix Bases: kivy.graphics.ContextInstruction Pop Matrix from context’s matrix stack onto model view class kivy. The same scale value is applied on all axis.graphics.context_instructions. z).context_instructions.context_instructions.context_instructions.graphics.axis = (0.graphics.angle = 90 rot. 0.Transform Rotate the coordinate space by applying a rotation transformation on the modelview matrix.instructions. You can set the properties of the instructions afterwards with e.graphics.Transform Instruction to create a translation of the model view coordinate space x Property for getting/setting the translation on X axis xy 2 tuple with translation vector in 2D for x and y axis xyz 3 tuple translation vector in 3D in x. 2. texture=self. Rectangle class FboTest(Widget): def __init__(self. 12. 512)) self. 64)) Color(0.fbo = Fbo(size=(512. . 0..fbo. 128). If the OpenGL context is lost.1 Reloading the FBO content New in version 1.fbo.5 Context management New in version 1. You need to reupload data on it yourself. you can draw whatever you want on the fbo with self. .fbo: Color(1. and the ability to flush and delete them.texture) Rectangle(pos=(32.__init__(**kwargs) self.).0.add_reload_observer() to add a reloading function that will be automatically called when needed: def __init__(self.8) Rectangle(size=(256.0. Fbo act as a kivy.texture) Rectangle(pos=(96. and canvas where the fbo is putted will be automaticly updated too. and use your fbo as a texture for another drawing.add_reload_observer(self. 256)) If you change anything in the self.8) Rectangle(size=(64. 0. 64).Canvas. 198 . 0. 256)) # show our fbo on the widget in different size Color(1.__init__(**kwargs) # first step is to create the fbo and use the fbo texture on other # rectangle with self.canvas: # create the fbo self. 0).populate_fbo) # and load the data now.fbo.12. **kwargs): super(FboTest. size=(64. 32).fbo. Color. Use the Fbo. **kwargs): super(.texture) # in the second step.graphics import Fbo.6.6 Framebuffer Fbo is like an offscreen window.graphics. texture=self. 0). This class handle a register of all graphics instructions created.instructions. You can read more about it at Graphics 12.. 1. You can activate the fbo for rendering into a texture. 1. texture=self. self).2. then the FBO is lost too. 1) Rectangle(size=(32. it will be automaticly updated.fbo object.fbo = Fbo(size=(256. size=(128. Example of using an fbo for some color rectangles: from kivy. 0. 0. fbo): with fbo: # . class kivy. New in version 1. and all the drawing operations will act inside the Framebuffer.release() # then. But it’s up to you.bind() fbo. But if you want to manipulate a Framebuffer yourself. put your Color / Rectangle / .graphics.clear_buffer() fbo.fbo. The Fbo support “with” statement.populate_fbo(self.0.Fbo Bases: kivy. default to (0. You need to bound the framebuffer yourself before calling this method: fbo. default to False If True. you could use the same method for initialization and for reloading.instructions.fbo.graphics.RenderContext Fbo class for wrapping the OpenGL Framebuffer extension. Parameters clear_color: tuple. texture: Texture. your fbo texture is available at print self. a default texture will be created.. 0) Define the default color for clearing the framebuffer size: tuple. alpha) format. the OpenGL viewport will be set to the framebuffer size.2. 199 .self. default to True If True..fbo) def populate_fbo(self. add_reload_observer() Add a callback to be called after the whole graphics context have been reloaded.. here This way.fbo.fbo. 1024) Default size of the framebuffer push_viewport: bool.release() clear_color Clear color in (red.fbo = FBO() self.bind() # do any drawing command self. default to None If None. until release() is called. and will be automatically restored when the framebuffer released. blue. The bind/release operation are automatically done when you add graphics object in it. default to (1024.texture clear_buffer() Clear the framebuffer with the clear_color. you can use it like this: self. green. the framebuffer will be allocated with a Z buffer. Bind mean that you enable the Framebuffer. Parameters callback: func(context) -> return None The first parameter will be the context itself bind() Bind the FBO to the current opengl context. This is where you can reupload your custom data in GPU. with_depthbuffer: bool. New in version 1.0.gl_instructions.3. 12. 0.Instruction Clearbuffer Graphic Instruction New in version 1.gl_instructions. list of 4 values in 0-1 range class kivy. you can use ClearColor and ClearBuffers instructions like this example: self.graphics.graphics. between 0-1 g Green component. only the coloc buffer is cleared.instructions. the color buffer will be cleared 200 . or ClearBuffers graphics instructions.graphics.3. between 0-1 b Blue component.3.fbo = Fbo(size=self. 0. the framebuffer content will be lost.1 Clearing an FBO To clear an FBO. in (width. between 0-1 r Red component. New in version 1. If you change the size. texture Return the framebuffer texture 12.ClearColor Bases: kivy.Instruction ClearColor Graphic Instruction. rgba RGBA used for clear color.7. Sets the clear color used to clear buffers with glClear function.0.graphics.fbo: ClearColor(0.7 GL instructions New in version 1. a Alpha component. between 0-1 rgb RGB color. clear_color If true. 0) ClearBuffers() class kivy.size) with self. Clear the buffers specified by the instructions buffer mask property.2.release() Release the Framebuffer (unbind). list of 3 values in 0-1 range. alpha will be 1.0. remove_reload_observer() Remove a callback from the observer list.ClearBuffers Bases: kivy. size Size of the framebuffer. By default.0. height) format. previously added by add_reload_observer().instructions. ) to vbo & texture‘ draw texture‘ draw texture‘ draw Only the first Color and BindTexture are useful. 10). we are compiling the group.png’. 1) Rectangle(source=’button. 20). y1. y1. Note to any Kivy contributor / internal developer: • All context instructions are checked if they are changing anything on the cache • We must ensure that a context instruction are needed into our current Canvas. y1.1 Reducing the context instructions Imagine that you have a scheme like this: Color(1. 1. 1 BindTexture: change ’texture0’ to ‘button. 20)) Color(1. 12. 201 .8. 20)) The real instruction seen by the graphics canvas would be: Color: change ’color’ context to 1. 1. pos=(10.clear_depth If true. 1) Rectangle(source=’button.. • We must ensure that we don’t depend of any other canvas • We must reset our cache if one of our children is another instruction group. pos=(10.) to vbo & Rectangle: push vertices (x1. 1.. 1) Rectangle(source=’button. and maybe a previous unused Color will be used at the next compilation.) to vbo & Rectangle: push vertices (x1. y1.) to vbo & texture‘ draw draw draw This is what the compiler does in the first place. because we don’t know if they are doing weird things or not. the whole InstructionGroup will be recompiled.. y1.png’. y1. the stencil buffer will be cleared 12.) to vbo & Color: change ’color’ context to 1..png Rectangle: push vertices (x1. by flagging all the unused instruction with GI_IGNORE flag.8 Graphics compiler Before rendering an InstructionGroup. 1. We can reduce them to: Color: change ’color’ context to 1. 20)) Color(1.png Rectangle: push vertices (x1.) to vbo & Color: change ’color’ context to 1. size=(20. and really change the context. 1 BindTexture: change ’texture0’ to ‘button.png Rectangle: push vertices (x1. 1...... in order to reduce the number of instructions executed at rendering time. 0). 1. size=(20. pos=(0.png’.. size=(20.png Rectangle: push vertices (x1. 1 BindTexture: change ’texture0’ to ‘button. As soon as a Color content change.. 1 BindTexture: change ’texture0’ to ‘button. 1. the depth buffer will be cleared clear_stencil If true.. graphics. By using theses OpenGL commands.graphics.opengl.opengl.glBindBuffer() See: glBindBuffer() on Kronos website kivy.glClearColor() See: glClearColor() on Kronos website kivy.glClear() See: glClear() on Kronos website kivy.graphics. kivy.opengl.opengl.graphics.glBufferSubData() See: glBufferSubData() on Kronos website kivy.opengl.opengl.opengl. you might change the OpenGL context and introduce inconsistency between Kivy state and OpenGL state. not the OpenGL one.graphics.opengl.glBindAttribLocation() See: glBindAttribLocation() on Kronos website kivy.graphics.graphics. because we are using the C binding for higher performance.12.glCheckFramebufferStatus() See: glCheckFramebufferStatus() on Kronos website kivy.opengl.graphics.opengl.opengl.graphics.glBindFramebuffer() See: glBindFramebuffer() on Kronos website kivy.opengl.opengl.graphics.opengl.graphics.graphics. Warning: Not every OpenGL command have been wrapped.glBindRenderbuffer() See: glBindRenderbuffer() on Kronos website kivy.opengl.graphics.graphics.glBlendFuncSeparate() See: glBlendFuncSeparate() on Kronos website kivy.glAttachShader() See: glAttachShader() on Kronos website kivy.glBlendColor() See: glBlendColor() on Kronos website kivy.glBufferData() See: glBufferData() on Kronos website kivy.opengl.opengl.opengl.graphics.glBlendEquationSeparate() See: glBlendEquationSeparate() on Kronos website kivy.9 OpenGL This module is python wrapper for OpenGL commands.graphics.glActiveTexture() See: glActiveTexture() on Kronos website kivy.graphics. and you should stick on the Kivy Graphics API.glBlendFunc() See: glBlendFunc() on Kronos website kivy.glClearStencil() See: glClearStencil() on Kronos website 202 .glBindTexture() See: glBindTexture() on Kronos website kivy.glBlendEquation() See: glBlendEquation() on Kronos website kivy.graphics. glCreateShader() See: glCreateShader() on Kronos website kivy.graphics.opengl.opengl.graphics.opengl.graphics.glDeleteRenderbuffers() See: glDeleteRenderbuffers() on Kronos website kivy.graphics.opengl.glDrawArrays() See: glDrawArrays() on Kronos website kivy.opengl.graphics.opengl.opengl.glCompileShader() See: glCompileShader() on Kronos website kivy.glDeleteBuffers() See: glDeleteBuffers() on Kronos website kivy.opengl.glCopyTexImage2D() See: glCopyTexImage2D() on Kronos website kivy.graphics.opengl.glColorMask() See: glColorMask() on Kronos website kivy.opengl.glDepthFunc() See: glDepthFunc() on Kronos website kivy.graphics.glCompressedTexSubImage2D() See: glCompressedTexSubImage2D() on Kronos website kivy.opengl.opengl.graphics.glCreateProgram() See: glCreateProgram() on Kronos website kivy.graphics.graphics.glDeleteShader() See: glDeleteShader() on Kronos website kivy.glDeleteProgram() See: glDeleteProgram() on Kronos website kivy.glDepthMask() See: glDepthMask() on Kronos website kivy.graphics.glCopyTexSubImage2D() See: glCopyTexSubImage2D() on Kronos website kivy.graphics.graphics.glCompressedTexImage2D() See: glCompressedTexImage2D() on Kronos website kivy.opengl.kivy.glDetachShader() See: glDetachShader() on Kronos website kivy.glDisableVertexAttribArray() See: glDisableVertexAttribArray() on Kronos website kivy.opengl.glDeleteTextures() See: glDeleteTextures() on Kronos website kivy.opengl.graphics.opengl.graphics.opengl.glDrawElements() See: glDrawElements() on Kronos website 203 .graphics.graphics.graphics.opengl.glCullFace() See: glCullFace() on Kronos website kivy.graphics.opengl.graphics.glDisable() See: glDisable() on Kronos website kivy.graphics.glDeleteFramebuffers() See: glDeleteFramebuffers() on Kronos website kivy.opengl.graphics.opengl.opengl. 204 .glGenRenderbuffers() See: glGenRenderbuffers() on Kronos website Unlike the C specification.opengl.glGetAttachedShaders() See: glGetAttachedShaders() on Kronos website Unlike the C specification.opengl.graphics. the value will be the result of call.opengl. the value will be the result of call.opengl.opengl.opengl.glGenerateMipmap() See: glGenerateMipmap() on Kronos website kivy.glGetActiveAttrib() See: glGetActiveAttrib() on Kronos website Unlike the C specification.opengl.graphics.glEnableVertexAttribArray() See: glEnableVertexAttribArray() on Kronos website kivy. kivy.graphics.graphics.graphics. the value will be the result of call.glGenTextures() See: glGenTextures() on Kronos website Unlike the C specification.graphics.graphics.opengl.glFramebufferTexture2D() See: glFramebufferTexture2D() on Kronos website kivy. the value will be the result of call.opengl.glEnable() See: glEnable() on Kronos website kivy. kivy.graphics.glGenFramebuffers() See: glGenFramebuffers() on Kronos website Unlike the C specification.graphics. the value will be the result of call.opengl.glGetBooleanv() See: glGetBooleanv() on Kronos website Unlike the C specification. kivy. kivy.graphics. the value will be the result of call. kivy.opengl.glGetActiveUniform() See: glGetActiveUniform() on Kronos website Unlike the C specification.graphics.glFinish() See: glFinish() on Kronos website kivy.opengl. kivy.graphics. kivy.graphics.graphics.glGenBuffers() See: glGenBuffers() on Kronos website Unlike the C specification.opengl.graphics.opengl.graphics.opengl. kivy.glGetAttribLocation() See: glGetAttribLocation() on Kronos website Unlike the C specification. the value will be the result of call.glFrontFace() See: glFrontFace() on Kronos website kivy.graphics. the value will be the result of call.opengl.kivy. the value will be the result of call.opengl.glFlush() See: glFlush() on Kronos website kivy.glFramebufferRenderbuffer() See: glFramebufferRenderbuffer() on Kronos website kivy. graphics.opengl.graphics.graphics.glGetFramebufferAttachmentParameteriv() See: glGetFramebufferAttachmentParameteriv() on Kronos website Unlike the C specification.glGetShaderPrecisionFormat() See: glGetShaderPrecisionFormat() on Kronos website Warning: Not implemented yet.glGetString() See: glGetString() on Kronos website Unlike the C specification. kivy.opengl. the source code will be returned as a string. the value will be the result of call.opengl.kivy. kivy. kivy. the value(s) will be the result of the call kivy.glGetIntegerv() See: glGetIntegerv() on Kronos website Unlike the C specification.graphics.graphics.graphics. kivy.opengl.opengl.opengl. kivy.graphics.glGetShaderInfoLog() See: glGetShaderInfoLog() on Kronos website Unlike the C specification. the source code will be returned as a string.glGetFloatv() See: glGetFloatv() on Kronos website Unlike the C specification.graphics.glGetProgramInfoLog() See: glGetProgramInfoLog() on Kronos website Unlike the C specification. kivy. kivy. kivy.opengl.glGetTexParameterfv() See: glGetTexParameterfv() on Kronos website 205 .opengl. kivy.graphics.graphics.opengl. the source code will be returned as a string. kivy.glGetError() See: glGetError() on Kronos website Unlike the C specification.opengl. the value will be returned as a string.glGetRenderbufferParameteriv() See: glGetRenderbufferParameteriv() on Kronos website Unlike the C specification. the value will be the result of call. the value will be the result of call. the value will be the result of call.glGetShaderSource() See: glGetShaderSource() on Kronos website Unlike the C specification.opengl.graphics. the value(s) will be the result of the call kivy.opengl. the value will be the result of call.graphics.glGetShaderiv() See: glGetShaderiv() on Kronos website Unlike the C specification.glGetProgramiv() See: glGetProgramiv() on Kronos website Unlike the C specification.opengl.graphics. kivy. the value will be the result of call.glGetBufferParameteriv() See: glGetBufferParameteriv() on Kronos website Unlike the C specification.graphics.opengl. graphics.glIsTexture() See: glIsTexture() on Kronos website kivy.opengl.graphics.graphics.opengl.glGetTexParameteriv() See: glGetTexParameteriv() on Kronos website kivy.glGetVertexAttribiv() See: glGetVertexAttribiv() on Kronos website kivy.opengl.opengl.glIsEnabled() See: glIsEnabled() on Kronos website kivy.graphics.opengl.opengl. and GL_UNSIGNED_BYTE as type.graphics.graphics.glIsBuffer() See: glIsBuffer() on Kronos website kivy.graphics.opengl.graphics.glGetUniformfv() See: glGetUniformfv() on Kronos website kivy.graphics.opengl.graphics.graphics.glReadPixels() See: glReadPixels() on Kronos website We are supporting only GL_RGB/GL_RGBA as format.graphics.graphics.opengl.opengl.opengl.opengl.glHint() See: glHint() on Kronos website kivy.glGetVertexAttribfv() See: glGetVertexAttribfv() on Kronos website kivy.graphics.opengl.glGetUniformLocation() See: glGetUniformLocation() on Kronos website kivy.glIsFramebuffer() See: glIsFramebuffer() on Kronos website kivy.graphics.glPixelStorei() See: glPixelStorei() on Kronos website kivy.glIsShader() See: glIsShader() on Kronos website kivy.glIsProgram() See: glIsProgram() on Kronos website kivy.graphics.kivy. 206 .glPolygonOffset() See: glPolygonOffset() on Kronos website kivy.opengl. kivy.glGetUniformiv() See: glGetUniformiv() on Kronos website kivy.glIsRenderbuffer() See: glIsRenderbuffer() on Kronos website kivy.graphics.glLinkProgram() See: glLinkProgram() on Kronos website kivy.opengl.glGetVertexAttribPointerv() See: glGetVertexAttribPointerv() on Kronos website Warning: Not implemented yet.opengl.graphics.graphics.opengl.graphics.opengl.glLineWidth() See: glLineWidth() on Kronos website kivy.opengl.opengl. glStencilOpSeparate() See: glStencilOpSeparate() on Kronos website kivy.graphics.graphics.glTexParameterfv() See: glTexParameterfv() on Kronos website Warning: Not implemented yet.opengl.glRenderbufferStorage() See: glRenderbufferStorage() on Kronos website kivy.glTexParameterf() See: glTexParameterf() on Kronos website kivy.glStencilFunc() See: glStencilFunc() on Kronos website kivy. kivy.graphics.opengl.glStencilMask() See: glStencilMask() on Kronos website kivy.opengl.graphics.glShaderBinary() See: glShaderBinary() on Kronos website Warning: Not implemented yet.graphics.glStencilOp() See: glStencilOp() on Kronos website kivy.graphics.kivy.opengl.glTexParameteri() See: glTexParameteri() on Kronos website kivy. kivy.glScissor() See: glScissor() on Kronos website kivy. 207 .opengl.opengl. kivy.glStencilMaskSeparate() See: glStencilMaskSeparate() on Kronos website kivy.glTexImage2D() See: glTexImage2D() on Kronos website kivy.opengl.graphics.graphics.glStencilFuncSeparate() See: glStencilFuncSeparate() on Kronos website kivy.glTexParameteriv() See: glTexParameteriv() on Kronos website Warning: Not implemented yet.glSampleCoverage() See: glSampleCoverage() on Kronos website kivy.opengl.graphics.opengl.opengl.graphics.opengl.glReleaseShaderCompiler() See: glReleaseShaderCompiler() on Kronos website Warning: Not implemented yet.graphics.graphics.opengl.opengl.graphics.graphics.graphics.opengl.graphics.opengl.opengl.opengl.graphics.glShaderSource() See: glShaderSource() on Kronos website kivy. opengl.glUniform4f() See: glUniform4f() on Kronos website Warning: Not implemented yet.graphics.graphics.graphics.graphics.glUniform2fv() See: glUniform2fv() on Kronos website Warning: Not implemented yet.opengl.glUniform3i() See: glUniform3i() on Kronos website kivy.kivy.opengl.graphics.graphics.graphics.glUniform3f() See: glUniform3f() on Kronos website kivy. kivy.graphics. kivy.graphics.graphics.glUniform3iv() See: glUniform3iv() on Kronos website Warning: Not implemented yet.graphics.opengl.glUniform2iv() See: glUniform2iv() on Kronos website Warning: Not implemented yet.glUniform1fv() See: glUniform1fv() on Kronos website Warning: Not implemented yet.opengl.opengl.opengl.glUniform2i() See: glUniform2i() on Kronos website kivy.graphics.glUniform1i() See: glUniform1i() on Kronos website kivy. kivy.glUniform2f() See: glUniform2f() on Kronos website kivy.opengl.graphics.opengl.opengl.opengl. kivy. 208 .glUniform1f() See: glUniform1f() on Kronos website kivy. kivy.opengl.glTexSubImage2D() See: glTexSubImage2D() on Kronos website kivy. kivy.glUniform3fv() See: glUniform3fv() on Kronos website Warning: Not implemented yet.graphics.opengl.opengl.glUniform1iv() See: glUniform1iv() on Kronos website Warning: Not implemented yet. opengl.opengl.glVertexAttrib3f() See: glVertexAttrib3f() on Kronos website kivy.graphics.graphics.glUseProgram() See: glUseProgram() on Kronos website kivy.opengl.glUniformMatrix4fv() See: glUniformMatrix4fv() on Kronos website Warning: Not implemented yet.opengl.graphics.glVertexAttrib1fv() See: glVertexAttrib1fv() on Kronos website Warning: Not implemented yet.glVertexAttrib2f() See: glVertexAttrib2f() on Kronos website kivy.glUniform4fv() See: glUniform4fv() on Kronos website Warning: Not implemented yet.glUniform4i() See: glUniform4i() on Kronos website kivy.graphics.graphics.graphics.kivy. kivy.opengl. kivy.glValidateProgram() See: glValidateProgram() on Kronos website kivy.opengl.opengl.graphics.opengl. kivy.glUniformMatrix2fv() See: glUniformMatrix2fv() on Kronos website Warning: Not implemented yet.graphics.graphics.glUniformMatrix3fv() See: glUniformMatrix3fv() on Kronos website Warning: Not implemented yet.opengl.opengl.opengl.glVertexAttrib3fv() See: glVertexAttrib3fv() on Kronos website 209 .glVertexAttrib2fv() See: glVertexAttrib2fv() on Kronos website Warning: Not implemented yet.opengl.graphics.graphics.opengl. kivy.graphics. kivy.graphics.opengl. kivy.graphics. kivy.glUniform4iv() See: glUniform4iv() on Kronos website Warning: Not implemented yet.glVertexAttrib1f() See: glVertexAttrib1f() on Kronos website kivy. glViewport() See: glViewport() on Kronos website 12.graphics. the GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX is a special pname that will return 1 integer (nvidia only).opengl_utils.opengl.gl_has_extension() Check if an OpenGL extension is available. and are in lowercase.glVertexAttribPointer() See: glVertexAttribPointer() on Kronos website Warning: Not implemented yet.gl_has_capability() Return the status of a OpenGL Capability. ’arb_compatibility’.. and converted to lowercase.graphics. If the name start with GL_.glVertexAttrib4f() See: glVertexAttrib4f() on Kronos website kivy.0..glVertexAttrib4fv() See: glVertexAttrib4fv() on Kronos website Warning: Not implemented yet.opengl.graphics. kivy. All the names in the list have the GL_ stripped at the start if exist. ’arb_color_buffer_float’.gl_get_extensions() Return a list of OpenGL extensions available. DXT5) •GLCAP_DXT1: Test the support of DXT texture (subset of S3TC) kivy. kivy.graphics.gl_register_get_size() Register an association between a OpenGL Const used in glGet* to a number of elements.7. >>> gl_has_extension(’NV_get_tex_image’) False >>> gl_has_extension(’OES_texture_npot’) True kivy.opengl. 210 .Warning: Not implemented yet.opengl_utils. By example.graphics. it will be stripped for the test.graphics. ] kivy.opengl. This is a wrapper that auto discover all the capabilities that Kivy might need. ’arb_copy_buffer’. The current capabilites test are: •GLCAP_BGRA: Test the support of BGRA texture format •GLCAP_NPOT: Test the support of Non Power of Two texture •GLCAP_S3TC: Test the support of S3TC texture (DXT1. kivy. kivy.graphics. DXT3. >>> print gl_get_extensions() [’arb_blend_func_extended’.graphics.10 OpenGL utilities New in version 1.opengl_utils.opengl_utils. gl_get_texture_formats() Return a list of texture format recognized by kivy. When you are creating a Shader.opengl_utils. you can add the “$HEADER$” token. Here is the header for Fragment Shader: 211 .gl_has_texture_format() Return if a texture format is supported by your system.gl_has_texture_native_format() Return 1 if the texture format is handled natively. we are able to convert to ‘rgba’.opengl_utils.opengl_utils. >>> gl_has_texture_format(’azdmok’) 0 >>> gl_has_texture_format(’rgba’) 1 >>> gl_has_texture_format(’s3tc_dxt1’) [INFO ] [GL ] S3TC texture support is available [INFO ] [GL ] DXT1 texture support is available 1 kivy. kivy. 12. and the creation of the program in OpenGL. The texture list is informative. Kivy will always include default parameters. but in software mode. parsed from the GL_VERSION. 1) >>> glGetIntegerv(GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX)[0] 524288 kivy.1 Header inclusion New in version 1. New in version 1.2.graphics. 12. If you want a list of supported textures. New in version 1.gl_get_version_minor() Return the minor component of the OpenGL version.0.2.graphics. If you don’t want to rewrite it each time you want to customize / write a new shader.2. For example. but might not been supported by your hardware.gl_get_version_major() Return the major component of the OpenGL version. kivy.7.graphics. minor) OpenGL version.opengl_utils. New in version 1. if your card doesn’t support ‘bgra’.0. natively or by conversion. kivy.0.opengl_utils.gl_has_texture_conversion() Return 1 if the texture can be converted to a native format kivy.graphics. and it will be replaced by the corresponding shader header.>>> GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX = 0x9047 >>> gl_register_get_size(GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX.11.gl_get_version() Return the (major.graphics.graphics.graphics.11 Shader The Shader class handle the compilation of the Vertex and Fragment shader.0.opengl_utils. Todo Write a more complete documentation about shader. you must filter that list like that: supported_fmts = [gl_has_texture_format(x) for x in gl_get_texture_formats()] kivy.opengl_utils. If you set a new fragment shader source code. #endif /* Outputs from the vertex shader */ varying vec4 frag_color. /* uniform variables */ uniform mat4 modelview_mat. it will be automatically compiled and replace the current one. class kivy. default to None source code for fragment shader fs Fragment shader source code. uniform float opacity.graphics. You must know have a StencilUnUse and repeat the same operation as 212 . uniform vec4 color.3. #endif /* Outputs to the fragment shader */ varying vec4 frag_color.#ifdef GL_ES precision highp float. /* vertex attributes */ attribute vec2 vPosition. And the header for Vertex Shader: #ifdef GL_ES precision highp float.4. uniform mat4 projection_mat. /* uniform texture samplers */ uniform sampler2D texture0.0: The stencil operation have been updated to resolve some issues appearing when nested. varying vec2 tex_coord0. attribute vec2 vTexCoords0.Changed in version 1. 12. default to None source code for vertex shader fs: string.0. it will be automatically compiled and replace the current one. varying vec2 tex_coord0. success Indicate if shader is ok for usage or not.Shader Bases: object Create a vertex or fragment shader Parameters vs: string. If you set a new vertex shader source code.12 Stencil instructions New in version 1.shader. vs Vertex shader source code. 100. from pos 100. Even if you don’t have as much control as OpenGL. the previous stencil # mask will crop us :) Color: rgb: 0. Here is a global scheme to respect: . you can still do fancy things :=) The stencil buffer can be controled with theses 3 instructions : • StencilPush: push a new stencil layer any drawing that happening here will be used as a mask • StencilUse : now draw the next instructions and use the stencil for masking them • StencilUnUse : stop drawing. (8 for kivy < 1. 100 size. 100 StencilUse # we want to show a big green rectangle. 1. however.1 Limitations • Drawing in PHASE 1 and PHASE 3 must not collide between each others. 900 213 .3. • The stencil is activated as soon as you’re doing a StencilPush • The stencil is deactivated as soon as you’ve correctly pop all the stencils layers • You must not play with stencil yourself between a StencilPush / StencilPop • You can push again the stencil after a StencilUse / before the StencilPop • You can push up to 128 layers of stencils. 100 size: 100. with a 100. and use the stencil to remove the mask • StencilPop : pop the current stencil layer. 0 Rectangle: size: 900. in kv style: StencilPush # create a rectangle mask. or you will get unexpected result.you did after StencilPush. Rectangle: pos: 100.12. Stencil instructions permit you to draw and use the current drawing as a mask.2 Example of stencil usage Here is an example.12. code-block:: kv StencilPush # PHASE 1: put here any drawing instruction to use as a mask StencilUse # PHASE 2: all the drawing here will be automatically clipped by the previous mask StencilUnUse # PHASE 3: put here the same drawing instruction as you did in PHASE 1 StencilPop 12..0) 12. Depending of the hardware. The default value and the most commonly used is ‘ubyte’.) You cannot instanciate the class yourself.graphics. ‘uint’.StencilUnUse: # new in kivy 1.0. You must use the function Texture.3.instructions.Instruction Use current stencil buffer to unset the mask. ‘byte’.graphics. Check module documentation for more information.texture parameter. See module documentation for more information.Instruction Push the stencil stack. ‘luminance_alpha’.instructions.create() to create a new texture: texture = Texture.colorfmt). if you want to create an RGBA texture: texture = Texture. that can be one of ‘rgb’. class kivy.graphics. NPOT support.stencil_instructions.Instruction Use current stencil buffer as a mask. So. ‘luminance’. ‘bgr’.stencil_instructions. ‘rgba’. remove the mask previoulsy added Rectangle: pos: 100.1 Blitting custom data You can create your own data and blit it on the texture using Texture. 480)) When you are creating a texture. The default value is ‘rgb’ • the buffer format is how a color component is stored into memory.graphics. ‘bgra’. ‘ushort’.instructions.13 Texture Texture is a class to handle OpenGL texture.stencil_instructions. This can be one of ‘ubyte’. 100 StencilPop class kivy. 12. 480). class kivy. If you want to use your texture in kv lang.StencilPop Bases: kivy. ‘short’. 12.graphics.13.graphics.StencilUse Bases: kivy. See module documentation for more information.blit_data(): 214 . colorfmt=’rgba’) You can use your texture in almost all vertex instructions with the kivy.create(size=(640. etc.StencilUnUse Bases: kivy. you must be aware of the default color format and buffer format: • the color/pixel format (Texture.create(size=(640. ‘int’.VertexIntruction.graphics.Instruction Pop the stencil stack.StencilPush Bases: kivy.graphics. you can save it in an ObjectProperty inside your widget.stencil_instructions. class kivy.graphics. some OpenGL capabilities might not be available (BGRA support. ‘float’. 100 size: 100.instructions. 0.get_region(0.texture bottomleft = texture.# create a 64x64 texture. we are checking if your hardware support BGR / BGRA texture by checking the extension ‘GL_EXT_bgra’. we are creating the nearest POT texture that can contain your NPOT texture.2 BGR/BGRA support The first time you’ll try to create a BGR or BGRA texture. size=(64. convert the array to a ubyte string buf = ’’. The Texture. default to rgb / ubyte texture = Texture. Another type of NPOT texture are also called rectangle texture.7.. NPOT and texture have their own pro/cons.join(map(chr. If none of theses are availables. That’s mean your width and height can be one of 64. you can do that with self. 256.3 NPOT texture New in version 1..canvas: Rectangle(texture=texture. but not 3. NPOT mean non-power-oftwo.png’). 64. As OpenGL documentation said. 68. a conversion to RGB / RGBA will be done in software.0.image import Image texture = Image(’mycombinedimage. Features OpenGL Target Texture coords Mipmapping Wrap mode POT GL_TEXTURE_2D 0-1 range Supported Supported NPOT GL_TEXTURE_2D 0-1 range Partially Supported Rectangle GL_TEXTURE_RECTANGLE_(NV|ARB|EXT) width-height range No No If you are creating a NPOT texture. a texture must be power-of-two sized. but with some drawbacks. load a 128x128 image that contain 4 64x64 images from kivy. 12. That will return you the original texture with custom texture coordinates: # for example. 64) 215 . You can get a region of the original texture. buf)) # then blit the buffer texture. 64)) # create 64x64 # we’ll have a size = 64 * 64 buf = [int(x * rgb tab. colorfmt=’rgb’.pos. POT. bufferfmt=’ubyte’) # that’s all ! you can use it in your graphics now :) # if self is a widget. 64.create(size=(64.13.get_region(0. 64) bottomright = texture. If the extension is not found. 64)) 12.blit_buffer(buf.create() will return a TextureRegion instead. and fill with value from 0 to 255 gradient from black to white * 3 255 / size) for x in xrange(size)] # then. you don’t need to.13. 32. 64.4 Texture atlas We are calling texture atlas a texture that contain many images in it. pos=self. If you want to seperate the original texture into many single one. 42. we first are checking if your hardware is capable of it by checking the extensions GL_ARB_texture_non_power_of_two or OES_texture_npot.13.core. OpenGL ES 2 support NPOT texture natively. 12. 512).texture. as linear filter.add_reload_observer(self. This class can be used to create simple texture or complex texture based on ImageData. 2x1. 64) topright = texture.2.6 Reloading the Texture New in version 1.0. Use the Texture. 64.get_region(0. it will use a lower filtered texture. Check http://www. New in version 1. 12.0. 64) 12. and 1x1”. 16x4.13. This is where you can reupload your custom data in GPU.__init__(**kwargs) self. 8x2. From the OpenGL Wiki : “So a 64x16 2D texture can have 5 mip-maps: 32x8.Texture Bases: object Handle a OpenGL texture. add_reload_observer() Add a callback to be called after the whole graphics context have been reloaded.org/wiki/Texture for more information. the Texture must be reloaded. Note: As the table in previous section said..opengl. Parameters callback: func(context) -> return None The first parameter will be the context itself bind() Bind the texture to current opengl state blit_buffer() Blit a buffer into a texture.get_region(64.5 Mipmapping New in version 1.topleft = texture. Texture having a source are automatically reloaded without any help. instead of using the biggest texture. when you rendering a small surface.graphics. 64. you need to specify mipmap=True when you’re creating a texture.2.texture.0.7: added mipmap_level + mipmap_generation 216 .13.add_reload_observer() to add a reloading function that will be automatically called when needed: def __init__(self. self. 4x1. 64. New in version 1.cbuffer = ’ class kivy. bufferfmt=’ubyte’) self. if your texture is NPOT.7. The result can look better with that way. If the OpenGL context is lost.).texture = Texture. The idea is to precalculate subtexture and apply some image filter. Without mipmapping. we are actually creating the nearest POT texture and generate mipmap on it. Mipmapping is an OpenGL technique for enhancing the rendering of large texture to small surface.. 64. you might seen pixels when you are rendering to small surface. But generated textures must be reloaded by the user.create(size=(512. Some widget already give you the possibility to create mipmapped texture like Label or Image. Then. This might change in the future.populate_texture) # and load the data now.0. To make that happen. **kwargs): super(. colorfmt=’RGB’. Parameters size: tuple. ‘uint’. ‘luminance_alpha’ pos [tuple. 128) Size of the texture colorfmt: str. ‘luminance’. ‘float’ mipmap: bool.height) dimensions height Return the height of the texture (readonly) id Return the OpenGL ID of the texture (readonly) mag_filter Get/set the mag filter texture. default to False Indicate if we need to regenerate mipmap from level 0 blit_data() Replace a whole texture with a image data bufferfmt Return the buffer format used in this texture. default to ‘rgb’] Image format. ‘luminance’. ‘bgr’. can be one of ‘rgb’. ‘luminance_alpha’ bufferfmt: str.y) with (width. ‘short’. ‘ushort’. default to (128. can be one of ‘ubyte’.0. default to texture size] Size of the image (width. create() Create a texture based on size. default to ‘ubyte’ Internal buffer format of the texture.7. Can be ‘ubyte’. default to ‘ubyte’] Type of the data buffer. default to False If True. from (x. it will automatically generate mipmap texture. ‘short’.0. Can be ‘rgba’ or ‘rgb’.Parameters pbuffer [str] Image data size [tuple. ‘bute’. ‘int’. ‘rgba’.2. ‘ushort’. default to (0. ‘byte’. (readonly) New in version 1. ‘uint’. default to 0 Indicate which mipmap level we are going to update mipmap_generation: bool. ‘bgra’. ‘int’. create_from_data() Create a texture from an ImageData class flip_vertical() Flip tex_coords for vertical displaying get_region() Return a part of the texture. 0)] Position to blit in the texture bufferfmt [str. Available values: •linear •nearest 217 . default to ‘rgba’ Internal color format of the texture. (readonly) New in version 1. ‘float’ mipmap_level: int. colorfmt Return the color format used in this texture. height) colorfmt [str. khronos.khronos. Available values: •linear •nearest •linear_mipmap_linear •linear_mipmap_nearest •nearest_mipmap_nearest •nearest_mipmap_linear Check opengl documentation for more information about the behavior of theses values : http://www. Available values: •repeat •mirrored_repeat •clamp_to_edge Check opengl documentation for more information about the behavior of theses values : http://www.xml. min_filter Get/set the min filter texture. class kivy. Warning: The size can be negative is the texture is flipped.xml.2.khronos.TextureRegion Bases: kivy. Useful for non power-of-2 texture handling.org/opengles/sdk/docs/man/xhtml/glTexParameter. size Return the (width.org/opengles/sdk/docs/man/xhtml/glTexParameter.texture.0.org/opengles/sdk/docs/man/xhtml/glTexParameter. New in version 1. 218 .xml.texture. previously added by add_reload_observer(). mipmap Return True if the texture have mipmap enabled (readonly) remove_reload_observer() Remove a callback from the observer list. height) of the texture (readonly) target Return the OpenGL target of the texture (readonly) tex_coords Return the list of tex_coords (opengl) uvpos Get/set the UV position inside texture uvsize Get/set the UV size inside texture.graphics.graphics.Check opengl documentation for more information about the behavior of theses values : http://www.Texture Handle a region of a Texture class. width Return the width of the texture (readonly) wrap Get/set the wrap texture. multiply(n) -> n * m rotate() Rotate the matrix with the angle.000000 1.000000 1. translation. translate() Translate the matrix view_clip() Create a clip matrix (inplace) 12.transformation.12.000000 ] [ 0.VertexInstruction A 2d triangle. y.000000 0.Triangle Bases: kivy.000000 ] [ 0.Matrix Bases: object Optimized matrix class for OpenGL: >>> from kivy. class kivy. We are supporting: • rotation.14 Transformation This module contain a Matrix class.000000 0.000000 0.graphics.000000 0.000000 0.000000 0. used for our Graphics calculation.000000 ] [ 0. around the axis (x. I. we premultiply the given matrix to the current matrix and return the result (not inplace): m.graphics..000000 0.000000 1.15 Vertex Instructions This module include all the classes for drawing simple vertex object.vertex_instructions.graphics.000000 0.000000 ]] [ [ [ [ 0 4 8 12 1 2 3] 5 6 7] 9 10 11] 13 14 15] identity() Reset matrix to identity matrix (inplace) inverse() Return the inverted matrix multiply() Multiply the given matrix with self (from the left).graphics. z) scale() Scale the matrix current Matrix (inplace).transformation import Matrix >>> m = Matrix() >>> print m [[ 1. 219 .instructions. scaling matrix • multiply matrix • create clip matrix (with or without perspective) • transform 3d touch on a matrix class kivy.e.000000 0. y2. in the format (width. of the disk portion angle_end: int default to 360 Specifies the ending angle. in degrees. y3) points Property for getting/settings points of the triangle class kivy.Rectangle Bases: kivy.graphics. y2. x4.vertex_instructions.Rectangle A 2D ellipse. default to 180 Define how much segment is needed for drawing the ellipse.instructions. New in version 1.vertex_instructions. The drawing will be smoother if you have lot of segment. x2.vertex_instructions.graphics. Parameters pos: list Position of the rectangle.graphics. of the disk portion angle_end Angle end of the ellipse in degrees.BorderImage Bases: kivy. Parameters border: list Border information in the format (top. border Property for getting/setting the border of the class class kivy. height) pos Property for getting/settings the position of the rectangle size Property for getting/settings the size of the rectangle class kivy. y3. right.graphics. in the format (x. in degrees. Parameters points: list List of point in the format (x1.VertexInstruction A 2d rectangle.graphics.graphics.7: added angle_start + angle_end Parameters segments: int.vertex_instructions. y) size: list Size of the rectangle.vertex_instructions. Each value is in pixels.0. y1.Ellipse Bases: kivy. y1. x3.Quad Bases: kivy.graphics. The behavior of the border image is similar to the concept of CSS3 borderimage.instructions. x3.Parameters points: list List of point in the format (x1. default to 360 220 .Rectangle A 2d border image. left). angle_start: int default to 0 Specifies the starting angle. bottom. y4) points Property for getting/settings points of the quads class kivy.VertexInstruction A 2d quad.vertex_instructions.graphics. x2. width=10) Actually. while properties for cap and joint have no sense for this.instructions.vertex_instructions.0. 200]. dash_length and dash_offset is not working on that mode.canvas: Line(points=[100. 221 .If the width is 1.If the width is > 1. then we will use standard GL_LINE drawing from OpenGL.0. the line have 3 internal drawing mode that you should know about if you want to get the best performance of it: 1. Drawing a line can be done easily: with self. dash_length and dash_offset works.graphics. stencil will be used internally to draw the line.0. 100. 2. 200. then we will use a custom drawing method.angle_start Angle start of the ellipse in degrees. 100.VertexInstruction A 2d line. Additionally.graphics.Line Bases: kivy. 100. if the current color have an alpha < 1. based on triangles. default to 0 segments Property for getting/setting the number of segments of the ellipse class kivy. y1. height) angle_end. Check rectangle for more information. segments): •x and y represent the bottom-left position of the rectangle •width and height represent the size The line is automatically closed. The 222 .) dash_length: int Length of a segment (if dashed). joint_precision. ellipse: list If set.1. cap_precision: int.. cap_precision Number of iteration for drawing the “round” cap. cap Determine the cap of the line. bezier_precision: int. the points will be set to build an ellipse. Check circle for more information. the points will be set to build a circle. default to 180 Precision of the Bezier drawing. ‘square’ or ‘round’ New in version 1. default to ‘round’. close. the line will be closed. default to 10. default 0. joint. Check ellipse for more information. bezier_precision have been added.1. the points will be set to build a rectangle.0 cap: str. Check bezier for more information. circle: list If set. bezier: list If set.2. cap. ellipse. width. default to False If True.4. 200. joint: str.Parameters points: list List of points in the format (x1. Can be one of ‘none’.1: bezier.New in version 1. the points will be set to build a bezier line. x2. default to 10 See cap_precision for more information joint_precision: int. default to 10 See joint_precision for more information close: bool. y. You can only set this property. New in version 1. 200)) New in version 1.4.4.4. default to 180. without calculate the points. bezier Use this property to build a rectangle.2.4. default to ‘round’ See cap for more information. rectangle have been added. New in version 1. Usage: Line(rectangle=(0. rectangle: list If set..0. The cap_precision must be at least 1.1: width. default 1 dash_offset: int Offset between the end of a segments and the begining of the next one. bezier_precision must be at least 1.4. 0. changing this makes it dashed. default 1.8: dash_offset and dash_length have been addedNew in version 1. bezier_precision Number of iteration for drawing the bezier between 2 segments. New in version 1. cap_precision. y2. The argument must be a tuple of (x. width: float Width of the line. not get it. default to ‘round’ See joint for more information. ellipse Use this property to build an ellipse. 20)) is calculated 223 . close If True. with few segments Line(circle=(150. dash_offset Property for getting/setting the offset between the dashes in the curve New in version 1. angle_end. You can only set this property. 0. 150. 180. 150. height.1. The default value is 0 and 360. angle_end. with few segments Line(ellipse=(0. Note that it’s up to you to close the ellipse or not. Note that it’s up to you to close the circle or not. 0. 150. the line will be closed. dash_length Property for getting/setting the length of the dashes in the curve New in version 1. without calculate the points. angle_start. For example. 90. The argument must be a tuple of (center_x. not get it.4. 90. •(optional) segments is the precision of the ellipse. 150. 50. for building a simple ellipse. For example.4. The default value from the range between angle. segments): •center_x and center_y represent the center of the circle •radius represent the radius of the circle •(optional) angle_start and angle_end are in degree. angle_start. •(optional) segments is the precision of the ellipse. 150)) # only from 90 to 180 degrees Line(ellipse=(0.circle Use this property to build a circle. for building a simple ellipse. 180)) # only from 90 to 180 degrees. center_y. in python: # simple circle Line(circle=(150. 150.1. New in version 1.0.8. 180. 150. 50. radius. The argument must be a tuple of (x. in python: # simple ellipse Line(ellipse=(0. 150. not get it. The default value from the range between angle. 0. width. without calculate the points.0. 90. 180)) # only from 90 to 180 degrees. You can only set this property. 50)) # only from 90 to 180 degrees Line(circle=(150. segments): •x and y represent the bottom left of the ellipse •width and height represent the size of the ellipse •(optional) angle_start and angle_end are in degree.8. The default value is 0 and 360. 150. 90. 20)) is calculated New in version 1. y. class kivy. segments): •x and y represent the bottom-left position of the rectangle •width and height represent the size The line is automatically closed.7. If you use add_point.1.graphics. x2.Point Bases: kivy.1.New in version 1. default to 1. It can be very CPU expensive.4. 2 entry in the list (x + y) will be converted to 4 vertices. y1.4. without calculate the points.VertexInstruction A 2d line. height) angle_end. New in version 1. 200)) New in version 1. add_point() Add a point into the current points list. The joint_precision must be at least 1. width Determine the width of the line. New in version 1. So the limit inside Point() class is 2^15-2. ‘round’. mean the real size will be 2) Warning: Starting from version 1. points Property for getting/settings points of the triangle pointsize Property for getting/setting point size 224 . Size of the point (1. Parameters points: list List of points in the format (x1. You can only set this property. vertex instruction have a limit of 65535 vertices (indices of vertex to be accurate). y. joint_precision Number of iteration for drawing the “round” joint. width. ‘miter’. The argument must be a tuple of (x.1. points Property for getting/settings points of the line Warning: This will always reconstruct the whole graphics from the new points list. rectangle Use this property to build a rectangle. If you intend to add multiple point.graphics.vertex_instructions. default to 1..1.0. instead of reassign a new points list. not get it. y2. ‘bevel’. New in version 1.1.4. Can be one of ‘none’. default to 10..) pointsize: float. joint Determine the join of the line. 0. default to ‘round’. 200.instructions. Assigning a new points list will recalculate and reupload the whole buffer into GPU. prefer to use this method. Usage: Line(rectangle=(0. it will only upload the changes.4.0.4. mean it’s only x/y + one texture coordinate. v.0 and in our graphics implementation. default to False Set the bezier curve to join last point to first..) mode: str Mode of the vbo. The drawing will be smoother if you have lot of segment. you cannot have more than 65535 indices. the Mesh instruction doesn’t allow you to change the format of the vertices.) segments: int. then you can make an indices list as: indices = [0. ‘line_strip’.0. v1. y1. y2. u1.) indices: list List of indices in the format (i1. v2. y2. y2.class kivy. y1. Check mode for more information. ‘lines’. y1.vertex_instructions. i3. this might change in a future release. A list of vertices is described as: vertices = [x1.. Right now. x2.0.vertex_instructions. v2.VertexInstruction A 2d mesh. New in version 1. default 1 dash_offset: int distance between the end of a segment and the start of the next one. v). ‘triangle_fan’ Can be one of: ‘points’.Exception Exception fired when a graphic error is fired. .] | | | | +---.Bezier Bases: kivy.graphics. u.instructions. dash_length Property for getting/stting the length of the dashes in the curve 225 . x2. In OpenGL ES 2.. default 0.i2 ----+ If you want to draw a triangles.vertex_instructions. class kivy. mode VBO Mode used for drawing vertices/indices. ‘triangle_strip’... x2.8.graphics.Mesh Bases: kivy. i2. u2.instructions. put 3 vertices.graphics. changing this makes it dashed.VertexInstruction A 2d Bezier curve. The format of vertices are actually fixed. y) and a 2D texture coordinate (u.graphics.graphics. ‘line_loop’. class kivy. Default to ‘points’. default to 180 Define how much segment is needed for drawing the ellipse. . used to construct the Mesh. u2. vertices List of x.. each vertex is described with 2D coordinates (x. loop: bool. 2] New in version 1.GraphicException Bases: exceptions.1. v1. 1. indices Vertex indices used to know which order you wanna do for drawing the mesh.. Right now. Parameters points: list List of points in the format (x1. u1... Parameters vertices: list List of vertices in the format (x1.i1 ----+ +---. y. dash_length: int length of a segment (if dashed).. dash_offset Property for getting/setting the offset between the dashes in the curve points Property for getting/settings points of the triangle Warning: This will always reconstruct the whole graphics from the new points list. segments Property for getting/setting the number of segments of the curve 226 . It can be very CPU expensive. args) Bases: object Abstract class to represent a touch and no-touch object. When the event have been read from devices. oy. dz copy_to(to) Copy some attribute to another touch object. y. pz. dx. px. dy. depack(args) Depack args into attributes in class distance(other_touch) Return the distance between the current touch and another touch. We are currently able to support natively : • Windows multitouch event (pencil and finger) • MacOSX touchpad • Linux multitouch event (kernel and mtdev) • Linux wacom driver (pencil and finger) • TUIO All the input management is configurable in the Kivy configuration. passed to depack() function apply_transform_2d(transform) Apply a transformation on x. oz.CHAPTER THIRTEEN INPUT MANAGEMENT Our input system is wide and simple at the same time. self. before sending them to your application. z. Parameters id [str] uniq ID of the Motion Event args [list] list of parameters. id. they are dispatched through post processing module.dx.dy) 227 . dpos Return delta between last position and current position. We got also several module by default for : • Double tap detection • Decrease jittering • Decrease the loose of touch on “bad” DIY hardware • Ignore regions class kivy.MotionEvent(device. You can easily use many multitouch device into one Kivy application. py.input. ox. in the screen coordinate system (self. and if the configuration use the current provider.MotionEventFactory MotionEvent factory is a class who register all availables input factories. This method is automatically called when the application is started. stop() Stop the provider update(dispatch_fn) Update the provider.grab(class_instance.MotionEventProvider(device.oy) pop() Pop attributes values from the stack ppos Return the previous position of the touch in the screen coordinate system (self. self. touch): if touch. touch): touch.grab(self) def on_touch_move(self. don’t forget to register it: 228 . args) Bases: object Base class for a provider.grab_current is self: # i receive my grabbed touch. h. exclusive=False) Grab this motion event.input. i must ungrab it ! touch. start() Start the provider. If you create a new input factory.ungrab(self) else: # it’s a normal touch pass move(args) Move the touch to another position opos Return the initial position of the touch in the screen coordinate system (self.input. rotation=0) Scale position for the screen spos Return the position in the 0-1 coordinate system (self. self. self. class kivy. even if the touch is not dispatched by your parent: def on_touch_down(self.sy) ungrab(class_instance) Ungrab a previous grabbed touch class kivy.ox.py) push(attrs=None) Push attributes values in attrs in the stack scale_for_screen(w. You can grab a touch if you absolutly want to receive on_touch_move() and on_touch_up(). touch): if touch. and dispatch all the new touch event though the dispatch_fn argument.px.sx.grab_current is self: # i receive my grabbed touch else: # it’s a normal touch def on_touch_up(self. p=None. 1. class kivy. and time is in millisecond.004 jitter_ignore_devices = mouse. A problem that is often faced (esp. find_double_tap(ref ) Find a double tap touch within self.1 Input Postprocessing 13. 13. With this module you can get rid of that jitter.1. MyInputProvider) static get(name) Get a provider class from provider id static list() Get a list of all providers availables static register(name. and all touch movements that move the touch by less than the jitter distance are considered ‘bad’ movements caused by jitter and will be discarded. in optical MT setups) is that of jitterish BLOBs caused by bad camera characteristics.register(’myproviderid’.MotionEventFactory.InputPostprocDejitter Bases: object Get rid of jitterish BLOBs.2 Double Tap Search touch for a double tap class kivy.doubletap. The touch must be not a previous double tap. You just define a threshold jitter_distance in your config.mactouch Configuration jitter_distance: float A float in range 0-1.postproc. jitter_ignore_devices: string A comma-seperated list of device identifiers that should not be processed by dejitter (because they’re very precise already). Double tap can be configured in the Kivy config file: [postproc] double_tap_time = 250 double_tap_distance = 20 Distance parameter is in 0-1000. Example: [postproc] jitter_distance = 0. and the distance must be ok 229 .InputPostprocDoubleTap Bases: object InputPostProcDoubleTap is a post-processor to check if a touch is a double tap or not. classname) Register a input provider in the database 13.input.postproc.touches.input.dejitter.1 Dejitter Prevent blob jittering. input.1 NO DOCUMENTATION (module kivy. xmax. ymin. check mtdev.input.match=acer # using hidinput with custom parameters to hidinput (all on one line) %(name)s = probesysfs.2 Auto Create Input Provider Config Entry for Available MT Hardware (linux only)..15.13.InputPostprocRetainTouch Bases: object InputPostprocRetainTouch is a post-processor to delay the ‘up’ event of a touch.ignorelist. Ignore list can be configured in the Kivy config file: [postproc] # Format: [(xmin.provider=hidinput # using mtdev with a match on name device_%(name)s = probesysfs.] ignore = [(0.uix) 13. Retain touch can be configured in the Kivy config file: [postproc] retain_time = 100 retain_distance = 50 Distance parameter is in 0-1000.2 Providers 13. 13.2. Thanks to Marc Tardif for the probing code.2. 0.15)] Ignore list coordinate are in 0-1. to reuse it under certains conditions.3 Ignore list Ignore touch in some part on screen class kivy.1. 13.InputPostprocIgnoreList Bases: object InputPostprocIgnoreList is a post-processor who remove touch in ignore list. This module is designed to prevent finger lost on some hardware/setup. taken from scan-for-mt-device. For more information about mtdev.postproc. linuxwacom.provider=mtdev.1. 230 . The device discovery is done by this provider.4 Retain Touch Reuse touch to counter finger lost behavior class kivy. 0. ymax). Here is an example of auto creation: [input] # using mtdev device_%(name)s = probesysfs.retaintouch. and time is in millisecond. However.provider=mtdev # using hidinput device_%(name)s = probesysfs. 0. not in the screen width/height..1. .postproc. mtdev is used prior to other providers.1. the reading of input can be made by other providers like: hidinput. mtdev. 3" screen stantum = hidinput./dev/input/eventXX # example with Stantum MTP4.disable_on_activity Disabling multitouch interaction with mouse New in version 1.4 Mouse provider implementation On linux system. ProbeSysfs module will enumerate hardware from /sys/class/input device./dev/input/event2 Note: You must have read access to the input event. you can activate the “disable_on_activity” token in mouse.match=E3 Finger. or 2.34. the range reported is invalid.param=mode=pen By default. But for example.0. Put in your configuration: [input] mouse = mouse. Y and pressure value. You can prevent this behavior by putting select_all=1 in your config line. put in your configuration: [input] # devicename = hidinput.).provider=linuxwacom. To avoid this behavior.disable_multitouch 13. you can add one of theses options on the argument line : • invert_x : 1 to invert X axis 231 . You have the possibility to use custom range for some X.6. if they are any touch active from another provider. mouse provider can be annoying when used with another multitouch provider (hidinput or mtdev. Mouse can conflict with them: a single touch can generate one event from mouse provider and from multitouch provider. 13.3. Then.2.5 Native support of HID input from linux kernel Support start from 2.param=max_pressure=99 # you can also match your wacom touchscreen touch = probesysfs.32-ubuntu. By default middle and right mouse buttons ared used for multitouch emulation.2. To configure HIDInput. If you want to use them for other purpose you can disable this behavior by activating the “disable_multitouch” token: [input] mouse = mouse. the mouse will be discarded. On some drivers. select_all=1.param=min_pressure=1.2.match=E3 Pen.provider=hidinput. and configure hardware with ABS_MT_POSITION_X capability.3 Common definitions for Windows provider This file provides common definitions of constants used for WM_Touch / WM_Pen 13.param=mode=touch # and your wacom pen pen = probesysfs.6. To fix that.provider=linuxwacom. select_all=1. wacom screen doesn’t support this capability. You can put it on configuration: [input] t101m = hidinput. using libmtdev. you can add one of theses options on the argument line : • invert_x : 1 to invert X axis • invert_y : 1 to invert Y axis • min_position_x : X minimum • max_position_x : X maximum • min_position_y : Y minimum • max_position_y : Y maximum • min_pressure : pressure minimum • max_pressure : pressure maximum • min_touch_major : width shape minimum • max_touch_major : width shape maximum • min_touch_minor : width shape minimum • max_touch_minor : height shape maximum 232 .max_position_y=32768 13. Y and pressure value./dev/input/event7. but real value are in a range from 0-32768.2. Check probesysfs for more information.ubuntu. Otherwise. on Asus T101M. Mtdev project is a part of Ubuntu Maverick multitouch architecture. To fix that. the range reported is invalid./dev/input/eventXX acert230h = mtdev.max_position_x=32768. you can put in your configuration: [input] # devicename = hidinput. On some drivers.com/Multitouch You can read more on To configure MTDev. it’s preferable to use probesysfs providers. http://wiki.• invert_y : 1 to invert Y axis • min_position_x : X minimum • max_position_x : X maximum • min_position_y : Y minimum • max_position_y : Y maximum • min_pressure : pressure minimum • max_pressure : pressure maximum For example./dev/input/event2 Note: You must have read access to the input event. You have the possibility to use custom range for some X.6 Native support of Multitouch device on Linux. the touchscreen report a range from 0-4095 for X and Y value. input. args) Bases: kivy. id.input.wm_touch./dev/input/event2. please refer to http://tuio.provider.MotionEvent MotionEvent representing the WM_MotionEvent event.2.MotionEventProvider The TUIO provider listens to a socket and handles some of the incoming OSC messages: •/tuio/2Dcur •/tuio/2Dobj 233 .10 Support of WM_TOUCH message (Window platform) class kivy.motionevent.2./dev/input/event3.WM_Pen(device. args) Bases: kivy. On some drivers.WM_MotionEvent(device. the range reported is invalid. To fix that.wm_pen. id.providers. Support pos profile 13. Supports pos.8 Native support of Wacom tablet from linuxwacom driver To configure LinuxWacom.2.providers. put in your configuration: [input] pen = linuxwacom.org – The specification should be of special interest.input.11 TUIO Input Provider TUIO is a de facto standard network protocol for the transmission of touch and fiducial information between a server and a client.input. shape and size profiles.2. Y and pressure value.tuio.motionevent. you can add one of theses options on the argument line : • invert_x : 1 to invert X axis • invert_y : 1 to invert Y axis • min_position_x : X minimum • max_position_x : X maximum • min_position_y : Y minimum • max_position_y : Y maximum • min_pressure : pressure minimum • max_pressure : pressure maximum 13. class kivy. To learn more about TUIO (which is itself based on the OSC protocol).mode=touch Note: You must have read access to the input event. 13.9 Support of WM_PEN message (Window platform) class kivy.7 Native support of MultitouchSupport framework for MacBook (MaxOSX platform) 13.TuioMotionEventProvider(device.providers.input. You have the possibility to use custom range for some X.input.13.mode=pen finger = linuxwacom.MotionEvent MotionEvent representing the WM_Pen event.2. args) Bases: kivy. Your class will be associated with the path that you pass to the register() function. id.The TUIO provider can be configured in the configuration file in the [input] section: [input] # name = tuio. though.input. id. TuioMotionEventProvider.providers.Tuio2dObjMotionEvent(device. self). id. implement ’unpacking’ for the received # arguments. args) def depack(self.input.register(’/tuio/PATH’. ) self. you can do it like this: if len(args) == 2: self. static create(oscpath.sy = args self.providers.192.sy = 1 . args): super(TuioNEWPATHMotionEvent.tuio.providers.Tuio2dCurMotionEvent(device.0. TuioNEWPATHMotionEvent) Note: The class name is of no technical importance.sy super(TuioNEWPATHMotionEvent.tuio. 234 . self. classname) Unregister a path to stop handling it in the tuio provider update(dispatch_fn) Update the tuio provider (pop events from the queue) class kivy.TuioMotionEvent A 2dCur TUIO touch.TuioMotionEvent A 2dObj TUIO object.input.depack(args) # Register it with the TUIO MotionEvent provider.sx. args): # In this method.self. If all you receive are x and y # values.profile = (’pos’.1:3333 You can easily extend the provider to handle new TUIO paths like so: # Create a class to handle the new TUIO type/path # Replace NEWPATH with the pathname you want to handle class TuioNEWPATHMotionEvent(MotionEvent): def __init__(self. To keep things simple.<ip>:<port> multitouchtable = tuio.__init__(id. class kivy.168. classname) Register a new path to handle in tuio provider start() Start the tuio provider stop() Stop the tuio provider static unregister(oscpath. you should name your class after the path that it handles. # You obviously need to replace the PATH placeholders appropriately. **kwargs) Create a touch from a tuio path static register(oscpath.tuio.providers. you basically translate from TUIO args to Kivy # MotionEvent variables. args) Bases: kivy. args) Bases: kivy.tuio.input. self). 2 Manual play You can manually open a recorder file.1 Recording events The best way is to use the “recorder” module. only the position are saved (‘pos’ profile and ‘sx’.recorder import Recorder def recorder_loop(instance. screen saver etc.3 Recording more attributes You can extend the attributes to save.13.3 Input recorder New in version 1. and his API is subject to change in a future v This is a class that can record and replay some part of input events.input. Let’s say you want to save angle and pressure of the touch. if available: 235 . By default.play = True 13. When activated. By default. you can do: from kivy.recorder import Recorder rec = Recorder(filename=’myrecorder. 13.bind(play=recorder_loop) rec.input. value): if value is False: instance.play = True rec = Recorder(filename=’myrecorder. you can press F8 to start the recording.1.3. press F8 again. This can be used for test case. Changes it only if you understand how input is working. and dispatch it to the event loop. attributes). Aka. not instance of complex class. and save some properties in a file + the delta time. You can replay the file by pressing F7. at one condition: attributes values must be simple value. saving shape will not work.kvi’) rec. Check the Modules documentation for learning about how to activate a module. 13. Warning: This part of Kivy is still experimental.kvi’) rec. you can play the input file: it will generate fake touch with saved properties. Once activated.play = True If you want to loop over that file. and play it by doing: from kivy.3.kvi. Check the Recorder module module for more information.0. Later.3. When you want to stop recording. the recorder will listen to any input event. ‘sy’. events will be written at <currentpath>/recorder. counter is a NumericProperty.input.) play is a BooleanProperty.event.recorder.from kivy.4 Known limitations • Unable to save attributes with instance of complex class • Values that represent time will be not adjusted • Can replay only complete record.EventDispatcher Recorder class.py -m recorder. default to False.kvi’.kvi’. default to False. record_attrs is a ListProperty. if a begin/update/end event is missing. record_attrs Attributes to record from the motion event. class kivy. read-only. ’sx’. record_profile_mask is a ListProperty. check module documentation for more information. ’pressure’]) rec. this could lead to ghost touch. • Stopping the replay before the end can lead to ghost touch. record_profile_mask Profile to save in the fake motion event when replayed. counter Number of events recorded in the last session. filename is a StringProperty. ’sy’. ‘sx’. profile_mask=pos:ang 13.input. default to [’pos’]. filename Filename to save the output of recorder. default to None.3. window is a ObjectProperty.record = True Or with modules variables: $ python main. default to 0. ‘sy’]. default to ‘recorder. ’angle’. ’pressure’].recorder import Recorder rec = Recorder(filename=’myrecorder. it will use the default one. play Boolean to start/stop the replay of the current file (if exist.attrs=is_touch:sx:sy:angle:pressure. record_attrs=[’is_touch’. record is a BooleanProperty. default to [’is_touch’. ’angle’. window Window instance to attach the recorder. 236 . record_profile_mask=[’pos’.Recorder(**kwargs) Bases: kivy. record Boolean to start/stop the recording of input events. If None set. This class define all the properties and methods needed to handle 2D and 3D position. Touch or not.profile: print ’The touch angle is’. A Touch event is a MotionEvent with the pos profile.4.4. This is a tiny list of the supported profiles by default.3 Profiles A capability is the ability of a MotionEvent to store a new information.4 Motion Event The MotionEvent is the base class used for every touch and no-touch event. If a MotionEvent have a pos profile. scrollup.move.2 Listen to Motion Event If you want to receive all Motion Event.a If you want to select only the fiducials: 237 . For example.bind(on_motion=on_motion) 13. Only theses event are dispatched all over the widget tree.up. pass Window. you can receive a Motion Event that have an angle. and how to access on it. 1.1 Motion Event and Touch We differentiate Motion Event and Touch event. this is the role of the providers. 3. Use properties x. Use properties x. but may have more capabilities. touch): if ’angle’ in touch. Profile name angle button markerid pos pos3d pressure shape Description 2D angle. you can bind motion event from Window to your own callbacks: def on_motion(self. Use property pressure Contact shape. touch. 13. z Pressure of the contact. a fiducial ID. Check other input providers to know if they are other profiles available.13. etype. Use property fid 2D position. or a way to indicate what is supported by the Motion Event. The MotionEvent are gathered from input providers 2. motionevent): # will receive all motion event.4. Note: You never create the MotionEvent yourself. y. Use property shape If yo want to know if the current MotionEvent have an angle: def on_touch_move(self. You can check the profile attribute to check what is currently supported by the Motion Event. scrolldown) Use property button Marker or Fiducial ID. y 3D position. right. 13. All the MotionEvent are dispatched in on_motion(). middle. or even a shape. Use property a Mouse button (left. we dispatch them in on_touch_down(). sz and self.x and self.pz.psz. px.psx.z and self. passed to depack() function apply_transform_2d(transform) Apply a transformation on x. dy. this is the time between the previous tap and the current touch. Parameters id [str] uniq ID of the Motion Event args [list] list of parameters. You can grab a touch if you absolutly want to receive on_touch_move() and on_touch_up(). dpos Return delta between last position and current position. dsz = None Delta between self. py. in the screen coordinate system (self. z. self.motionevent. ox. oz.y and self. oy. in window range dy = None Delta between self. in window range grab(class_instance.psy. exclusive=False) Grab this motion event. double_tap_time = None If the touch is a is_double_tap.px. in window range dz = None Delta between self.MotionEvent(device.grab_current is self: 238 .dy) dsx = None Delta between self.grab(self) def on_touch_move(self.sx and self.dx. dsy = None Delta between self. depack(args) Depack args into attributes in class device = None Device used for creating this touch distance(other_touch) Return the distance between the current touch and another touch. dx = None Delta between self. dz copy_to(to) Copy some attribute to another touch object. id. in 0-1 range. in 0-1 range.profile: return class kivy. touch): if ’markerid’ not in touch. touch): if touch. in 0-1 range. y.input.def on_touch_move(self.sy and self. touch): touch.py. pz. dx. args) Bases: object Abstract class to represent a touch and no-touch object. even if the touch is not dispatched by your parent: def on_touch_down(self. osz = None Origin Z position.grab_current is self: # i receive my grabbed touch. id = None Id of the touch. If you have multiple TUIO source. i must ungrab it ! touch. in window range oz = None Origin Z position. Y).py) profile = None Profiles currently used in the touch psx = None Previous X position.ox. touch): if touch. Prefer to use uid attribute instead. in window range pop() Pop attributes values from the stack pos = None Position (X. osy = None Origin Y position. move(args) Move the touch to another position opos Return the initial position of the touch in the screen coordinate system (self.ungrab(self) else: # it’s a normal touch pass grab_current = None Used to determine which widget the touch is beeing dispatched. ox = None Origin X position. self. 239 . in window range oy = None Origin Y position. the same id can be used. is_double_tap = None Indicate if the touch is a double tap or not is_touch = None True if the Motion Event is a Touch. in 0-1 range. in 0-1 range. This is generally the Id set by the input provider.# i receive my grabbed touch else: # it’s a normal touch def on_touch_up(self. in 0-1 range. self.oy) osx = None Origin X position. Can be also verified is pos is profile.px. in window range ppos Return the previous position of the touch in the screen coordinate system (self. like ID in TUIO. in 0-1 range. not uniq. Check grab() function for more information. Use this dictionnary to save your own data on the touch. in 0-1 range. pz. dx. p=None. oz.psy = None Previous Y position. oy. z. self. in 0-1 range. px = None Previous X position. in 0-1 range sy = None Y position. You can safely use this property. psz = None Previous Z position. subclass of Shape. it will be never the same accross all existing touches. ungrab(class_instance) Ungrab a previous grabbed touch x = None X position. in window range scale_for_screen(w. in window range pz = None Previous Z position. py. when we use push() : x. By default. y. the property is set to None spos Return the position in the 0-1 coordinate system (self. ox. dy. push(attrs=None) Push attributes values in attrs in the stack push_attrs_stack = None Attributes to push by default. uid = None Uniq ID of the touch.sy) sx = None X position. px. dz. in window range py = None Previous Y position. in 0-1 range time_end = None Time of the end event (last touch usage) time_start = None Initial time of the touch creation time_update = None Time of the last update ud = None User data dictionnary.sx. in 0-1 range sz = None Z position. in window range 240 . h. in window range z = None Z position. in window range y = None Y position. rotation=0) Scale position for the screen shape = None Shape of the touch. don’t forget to register it: MotionEventFactory. MyInputProvider) static get(name) Get a provider class from provider id static list() Get a list of all providers availables static register(name. and if the configuration use the current provider.MotionEventProvider(device.input. The implementation must support the start(). class kivy. classname) Register a input provider in the database 13. height Height of the rect width Width fo the rect 241 . and dispatch all the new touch event though the dispatch_fn argument.factory.7 Motion Event Shape Represent the shape of the MotionEvent class kivy.shape.provider.input.ShapeRect Bases: kivy. start() Start the provider.5 Motion Event Factory Factory of MotionEvent providers. If you create a new input factory.input. 13.Shape Bases: object Abstract class for all implementation of a shape class kivy. stop() and update() methods. args) Bases: object Base class for a provider.Shape Represent a rectangle shape.input. This method is automatically called when the application is started.shape.MotionEventFactory MotionEvent factory is a class who register all availables input factories.input. stop() Stop the provider update(dispatch_fn) Update the provider.6 Motion Event Provider Abstract class for a implement a MotionEvent provider.register(’myproviderid’.shape.13. class kivy. 242 . exc_value. locals and contents.lib.ProcessedTraceback(exc_type.debug. and we might change in the future. see LICENSE for more details. 243 .debug.TracebackFrameProxy(tb) Bases: object Proxies a traceback frame.debug Implements the debug interface for Jinja. Don’t rely on theses in your code. We want to thanks a lot all the Jinja2 team for this awesome and ugly file ! :) class kivy. exc_info Exception info tuple with a proxy around the frame objects. 14. we don’t give any support. Note: This file have been modified for Kivy usage. copyright 3. render_as_text(limit=None) Return a string with the traceback.lib.1 jinja2. standard_exc_info Standard python exc_info for re-raising class kivy.CHAPTER FOURTEEN EXTERNAL LIBRARIES Kivy come with other python/c libraries : • ddslib • oscAPI (modified / optimized) • mtdev Warning: Even if Kivy come with theses external libraries. This module does some pretty ugly stuff with the Python traceback system in order to achieve tracebacks with correct line numbers. license BSD. and its own kv language. frames) Bases: object Holds a Jinja preprocessed traceback for printing or reraising. 2010 by the Jinja Team. next) Set the tb_next attribute of a traceback object.debug. lineno) Helper for translate_exception. kivy. kivy. kivy. initial_skip=0) If passed an exc_info it will automatically rewrite the exceptions all the way down to the correct line numbers and frames.kivy. kivy.translate_exception(exc_info.debug.lib.debug. filename.lib. source_hint=None) Creates a processed traceback object from the exc_info.debug. source=None) Rewrites a syntax error to please traceback systems.fake_exc_info(exc_info. 244 .translate_syntax_error(error.tb_set_next(tb.lib.make_traceback(exc_info.lib.lib.debug. you can edit your configuration file (in your HOME/. • keybinding: Bind some keys to action.kivy/config. we have few modules like: • touchring: Draw a circle around each touch • monitor: Add a red topbar that indicate the FPS and little graph about activity input. ’’) 15.config import Config Config.0. For example.set(’modules’.3 Create my own module Create a file in your HOME/. you can do something like this: import kivy kivy.ini): [modules] # uncomment to activate touchring = # monitor = # keybinding = Only the name of the module followed by a = is sufficient to activate the module. 15. Modules are automatically searched accross Kivy path and User path: • PATH_TO_KIVY/kivy/modules • HOME/. and create 2 functions: 245 . activate touchring module from kivy. like screenshot. preferably at the start of your import. The loading of modules are managed inside the config file.8’) # here.kivy/mods 15.1 Activate module in config To activate a module.CHAPTER FIFTEEN MODULES Modules are classes that can be loaded when a Kivy application is starting. ’touchring’.require(’1.kivy/mods.2 Activate module in Python Before starting your application. Warning: This module is highly experimental. 90.def start(win. This context is unique for each instance / start() call of the module. attach to the class. 180.6 Monitor module Monitor module is a toolbar that show activity of your current application : • FPS • Graph of input event 15. When you are starting a module. However. Inspector is a tool to lookup the widget tree by pointing widget on the screen.9. Create an instance of Recorder.4 Inspector New in version 1. and bind some keys to record / play sequences: • F7: read the latest recording • F8: record input events 246 .1.5 Keybinding This module force the mapping of some keys to functions: • F11: Rotate the Window from 0. Use the ctx variable as a dictionnary. this due to delayed usage of some properties. 15.0.7 Recorder module New in version 1. you might have crash if you didn’t handle all the case. ctx): pass Start/stop are functions that will be called for every window opened in Kivy. then hide inspector view Available inspect interactions: • tap once on a widget to select it without leaving inspect mode • double tap on a widget to select and leave inspect mode (then you can manipulate the widget again) Some properties can be edited in live. and will be passed to stop() too. 270 • F12: Take a screenshot 15. 15. ctx): pass def stop(win. to use global variables to store the module state.0. Some keyboard shortcut are activated: • “Ctrl + e”: activate / deactivate inspector view • “Escape”: cancel widget inspect first. use it with care. 8 Screen This module change some environement and configuration to match the density / dpi / screensize of a specific devices. just run: python main. Opacity of the image 15.py -m screen:onex. in portrait: python main.9 Touchring Show ring around every touch on the table. default to ‘<kivy>/data/images/ring.9. scale: float. you can write something like this: [modules] touchring = image=mypointer. default to ‘recorder.15. filename: str. Attributes to record from the motion event profile_mask: str.png’ Filename of the image to use. Mask for motion event profile. You can use this module for checking if you don’t have any calibration trouble with touches.alpha=.3.py -m screen:ipad 15.7. default to 1.py -m screen:droid2 Simulate a high-density screen as HTC One X.ini).py -m screen Simulate a medium-density screen as Motolora Droid 2: python main.portrait Simulate the iPad 2 screen: python main. alpha: float. default to 1.kivy/config.9. Scale of the image. default to record_attrs value. 15.kvi’ Name of the file to record / play with 15. Used to filter which profile will appear in the fake motion event when replayed.scale=.png.7 247 . To see a list of the available screenid. default to record_profile_mask value.1 Configuration Parameters attrs: str.1 Configuration Parameters image: str.2 Example In your configuration (~/. 248 . The syntax to create a request: from kivy. for trend in trends: print trend[’name’].com/1/trends/1. body.urlrequest. By default. Example of fetching twitter trends: def got_twitter_trends(req.urlencode({’@number’: 12524. ’@type’: ’issue’. Right now. got_twitter_trends) Example of Posting data (adapted from httplib example): import urllib def bug_posted(req. a “POST” request will be done. the result will be automatically passed through json. callback_success.loads. You can use the UrlRequest to make asynchronous request on the web. all the rest is optional.urlrequest import UrlRequest req = UrlRequest(url. The content is also decoded. check 16. ’@action’: ’show’}) headers = {’Content-type’: ’application/x-www-form-urlencoded’.req_headers if necessary. if the Content-Type is application/json.req_body is not None.1 Url Request New in version 1.network. result): trends = result[0][’trends’] print ’Last %d twitter trends:’ % len(trends). and get the result when the request is completed. print ’!’ req = UrlRequest(’https://api. It’s up to you to adjust UrlRequest. If UrlRequest. callback_error. The spirit is the same as XHR object in Javascript.CHAPTER SIXTEEN NETWORK SUPPORT Kivy start to have some support for kivy.0.UrlRequest ! network request.network.json’. a “GET” request will be done. result): print ’Our bug is posted !’ print result params = urllib.twitter.8. headers) Only the first argument is mandatory. aka for now. ’Accept’: ’text/plain’} 249 . a lot of on_progress will be fired. If you want to have the maximum download speed. Changed in version 1. on_success=None. on_error=None. used only when on_progress callback have been set. default to 8192 Size of each chunk to read. error Return the error of the request. See module documentation for usage. or don’t use on_progress. get_connection_for_scheme(scheme) Return the Connection class from a particular scheme. This callback will be called after each chunk_size read. method=None) Bases: threading.org’. chunk_size=8192. resp) Decode the result fetched from url according to his Content-Type. req_body: str.10: Add method parameters Parameters url: str Complete url string to call. timeout: int. only decode application/json. increase chunk_size. and will slow down your download. req_body=None. Actual supported schemes: http. method’: str. is_finished Return True if the request have finished. on_success: callback(request.network. a POST will be done instead of a GET req_headers: dict. total_size) Callback function that will be called to report progression of the download. total_size might be -1 if no Content-Length have been reported in the http response. timeout=None. req_body = None Request body passed in __init__ 250 .UrlRequest(url. current_size.0.) decode_result(result. req_body=params. error) Callback function to call when an error happen on_progress: callback(request. If it’s not None. If you decrease it too much.python. blocking operations will timeout after that many seconds. on_progress=None. result) Callback function to call when the result have been fetched on_error: callback(request. req_headers=None. This value is not undeterminate until the request is finished. whatever is if it’s a success or a failure. used only in “progress” mode (when on_progress callback is set.urlrequest. default to None If set.Thread Url request. default to None Custom headers to add for the request chunk_size: int. Actually. https. This is an internal that can be expanded to support custom scheme. on_success=bug_posted. req_headers=headers) class kivy. default to None Data to sent in the request.req = UrlRequest(’bugs. default to ‘GET’ (or ‘POST’ if body) HTTP method to use chunk_size Return the size of a chunk. This value is not undeterminate until the request is finished.req_headers = None Request headers passed in __init__ resp_headers If the request have been done.1. it will return None resp_status Return the status code of the response if the request have been done.0. and the callback will be dispatched from the same thread as the thread you’re calling it. New in version 1. you can call the wait() method. It will wait for the request to be finished (until resp_status is not None) Note: This method is intended to be used in the main thread. return a dictionnary containing the headers of the response. 251 . Otherwise. return None result Return the result of the request. url = None Url of the request wait(delay=0.5) If you want a sync request. otherwise. 252 . Toggle button.0. or even on the interaction (touch) part. Button. Video • Layouts: A layout widget has no rendering. and its API is subject to change in a future vers 253 . Read more on Layout Grid Layout. We call them complex because the assembly and usages are not as generic as the classicals widgets. result of classic widget combinations. Box Layout. just a trigger that will arrange its children in a specific way. Scatter. but act on the graphics part. CheckBox. Switch. Drop-Down List. Screen Manager 17. and transition when switching from one to another. Anchor Layout. perfect and ready to be assembled to create more complex widgets. Stencil View • Screen manager: Manage screens. Text Input. VKeyboard. Spinner. Warning: This widget is still experimental. The kivy.8.1 Accordion New in version 1.CHAPTER SEVENTEEN WIDGETS A widget is an element of a graphical user interface. Label. Progress Bar. Bubble. Stack Layout • Complex UX widgets: Non-atomic widgets.uix module contains classes for creating and managing Widgets. Read first: Widget class • UX widgets: Classical user interface widgets. Image. Slider. Video player. Popup. FileChooser. TabbedPanel. • Behaviors widgets: Theses widgets have no rendering. and reduce the number of children. This is “normal”. and the item in focus/when touched opens up displaying his content.accordion import Accordion. You’ll have a Tree like this: • Accordion – AccordionItem * YourContent – AccordionItem * BoxLayout · Another user content 1 · Another user content 2 – AccordionItem * Another user content The current implementation divides the AccordionItem into two parts: 1. That means you have too many children. Try to increase the space for the accordion. Warning: If you see message like: [WARNING] [Accordion] not have enough space for displaying all children [WARNING] [Accordion] need 440px.add_widget(Label(text=’Very big content\n’ * 10)) root. and nothing will be done.add_widget(item) return root if __name__ == ’__main__’: AccordionApp(). One container for the title bar 2. One container for the content The title bar is made from a Kv template.1 Simple example from kivy.app import App class AccordionApp(App): def build(self): root = Accordion() for x in xrange(5): item = AccordionItem(title=’Title %d’ % x) item.label import Label from kivy.uix.uix. 17. You can also reduce the Accordion. and there is no more space to display any content. The Accordion will contain one or many AccordionItem instances.min_space.run() 254 .1. We’ll see how to create a new template to customize the design of the title bar. got 100px [WARNING] [Accordion] layout aborted.The Accordion widget is a form of menu where the options are stacked either vertically or horizontally. that will contain one root content widget. AccordionItem from kivy. See module documentation for more information. default to . default to 44 (px). background_normal is an StringProperty.accordion. background_selected=’image_when_selected. default to ‘horizontal’.png’. orientation is an OptionProperty. when the item is collapsed.2 Customize the accordion You can increase the default size of the title bar: root = Accordion(min_space=60) Or change the orientation to vertical: root = Accordion(orientation=’vertical’) AccordionItem is more configurable.uix. min_space is a NumericProperty.animation.uix. default to ‘out_expo’. class kivy. You can set a string or a function to use as an easing function.AnimationTransition for more information about available animation functions. anim_duration Duration of the animation in seconds. and you can set your own title background when the item is collapsed or opened: item = AccordionItem(background_normal=’image_when_collapsed.1.uix.uix.AccordionItem(**kwargs) Bases: kivy. default to None. Check kivy.floatlayout. See module documentation for more information. accordion is an ObjectProperty. 255 . orientation Orientation of the layout. when a new accordion item is selected. each time the layout happens.FloatLayout AccordionItem class.Widget Accordion class.png’) class kivy.17. accordion Instance of the Accordion that the item belongs to. Can take a value of ‘vertical’ or ‘horizontal’.25 (250ms) anim_func Easing function to use for the animation. anim_duration is a NumericProperty. when the item is selected (not collapsed).accordion. that must be used in conjunction with Accordion class. las://data/images/defaulttheme/button’ default to ‘at- background_selected Background image of the accordion item used for default graphical representation.Accordion(**kwargs) Bases: kivy. background_normal Background image of the accordion item used for default graphical representation. This value is automatically set on each children. anim_func is a ObjectProperty.widget. min_space Minimum space to use for title of each item. The title might be used in conjuction with the AccordionItemTitle template.min_space property. default to ‘AccordionItemTitle’. default to True default to ‘at- collapse_alpha Value between 0 and 1 to indicate how much the item is collasped (1) or selected (0). las://data/images/defaulttheme/button_pressed’ collapse Boolean to indicate if the current item is collapsed or not. 1. By default. title Title string of the item.orientation property. title is a StringProperty.before: Color: rgb: 1.background_normal \ if ctx.background_selected 256 . See title_template and the example below. container (internal) Property that will be set to the container of children. if the default template does not suffice. title_args is a DictProperty.item.title canvas. Here is the code if you want to build your own template: [AccordionItemTitle@Label]: text: ctx. content_size (internal) Set by the Accordion to the size allocated for the content. orientation Link to the Accordion. default to {} title_template Template to use for creating the title part of the accordion item.template() method.background_normal is an StringProperty.item. not customizable (except the text) that supports vertical and horizontal orientation. The current default template lives in the kivy/data/style.collapse \ else ctx. It’s better to create and use your own template. If you are using a custom template. title is a StringProperty. min_space Link to the Accordion. inside the AccordionItem representation. inside the AccordionItem representation.lang. default to 1. it’s used for the title text. The default template is a simple Label. collapse is a BooleanProperty. 1 BorderImage: source: ctx. and different backgrounds for collapse and selected mode. default to ‘’ title_args Default arguments that will be pass to the kivy. It’s mostly used for animation. collapse_alpha is a NumericProperty. or not. container_title (internal) Property that will be set to the container of title.item.kv file. you can use that property as a text entry.Builder. item. bottom.Exception AccordionException class.AccordionException Bases: exceptions. 17. left.center_y Rotate: angle: 90 if ctx.size PushMatrix Translate: xy: self.center_y canvas. To draw a button in the lower-right corner: layout = AnchorLayout( anchor_x=’right’.accordion. anchor_y=’bottom’) btn = Button(text=’Hello World’) layout. 1 Translate: xy: -self. self. -self.uix.pos: self.pos size: self.orientation == ’horizontal’ else 0 axis: 0.center_x.center_x.add_widget(btn) 257 .2 Anchor Layout AnchorLayout aligns children to a border (top. right) or center. 0.after: PopMatrix class kivy. anchor_y is an OptionProperty. Can take a value of ‘top’.add_widget(btn2) To position widgets next to each other. In this example.layout. ‘center’ or ‘right’. anchor_x Horizontal anchor. anchor_y Vertical anchor. use a vertical BoxLayout: layout = BoxLayout(orientation=’vertical’) btn1 = Button(text=’Hello’) btn2 = Button(text=’World’) layout. default to ‘center’.Layout Anchor layout class. 1)) 258 . padding Padding between widget box and children. use a horizontal BoxLayout.anchorlayout. default to ‘center’. the first button covers 70% of the horizontal space.3 Box Layout BoxLayout arranges children in a vertical or horizontal box. the second covers 30%: layout = BoxLayout(spacing=10) btn1 = Button(text=’Hello’. size_hint=(. in pixels. size_hint=(. See module documentation for more information.3. default to 0.uix. 17.AnchorLayout(**kwargs) Bases: kivy.7. padding is a NumericProperty. Can take a value of ‘left’. To position widgets above/below each other. 1)) btn2 = Button(text=’World’.class kivy. we use 10 pixel spacing between children. ‘center’ or ‘bottom’.uix.add_widget(btn1) layout. anchor_x is an OptionProperty. layout. spacing is a NumericProperty.boxlayout. For example.1 Simple example 259 . Can be ‘vertical’ or ‘horizontal’. The Bubble widget is a form of menu or a small popup where the menu options are stacked either vertically or horizontally.4. size_hint=(. 1)) btn3 = Button(text=’World’.0. (800200)*0.5. default to 0. 100).5. class kivy. top and center_y will be used You can check the examples/widgets/boxlayout_poshint. and add three buttons like this: btn1 = Button(text=’Hello’.py for a live example.BoxLayout(**kwargs) Bases: kivy.4 Bubble New in version 1.4.uix. orientation is an OptionProperty. the second and third will be 300px each. 1)) The first button will be 200px wide as specified. padding Padding between layout box and children. spacing Spacing between children. size_hint=(. if you have a layout that is 800px wide. size=(200. size_hint=(None. default to ‘horizontal’.1.add_widget(btn2) Position hint are also partially working.layout. e.. depending the orientation: • If the orientation is vertical: x. Note: The size_hint uses the available space after subtracting all the fixed-size widgets.uix.Layout Box layout class. in pixels. right and center_x will be used • If the orientation is horizontal: y. The Bubble contains an arrow pointing towards the direction you choose. 17. See module documentation for more information.5 Changed in version 1. padding is a NumericProperty. default to 0.1: Added support for pos_hint. 17.g. orientation Orientation of the layout. None)) btn2 = Button(text=’Kivy’. in pixels.add_widget(btn1) layout. 5.arrow_pos) self.but_bubble. ’’’ from from from from from kivy.floatlayout import FloatLayout kivy. ’right_mid’. ’left_bottom’.but_bubble) def show_bubble(self. ’left_mid’. ’top_right’.6} arrow_pos: ’bottom_mid’ orientation: ’horizontal’ BubbleButton: text: ’Cut’ BubbleButton: text: ’Copy’ BubbleButton: text: ’Paste’ ’’’) class cut_copy_paste(Bubble): pass class BubbleShowcase(FloatLayout): def __init__(self.bubble import Bubble Builder.uix. **kwargs): super(BubbleShowcase. None) size: (150.add_widget(bubb) else: values = (’left_top’.bubb. ’bubb’): self. ’bottom_left’. ’top_left’.lang import Builder kivy.show_bubble) self.bubb = bubb = cut_copy_paste() self.bubb. ’bottom_right’) index = values.arrow_pos = values[(index + 1) % len(values)] class TestBubbleApp(App): def build(self): return BubbleShowcase() if __name__ == ’__main__’: TestBubbleApp().but_bubble = Button(text=’Press to show bubble’) self. 50) pos_hint: {’center_x’: .’’’ Bubble ====== Test of the widget Bubble.add_widget(self. ’right_top’.uix.load_string(’’’ <cut_copy_paste> size_hint: (None.app import App kivy. ’right_bottom’. *l): if not hasattr(self. ’y’: .bind(on_release=self.uix. ’top_mid’.run() 260 .index(self. self).__init__(**kwargs) self. ’bottom_mid’.button import Button kivy. Can be one of: left_top.children Change Appearance of the bubble: bubble. right_bottom bottom_left. right_mid. 0. background_color Background color.bubble.uix. top_right right_top.5) #50% translucent red bubble.add_widget(your_widget_instance) Remove Items: bubble. 0. 0. background_color is a ListProperty.background_color = (1. background_image is a StringProperty. 1].4. g. 0. left_mid.clear_widgets() Access children list. 0] background_image = ’path/to/background/image’ arrow_image = ’path/to/arrow/image’ class kivy. . top_mid. default to ‘bottom_mid’. 1. bottom_right.uix. Warning This is important! Use content. default to [1. default to ‘at- 261 .border = [0. arrow_image is a StringProperty.17. You can change that by: orientation = ’vertical’ Add Items to the bubble: bubble = Bubble(orientation = ’vertical’) bubble.children to access the children list: bubble. arrow_pos Specifies the position of the arrow relative to the bubble. 1. arrow_pos is a OptionProperty. in the format (r. default to ‘atlas://data/images/defaulttheme/bubble_arrow’. b. background_image Background image of the bubble.gridlayout.Bubble(**kwargs) Bases: kivy.2 Customize the Bubble You can choose the direction the arrow points towards: Bubble(arrow_pos=’top_mid’) The widgets added to Bubble are orderd by default horizontally as in a Boxlayout.content. bottom_mid. See module documentation for more information. left_bottom top_left.remove_widget(Widget) or bubble. las://data/images/defaulttheme/bubble’.GridLayout Bubble class. arrow_image Image of the arrow pointing to the bubble. a). left). you can use the same properties that you can use for the Label class: button = Button(text=’Hello world’.BubbleButton(**kwargs) Bases: kivy. 16) content This is the object where the main content of the bubble is held. 17. It must be a list of 4 values: (top. right. default to (16. You can use a “normal” button class. content is a ObjectProperty. Instead. ‘horizontal’ orientation is a OptionProperty. Can be one of ‘vertical’.uix. class kivy. font_size=14) To attach a callback when the button is pressed (clicked/touched).bind(on_press=callback) If you want to be notified every time the button state changes.button.text btn1 = Button(text=’Hello world 1’) btn1.border Border used for BorderImage graphics instruction.bind(on_press=callback) btn2 = Button(text=’Hello world 2’) btn2. you can attach to the Button. default to ‘None’. border is a ListProperty. To configure the button.bubble. you can use this BubbleButton widget that already defined the good background for you.Button A button intended for use as in a Bubble widget. 16.state property: 262 . Used for background_image. use bind: def callback(instance): print ’The button <%s> is being pressed’ % instance.uix. Read the BorderImage instructions for more information about how to use it. orientation This specifies the manner in which the children inside bubble are arranged.5 Button Button is a Label with associated actions that are triggered when the button is pressed (or released after a click/touch). unless the background is changed. but it will not look good. 16. bottom. Can be used when using custom background. default to ‘horizontal’. It must be a list of four values: (top. when the button is not pressed. value): print ’My button <%s> state is <%s>’ % (instance. New in version 1.. 16. 1. 17. Events on_press Fired when the button is pressed. Once the widget is created. background_down Background image of the button used for default graphical representation. the touch/click that pressed the button goes away). background_down is an StringProperty.8. background_color Background color.Label Button class. To use a different camera. bottom. g. right. The state is ‘down’ only when the button is currently touched/clicked.0. 1]. default to (16. Can be used for a custom background.4. on_release Fired when the button is released (i.6 Camera The Camera widget is used to capture and display video from a camera. background_normal is an StringProperty.0. 1. a). left). when the button is pressed. border is a ListProperty. 16. Our CameraBase implementation is used under the hood: cam = Camera() By default the first camera found on your system is used.def callback(instance. must be one of ‘normal’ or ‘down’. Used with background_normal and background_down. default to [1. New in version 1.Button(**kwargs) Bases: kivy. default to ‘atlas://data/images/defaulttheme/button’ border Border used for BorderImage graphics instruction. b. state is an OptionProperty. 16) state State of the button. otherwise ‘normal’.label.4. New in version 1.bind(state=callback) class kivy.uix. background_color is a ListProperty.uix.e. in the format (r.button. Read the BorderImage instruction for more information about how to use it.0. default to ‘atlas://data/images/defaulttheme/button_pressed’ background_normal Background image of the button used for default graphical representation. value) btn1 = Button(text=’Hello world 1’) btn1. the texture inside the widget will be automatically updated. set the index property: cam = Camera(index=1) You can also select the camera resolution: 263 . see module documentation for more information. resolution is a ListProperty.png&text=slide-%d&. starting from 0. -1]. See module documentation for more information. class kivy.png" % i image = Factory. The camera initialization is asynchronous. the camera may not respect this property. resolution Preferred resolution to use when invoking the camera. 240)) Warning: The camera texture is not updated as soon as you have created the object.7 Carousel New in version 1.camera. allow_stretch=True) 264 . default to [-1. You can start/stop the camera by setting this property: # start the camera playing at creation (default) cam = Camera(play=True) # create the camera.4. The Carousel widget provides the classic mobile-friendly carousel view where you can swipe between slides. Example: class Example1(App): def build(self): carousel = Carousel(direction=’right’) for i in range(10): src = "http://placehold. the resolution will be the default one: # create a camera object with the best image available cam = Camera() # create a camera object with an image of 320x240 if possible cam = Camera(resolution=(320.cam = Camera(resolution=(320. default to -1 to allow auto selection.0. it may take a little bit before the texture is created. -1] 17. 240)) Warning: Depending on the implementation.Image Camera class.it/480x270. and start later cam = Camera(play=False) # and later cam.AsyncImage(source=src. If you are using [-1. You can add any content to the carousel and use it horizontally or verticaly. index is a NumericProperty. index Index of the used camera.Camera(**kwargs) Bases: kivy. The carousel can display pages in loop or not. default to True.uix.uix. play Boolean indicate if the camera is playing.image.play = True play is a BooleanProperty. index is a NumericProperty.uix. anim_cancel_duration is a NumericProperty . direction is a OptionProperty. If the movement doesn’t reach this minimal value.add_widget(image) return carousel Example1().0. index Get/Set the current visible slide based on index. This is a percentage of the carousel width. then the movement is canceled and the content is restored to its preceding position.carousel.run() Changed in version 1. default to True. with the default value of right. default to 0. default to 0.carousel.uix. and the user would swipe from the right towards the left. Slidesare a Relativelayout which contains the widget added to the carousel.5 current_slide The currently shown slide. the previous slide is towards the top. default to 0 (first item) loop Allow carousel to swipe infinitely.Carousel(**kwargs) Bases: kivy. loop is a BooleanProperty. 265 . previous_slide is a AliasProperty.stencilview. If orientation is ‘horizontal’. to get to the second slide. When the user reach the last page. the second slide. the next slide is to the right.2 next_slide The next slide in the Carousel.3 anim_move_duration Defines the duration of the carousel animation between pages. left. he will get the first page when trying to swipe next. min_move Defines the minimal distance from the edge where the movement is considered a swipe gesture and the carousel will change his content. Same effect when trying to swipe the first page. See module documentation for more information.StencilView Carousel class.5. ‘top’. is to the right of the first. anim_move_duration is a NumericProperty. is None if the current slide is the last slide in the carousel. Can be right. default to ‘right’. For example. This is generally when the user doesnt swipe enough. is None if the current slide is the first slide in the carousel. If orientation is ‘vertical’. direction Specifies the direction in which the slides are orderd / from which the user swipes to go from one to the next slide. class kivy. previous_slide The previous slide in the Carousel. min_move is a NumericProperty. anim_cancel_duration Defines the duration of the animation when a swipe movement is not accepted. current_slide is a AliasProperty. default to 0. See min_move. or bottom. scroll_distance Distance to move before scrolling the ScrollView.5.8 CheckBox New in version 1..0. in milliseconds. If the CheckBox is in a Group. and no touch event will go to children. the ScrollView will start to scroll.uix. default to 200 (milliseconds) New in version 1..4.5. previous_slide is a AliasProperty. in pixels. As soon as the distance has been traveled.0. If the user has not moved scroll_distance within the timeout. If orientation is ‘vertical’. As with the ToggleButton. def on_checkbox_active(checkbox. scroll_timeout Timeout allowed to trigger the scroll_distance. slides is a list of RelativeLayout widgets containing the content added through add_widget. the previous slide towards the bottom.checkbox import CheckBox # . only one Radio button at a time can be selected when the CheckBox. CheckBox is a specific two-state button that can be either checked or unchecked. slides List of slides inside the carousel. scroll_timeout is a NumericProperty. the previous slide is to the left.0. It is advisable that you base this value on the dpi of your target device’s screen. scroll_distance is a NumericProperty. and the touch event will go to the children. default to 20dp. The slides are added when a widget is added to Carousel using add_widget(). value): if value: 266 . New in version 1. 17. it becomes a Radio button. An example usage: from kivy.group is set.If orientation is ‘horizontal’. the scrolling will be disabled. like the ones shown in the image.highlight import KivyLexer codeinput = CodeInput(lexer=KivyLexer()) 267 . checkbox.uix. active Indicates if the switch is active or inactive. It supports all the features supported by the textinput and Code highliting for languages supported by pygments along with KivyLexer for KV Language highliting.CheckBox(**kwargs) Bases: kivy. no group will be used (the checkbox is independent).extras.print ’The checkbox’.Widget CheckXox class. Only one checkbox in a group can be active.uix. active is a BooleanProperty. The CodeInput provides a box of editable highlited text.uix.checkbox. like a string.widget. ’is inactive’ checkbox = CheckBox() checkbox. ’is active’ else: print ’The checkbox’.1 Usage example To create a CodeInput with highliting for KV language: from kivy. group is a ObjectProperty 17. If None.9 Code Input New in version 1.9. group must be a hashable object.codeinput import CodeInput from kivy. see module documentation for more information. checkbox. 17.0.5. group Group of the checkbox. If specified. default to False.bind(active=on_checkbox_active) class kivy. To create a CodeInput with highliting for Cython: from kivy.uix.codeinput import CodeInput from pygments.lexers import CythonLexer codeinput = CodeInput(lexer=CythonLexer()) class kivy.uix.codeinput.CodeInput(**kwargs) Bases: kivy.uix.textinput.TextInput CodeInput class, used for displaying highlited code. lexer This holds the selected Lexer used by pygments to highlite the code lexer is a ObjectProperty defaults to PythonLexer 17.10 Drop-Down List New in version 1.4.0. A versatile drop-down list, that can be used with custom widget. It allow you to display a list of widgets under a displayed widget. Unlike others toolkits, the list of widgets is what you want, it can be simple button, or images etc. The positioning of the drop-down list is fully automatic: we will always try to place the dropdown list in a way that the user can select an item in the list. 17.10.1 Basic example A button with a dropdown list of 10 possibles values. All the button within the dropdown list will trigger the dropdown DropDown.select() method. And then, the main button text will display the selection of the dropdown. from kivy.uix.dropdown import DropDown from kivy.uix.button import Button # create a dropdown with 10 button dropdown = DropDown() for index in xrange(10): btn = Button(text=’Value %d’ % index, size_hint_y=None, height=44) # for each button, attach a callback that will call the select() method # on the dropdown. We’ll pass the text of the button as the data of the # selection. btn.bind(on_release=lambda btn: dropdown.select(btn.text)) # then add the button inside the dropdown dropdown.add_widget(btn) # create a big main button mainbutton = Button(text=’Hello’, size_hint=(None, None)) # show the dropdown menu when the main button is released # note: all the bind() always pass the instance of the caller (here, the # mainbutton instance) as first argument of the callback (here, # dropdown.open.). mainbutton.bind(on_release=dropdown.open) # one last thing, listen to the selection done in the dropdown list. 268 # Assign the data to the button text. dropdown.bind(on_select=lambda instance, x: setattr(mainbutton, ’text’, x)) 17.10.2 Extending dropdown in Kv You could create a dropdown directly from kv: #:kivy 1.4.0 <CustomDropDown>: Button: text: ’My first Item’ size_hint_y: None height: 44 on_release: root.select(’item1’) Label: text: ’Unselectable item’ size_hint_y: None height: 44 Button: text: ’My second Item’ size_hint_y: None height: 44 on_release: root.select(’item2’) And then, create the associated python class, and use it: class CustomDropDown(DropDown): pass dropdown = CustomDropDown() mainbutton = Button(text=’Hello’, size_hint=(None, None)) mainbutton.bind(on_release=dropdown.open) dropdown.bind(on_select=lambda instance, x: setattr(mainbutton, ’text’, x)) class kivy.uix.dropdown.DropDown(**kwargs) Bases: kivy.uix.scrollview.ScrollView DropDown class. See module documentation for more information. Events on_select: data Fired when a selection is done, with the data of the selection as first argument. Data is what you pass in the select() method as first argument. attach_to (internal) Property that will be set to the widget on which the drop down list is attached to. The method open() will automatically set that property, while dismiss() will set back to None. auto_width By default, the width of the dropdown will be the same as the width of the attached widget. Set to False if you want to provide your own width. container (internal) Property that will be set to the container of the dropdown list, which is a GridLayout by default. dismiss(*largs) Remove the dropdown widget from the iwndow, and detach itself from the attached widget. 269 dismiss_on_select By default, the dropdown will be automatically dismissed when a selection have been done. Set to False to prevent the dismiss. dismiss_on_select is a BooleanProperty, default to True. max_height Indicate the maximum height that the dropdown can take. If None, it will take the maximum height available, until the top or bottom of the screen will be reached. max_height is a NumericProperty, default to None. open(widget) Open the dropdown list, and attach to a specific widget. Depending the position of the widget on the window and the height of the dropdown, the placement might be lower or higher off that widget. select(data) Call this method to trigger the on_select event, with the data selection. The data can be anything you want. 17.11 FileChooser New in version 1.0.5. Warning: This is experimental and subject to change as long as this warning notice is prese Changed in version 1.2.0: In chooser template, the controller is not a direct reference anymore, but a weak-reference. You must update all the notation root.controller.xxx to root.controller().xxx. class kivy.uix.filechooser.FileChooserListView(**kwargs) Bases: kivy.uix.filechooser.FileChooserController Implementation of FileChooserController using a list view. class kivy.uix.filechooser.FileChooserIconView(**kwargs) Bases: kivy.uix.filechooser.FileChooserController Implementation of FileChooserController using an icon view. class kivy.uix.filechooser.FileChooserController(**kwargs) Bases: kivy.uix.floatlayout.FloatLayout Base for implementing a FileChooser. Don’t use that class directly, preferring to use an implementation like FileChooserListView or FileChooserIconView. Events on_entry_added: entry, parent Fired when a root-level entry is added to the file list. on_entries_cleared Fired when the the entries list is cleared. Usally when the root is refreshed. on_subentry_to_entry: entry, parent Fired when a sub-entry is added to an existing entry. on_remove_subentry: entry, parent Fired when entries are removed from an entry. Usually when a node is closed. on_submit: selection, touch Fired when a file has been selected with a double-tap. cancel(*largs) Cancel any background action started by filechooser, such as loading a new directory. New in version 1.2.0. 270 dirselect BooleanProperty, defaults to False. Determines whether directories are valid selections. New in version 1.1.0. entry_released(entry, touch) (internal) This method must be called by the template when an entry is touched by the user. New in version 1.1.0. entry_touched(entry, touch) (internal) This method must be called by the template when an entry is touched by the user. file_encodings Possible encodings for decoding a filename to unicode. In the case that the user has a weird filename, undecodable without knowing it’s initial encoding, we have no other choice than to guess it. Please note that if you encounter an issue because of a missing encoding here, we’ll be glad to add it to this list. New in version 1.3.0. ListProperty, defaults to [’utf-8’, ‘latin1’, ‘cp1252’] files Read-only ListProperty. The list of files in the directory specified by path after applying the filters. filter_dirs BooleanProperty, defaults to False. Indicates whether filters should also apply to directories. filters ListProperty, defaults to [], equal to ‘*’. The filters to be applied to the files in the directory. The filters are not reset when the path changes. You need to do that yourself if desired. There are two kinds of filters : filename patterns : e.g. [’*.png’]. You can use the following patterns: Pattern * ? [seq] [!seq] Meaning matches everything matches any single character matches any character in seq matches any character not in seq Changed in version 1.4.0: if the filter is a callable (function or method). It will be called with the path and the file name as arguments for each file in dir. The callable should returns True to indicate a match and False overwise. get_nice_size(fn) Pass the filepath. Returns the size in the best human readable format or ‘’ if it is a directory (Don’t recursively calculate size.). multiselect BooleanProperty, defaults to False. Determines whether user is able to select multiple files. path StringProperty, defaults to current working directory as unicode string. Specifies the path on the filesystem that this controller should refer to. progress_cls Class to use for displaying a progress indicator for filechooser loading. New in version 1.2.0. ObjectProperty, defaults to FileChooserProgress 271 rootpath Root path to use, instead of the system root path. If set, it will not show a ”..” directory to go upper the root path. For example, if you set rootpath to /Users/foo, the user will be unable to go to /Users, or to any other directory not starting with /Users/foo. New in version 1.2.0. StringProperty, defaults to None. selection Read-only ListProperty. The list of files that are currently selected. show_hidden BooleanProperty, defaults to False. Determines whether hidden files and folders should be shown. sort_func ObjectProperty. Provides a function to be called with a list of filenames as the only argument. Returns a list of filenames sorted for display in the view. class kivy.uix.filechooser.FileChooserProgressBase(**kwargs) Bases: kivy.uix.floatlayout.FloatLayout Base for implementing a progress view. This view is used when too many entries need to be created, and are delayed over multiple frames. New in version 1.2.0. cancel(*largs) Cancel any action from the FileChooserController. index Current index of total entries to be loaded. path Current path of the FileChooser, read-only. total Total number of entries to load. 17.12 Float Layout The FloatLayout class will only honor the Widget.pos_hint and Widget.size_hint attributes. For example, if you create a FloatLayout with size a of (300, 300): 272 layout = FloatLayout(size=(300, 300)) By default, all widgets have size_hint=(1, 1), so this button will have the same size as the layout: button = Button(text=’Hello world’) layout.add_widget(button) To create a button of 50% width and 25% height of the layout and positioned at (20, 20), you can do: button = Button( text=’Hello world’, size_hint=(.5, .25), pos=(20, 20)) If you want to create a button that will always be the size of layout minus 20% on each side: button = Button(text=’Hello world’, size_hint=(.6, .6), pos_hint={’x’:.2, ’y’:.2}) Note: This layout can be used for an application. Most of time, you will use the size of Window. Warning: If you are not using pos_hint, you must handle the position of children: If the float layout is moving, you must handle moving children too. class kivy.uix.floatlayout.FloatLayout(**kwargs) Bases: kivy.uix.layout.Layout Float layout class. See module documentation for more information. 17.13 Grid Layout New in version 1.0.4. 273 GridLayout arranges children in a matrix. It takes the available space and divides it into columns and rows, then adds widgets to the resulting “cells”. New in version 1.0.7: The implementation has changed to use widget size_hint for calculating column/row sizes. uniform_width and uniform_height have been removed, and others properties have added to give you more control. 17.13.1 Background Unlike many other toolkits, you cannot explicitly place a widget at a specific column/row. Each child is automatically assigned a position, depending on the layout configuration and the child’s index in the children list. A GridLayout must always have at least one input constraint: GridLayout.cols or GridLayout.rows. If you do not specify cols or rows, the Layout will throw an exception. 17.13.2 Column Width and Row Height The column width/row height are determined in 3 steps: • The initial size is given by the col_default_width and row_default_height properties. To customize the size of a single column or row, use cols_minimum or rows_minimum. • Then the size_hint_x/size_hint_y of the child are taken into account. If no widgets have a size hint, the maximum size is used for all children. • You can force the default size by setting the col_force_default or row_force_default property. This will force the layout to ignore the width and size_hint properties of children and use the default size. 17.13.3 Usage of GridLayout In the example below, all widgets will get an equal size. By default, size_hint is (1, 1), so a Widget will take the full size of the parent: layout = GridLayout(cols=2) layout.add_widget(Button(text=’Hello layout.add_widget(Button(text=’World layout.add_widget(Button(text=’Hello layout.add_widget(Button(text=’World 1’)) 1’)) 2’)) 2’)) Now, let’s fix the size of Hello buttons to 100px instead of using size_hint 1: 274 add_widget(Button(text=’World layout.add_widget(Button(text=’Hello 2’.gridlayout. size_hint_x=None.0.add_widget(Button(text=’World 2’)) class kivy. New in version 1. DictProperty. New in version 1.0. row_default_height=40) layout. cols_minimum is a minimum_height Minimum height needed to contain all children.8: Change from NumericProperty to BoundedNumericProperty. default to 0. cols is a NumericProperty.0.uix. default to {} New in version 1. width=100)) 2’)) Next.8.add_widget(Button(text=’Hello 1’. col_default_width Default minimum size to use for column. let’s fix the row height to a specific size: layout = GridLayout(cols=2. cols_minimum List of minimum size for each column.7. See module documentation for more information.uix. default to 0. width=100)) 1’)) 2’. minimum_height is 275 . default to False. New in version 1.layout. row_force_default=True.7.0.GridLayout(**kwargs) Bases: kivy. You cannot set a negative value anymore. cols Number of columns in the grid.0.add_widget(Button(text=’World 1’. col_default_width is a NumericProperty. col_force_default If True. width=100)) layout. and use the default column width.add_widget(Button(text=’Hello layout.7. size_hint_x=None.layout = GridLayout(cols=2) layout.add_widget(Button(text=’World 1’)) layout.Layout Grid layout class.add_widget(Button(text=’Hello layout. size_hint_x=None. New in version 1. width=100)) layout. ignore the width and size_hint_x of the child. size_hint_x=None. col_force_default is a BooleanProperty. 14 Image The Image widget is used to display an image: wimg = Image(source=’mylogo. default to 0.0. New in version 1.Exception Exception for errors in the grid layout manipulation. you can inherit from Image and create your own style.properties. If you don’t want that. in pixels. New in version 1.7. padding Padding between widget box and children. rows_minimum is a spacing Spacing between widget box and children. ignore the height and size_hint_y of the child. New in version 1. spacing is a NumericProperty.NumericProperty.2 Alignment By default.7. 17. in pixels. default to 0. New in version 1. row_default_height is a NumericProperty. default to 0. You cannot set a negative value anymore. default to 0. default to 0. rows is a NumericProperty.14.1 Asynchronous Loading To load an image asynchronously (for example from an external webserver).a kivy. row_force_default is a BooleanProperty. minimum_width Minimum width needed to contain all children. default to False.0. minimum_height) properties.14.com/logo.0.8.8.png’) 17. rows Number of rows in the grid. minimum_size Minimum size needed to contain all children.7. DictProperty. 276 . default to {} New in version 1.0.8: Change from NumericProperty to BoundedNumericProperty.GridLayoutException Bases: exceptions. and use the default row height. minimum_size is a ReferenceListProperty of (minimum_width.NumericProperty.uix.0. row_default_height Default minimum size to use for row. default to 0. New in version 1. minimum_width is a kivy. class kivy. padding is a NumericProperty.gridlayout. rows_minimum List of minimum size for each row. the image is centered and fit inside the widget bounding box. use the AsyncImage subclass: aimg = AsyncImage(source=’http://mywebsite.png’) 17.properties. row_force_default If True.0. 1.Widget Image class. the image will not be stretched more than 1:1 pixels. New in version 1. Read Mipmapping for more information. keep_ratio is a BooleanProperty. default to [1. default to False anim_delay Delay of animation if the image is sequenced (like an animated gif). you can do: <FullImage>: canvas: Color: rgb: (1.Image(**kwargs) Bases: kivy. anim_delay is a NumericProperty. see module documentation for more information. Otherwise. color is a ListProperty.For example. disregarding the aspect ratio of the image. a).25 (4 FPS) color Image color.8. norm_image_size Normalized image size within the widget box.pos class kivy. default to . and will preserve the image ratio. If the anim_delay is set to -1. mipmap is a BooleanProperty. g. New in version 1.3. if the box is too tall. allow_stretch is a BooleanProperty. New in version 1.0.0. 1].8. keep_ratio is a BooleanProperty.0. keep_data If true the underlaying _coreimage have to keep the raw image data.7.6. 1) Rectangle: texture: self. 1.image. default to True mipmap Indicate if you want OpenGL mipmapping to be applied on the texture.0. default to False keep_ratio If False along with allow_stretch being True. image_ratio is a AliasProperty.uix. if you want your image to take the same size of your widget. in the format (r.uix. allow_stretch If True. you can do: class FullImage(Image): pass And in your kivy language file. and is read-only. 277 . default to False. Otherwise. This size will always be fit to the widget size. if the box is too tall. the normalized image size will be maximized to fit in the image box. and is read-only. the image will not be stretched more than 1:1 pixels. This attribute can be used to ‘tint’ an image. the animation will be stopped. New in version 1. norm_image_size is a AliasProperty. if the source image is not gray/white. b. New in version 1.size pos: self.7. Be careful.0.widget. Useful to perform pixel based collision detection New in version 1. 1. the color will not really work as expected. image_ratio Ratio of the image (width / float(height).texture size: self.0. the normalized image size will be maximized to fit in the image box. This facilitates re-loading of image from disk in case contents change. Warning: The texture size is set after the texture property.image. world in blue 278 . font_size=’20sp’) 17. Use self. class kivy. You can change the style of the text using Text Markup. See module documentation for more information.15. The syntax is near the bbcode syntax. but only the inline styling is allowed: # hello world with world in bold l = Label(text=’Hello [b]World[/b]’.reload() Reload image from disk. the value will be a Texture or TextureRegion object.3. Usage: im = Image(source = ’1. the property texture_size will not be up-to-date.do something -im.1 Markup text New in version 1.15 Label The Label widget is for rendering text. texture is a ObjectProperty. So if you listen on the change to texture. It supports ascii and unicode strings: # hello world text l = Label(text=’Hello world’) # unicode text. default to None.0. markup=True) # hello in red.size instead. 17. can only display glyphs that are available in the font l = Label(text=u’Hello world ’ + unichr(2764)) # multiline text l = Label(text=’Multi\nLine’) # size l = Label(text=’Hello world’.1. default to None.image. source is a StringProperty.uix.texture. texture Texture object of the image.jpg’) # -.uix.reload() # image will be re-loaded from disk source Filename / source of your image.Image Asynchronous Image class. New in version 1. Depending of the texture creation. texture_size Texture size of the image.0.AsyncImage(**kwargs) Bases: kivy. You can get the position of your anchor within the text with Label. markup=True) The following tags are available: [b][/b] Activate bold text [i][/i] Activate italic text [font=<str>][/font] Change the font [size=<integer>][/size] Change the font size [color=#<color>][/color] Change the text color [ref=<str>][/ref] Add an interactive zone.World&bt.Widget Label class. we are creating a reference on the word “World”. Then you can write: "[size=24]Hello &bl.l = Label(text=’[color=ff3333]Hello[/color][color=3333ff]World[/color]’.anchors If you want to render the markup text with a character [ or ] or &. -> &.escape_markup(): text = ’This is an important message [1]’ l = Label(text=’[b]’ + escape_markup(text) + ’[/b]’. value): print ’User clicked on’. markup=True) widget. the function print_it will be called with the name of the reference: def print_it(instance.15. you could add a color for the reference. and to react.bind(on_ref_press=print_it) For a better rendering.2 Interactive Zone in Text New in version 1.refs [anchor=<str>] Put an anchor in the text. You can now have definable “links” using text markup. Events on_ref_press Fired when the user clicks on a word referenced with a [ref] tag in a text markup.label.[/size]" 17.0. -> &br.utils. markup = True) If you need to escape the markup from the current text. When a click happens on it. 279 . value widget = Label(text=’Hello [ref=world]World[/ref]’. you need to escape them. The reference + bounding box inside the reference will be available in Label. see module documentation for more information. In this example. We created a simple syntax: [ ] & -> &bl.uix.Label(**kwargs) Bases: kivy.uix. use kivy. Replace the text= in the previous example with: ’Hello [ref=world][color=0000ff]World[/color][/ref]’ class kivy.1. The tag [ref=xxx] is used for that. The idea is to be able to detect when the user clicks on part of the text.widget. The solution is to use a font that has the glyphs you need to display. 1]. Available options are : left. The path can be absolute or relative. halign Horizontal alignment of the text. font_name Filename of the font to use. to display freesans. default to ‘DroidSans’. default to [1. the bold attribute may have no impact on your text rendering. However.0. b. You need markup set to True. If the font used lacks the glyphs for the particular language/symbols you are using.ttf that has the glyph. Relative paths are resolved by the resource_find() function. center and right. 16)} Note: This is working only with markup text. font_size Font size of the text. You probably want to bind the size of the Label to the texture_size or set a text_size. markup=True) >>> widget. Position of all the [anchor=xxx] markup put into the text.anchors {"content": (20. the font file can be ignored. 1. For example. font_size is a NumericProperty. g. font_name is a StringProperty. You can put anchors in your markup text: text = """ [anchor=title1][size=24]This is my Big title. bold Indicates use of the bold version of your font. Warning: Depending of your text provider. Warning: This doesn’t change the position of the text texture of the Label (centered). default to ‘left’. use a font such as 280 . all the [anchor=] references will be removed. bold is a BooleanProperty. "title1": (20. Note: Depending of your font. you can mostly use this without trouble. you will see ‘[]’ blank box characters instead of the actual glyphs. in the format (r. default to False color Text color. 32).1.texture_update() >>> widget. only the position of the text in this texture. in pixels. halign is a OptionProperty. and you’ll get all the anchor positions in this property (only after rendering): >>> widget = Label(text=text.[/size] [anchor=content]Hello world """ Then.anchors New in version 1. a) color is a ListProperty. default to 12dp. 1. . You need markup set to True. y2). New in version 1. italic is a BooleanProperty. the text will be rendered with MarkupLabel: you can change the style of the text using tags. value): print ’User click on’. value widget = Label(text=’Hello [ref=world]World[/ref]’. You can bind a ref event like this: def print_it(instance. padding_x Horizontal padding of the text inside the widget box. 0. Read Mipmapping for more information. Note: Depending of your font.1. padding_x is a NumericProperty. 16).7.italic Indicates use of the italic version of your font. and dispatching an on_ref_press event.0. If true. automatically doing the collision with the touch. only after rendering. x2. List of [ref=xxx] markup put into the text. markup is a BooleanProperty. For example. default to False markup New in version 1. 78. )} You know that the reference “hello” have a bounding box set at (x1. padding_y) properties. padding_x is a NumericProperty.1. padding Padding of the text in the format (padding_x. markup=True) widget. default to 0 padding_y Vertical padding of the text inside the widget box. default to 0 refs New in version 1. mipmap is a BooleanProperty. mipmap Indicates OpenGL mipmapping applied to texture or not. default to False.0. y1. if you wrote: Check out my [ref=hello]link[/hello] The refs will be set with: {’hello’: ((64. the italic attribute may have no impact on your text rendering. padding_y) padding is a ReferenceListProperty of (padding_x.on_ref_press(print_it) Note: This is working only with markup text. default to False. Setting this to True without an appropriately set text_size will lead to unexpected results. with the bounding box of all the words contained in a ref. Check Text Markup documentation for more information. 281 . The current Label implementation uses these references if they exist in your markup text.0. shorten Indicates whether the label should attempt to shorten its textual contents as much as possible if a text_size is given. New in version 1. the label is not constrained to any bounding box.texture is not updated yet l. you have to call the texture_update() method before accessing texture: l = Label(text=’Hello world’) # l. For example.update_texture() # l. use: widget = Label(text=u’My unicode string’) text a StringProperty. text_size By default. You can use this texture for any graphics elements. You can set the size constraint of the label with this property.) text_size is a ListProperty. The OpenGL texture created in this operation is stored in this property. texture_update(*largs) Force texture recreation with the current Label properties. if you want the label to be created in a box with width=200 and unlimited height: Label(text=’Very big big line’. texture is a ObjectProperty.texture is good l. None)) Note: This text_size property is the same as usersize property in Label class. default to None. text Text of the label. Warning: The texture_size is set after the texture property. text_size=(200.font_size = ’50sp’ # l. meaning no size restriction by default. After this function call. Warning: The texture update is scheduled for the next frame. texture_size Texture size of the text. Depending on the texture creation. default to False. the texture and texture_size will be updated in this order. If you need the texture immediately after changing a property. Creation of a simple hello world: widget = Label(text=’Hello world’) If you want to create the widget with an unicode string. texture Texture object of the text.texture is good now.4. (It is named size= in constructor. texture_size will not be up-to-date in your callback. None). Bind to texture_size instead.shorten is a BooleanProperty. The text is rendered automatically when a property changes.0. whatever your current widget size is. default to (None. If you listen for changes to texture. the value will be a Texture or TextureRegion object. 282 . size_hint = (0.layout.4.widget.1: reposition_child internal method (made public by mistake) have been removed.uix.width = 250 Changed in version 1. don’t call this function directly.uix. 283 .Layout(**kwargs) Bases: kivy. do: widget. set the value to None. do_layout(*largs) This function is called when a layout is needed.stacklayout. valign is a OptionProperty.16.BoxLayout • Float layout : kivy. 1.size_hint = (None. 0. used to implement every layout.StackLayout 17.FloatLayout • Grid layout : kivy.uix. by a trigger. 17. The Layout class itself cannot be used directly.floatlayout. You probably want to bind the size of the Label to the texture_size or set a text_size.gridlayout. It indicate the size relatively to the layout size.5 is 50%.AnchorLayout • Box layout : kivy. For example. height_percent) The percent is specified as a floating point number in the range 0-1.size_hint = (width_percent.Widget Layout interface class. middle and top. See module documentation for more information. only the position of the text in this texture. If you are doing a new Layout subclass.boxlayout.uix. to make a widget that is 250px wide and 30% of the parent’s height.uix. use _trigger_layout() instead.16 Layout Layouts are used to calculate and assign widget positions. New in version 1.uix.GridLayout • Stack layout : kivy. Warning: This doesn’t change the position of the text texture of the Label (centered).valign Vertical alignment of the text. instead of absolutely (in pixels/points/cm/etc). 1 is 100%. you would do: widget.3) widget.0) If you don’t want to use size_hint for one of width or height. default to ‘bottom’. The format is: widget. class kivy.0.8. Available options are : bottom.anchorlayout. You must use one of: • Anchor layout : kivy. For example.uix. 0.1 Understanding size_hint Property in Widget The size_hint is a tupple of values used by layouts to manage the size of their children. If you want a widget’s width to be half of the parent’s width and the height to be identical to parent’s height.5. If you don’t want your view to be fullscreen. any click outside the view will dismiss it. use ModalView.4. The ModalView widget is used to create modal views.dismiss() The ModalView. you can prevent the view from closing by explictly returning True from your callback def my_callback(instance): print ’ModalView’. ModalView. Remember that the default size of a Widget is size_hint=(1. and on_dismiss when it is closed.dismiss() are bindable.dismiss(): ModalView. 400)) view. e.open() class kivy.add_widget(Label(text=’Hello world’)) view.modalview. By default.17 ModalView New in version 1.bind(on_press=view.2 ModalView Events There are two events available: on_open when the view is opening. 1).add_widget(content) # bind the on_press event of the button to the dismiss function content.anchorlayout.open() 17.17. ’is being dismissed. Events 284 .g. deactivate the size_hint and use a specific size attribute.0.17.ModalView(**kwargs) Bases: kivy..17.AnchorLayout ModalView class. but is prevented!’ return True view = ModalView() view.uix. to a button’s on_press # create content and assign to the view content = Button(text=’Close me!’) view = ModalView(auto_dismiss=False) view.add_widget(Label(text=’Hello world’)) By default.1 Examples Example of a simple 400x400 Hello world view: view = ModalView(size_hint=(None.dismiss) # open the view view.auto_dismiss to False: view = ModalView(auto_dismiss=False) view. you can set To manually dismiss/close the view. 17.open() If you don’t want that. See module documentation for more information.bind(on_dismiss=my_callback) view. That means you can directly bind the function to an action. instance.uix. For on_dismiss. None).open() and ModalView. the view will cover the whole “parent” window.add_widget(Label(text=’Hello world’)) view. size=(400. auto_dismiss Default to True.on_open: Fired when the ModalView is opened on_dismiss: Fired when the ModalView is closed.. right. it will attach to the nearest window. If you don’t want animation. If the widget is not attached to any window. whatever the on_dismiss event returns. 0.) view. 16. use: view. default to None. the dismiss will be canceled. attach_to If a widget is set on attach_to. border Border used for BorderImage graphics instruction. Can be used when using custom background. bottom. . background_color is a ListProperty. If you really want to close the view. border is a ListProperty.dismiss(animation=False) open(*largs) Show the view window from the attach_to widget. default to [0. the view will attach to the nearest parent window of the widget. this property determines if the view is automatically dismissed when the user clicks outside it. 16) dismiss(*largs. a). Read the BorderImage instructions for more information about how to use it. auto_dismiss is a BooleanProperty. b. default to True. the view will attach to the global Window. you can do this: view = ModalView(. left). default to (16. If set. **kwargs) Close the view if it is open. 16. attach_to is a ObjectProperty. default to ‘atlas://data/images/defaulttheme/modalviewbackground’ background_color Background color. in the format (r. before removal from the parent. background Background image of the view used for the view background. it will be faded out. Used for background_normal and background_down. If the callback returns True. g. If none is found.dismiss(force=True) When the view is dismissed. it will attach to the main/global Window. 285 . It must be a list of four values: (top. background is an StringProperty..7]. 0. If you don’t want your popup to be fullscreen. The Popup offers a default layout with a title and a separation bar. content=Label(text=’Hello world’).. the popup will cover the whole “parent” window.open() To manually dismiss/close the popup. By default.g. The Popup widget is used to create modal popups. you can set popup = Popup(title=’Test popup’. 17.title and a Popup. auto_dismiss=False) popup. 400)) By default.18 Popup New in version 1. 1). size_hint=(None.dismiss() The Popup. None). When you are creating a popup.content widget. That means you can directly bind the function to an action. you must at a minimum set a Popup.1 Examples Example of a simple 400x400 Hello world popup: popup = Popup(title=’Test popup’. to a button’s on_press: # create content and assign to the popup content = Button(text=’Close me!’) popup = Popup(content=content.0. any click outside the popup will dismiss it.open() and Popup.0: The Popup class now inherits from ModalView.dismiss() are bindable. Popup.17. use Popup. auto_dismiss=False) # bind the on_press event of the button to the dismiss function 286 . e.18. content=Label(text=’Hello world’).dismiss(): popup.auto_dismiss to False: If you don’t want that. deactivate the size_hint and use a specific size attribute. size=(400.4. Remember that the default size of a Widget is size_hint=(1.7. Changed in version 1. 1.bind(on_press=popup. fired when multiple content are added to the popup. you can prevent the popup from closing by explictly returning True from your callback: def my_callback(instance): print ’Popup’.bind(on_dismiss=my_callback) popup. content is a ObjectProperty.modalview.19 Progress Bar New in version 1.0...Popup(**kwargs) Bases: kivy.18.8. Events on_open: Fired when the Popup is opened on_dismiss: Fired when the Popup is closed.popup. separator_height is a 17.uix.open() 17. New in version 1. NumericProperty. If the callback returns True. background_color is a ListProperty. For on_dismiss. but is prevented!’ return True popup = Popup(content=Label(text=’Hello world’)) popup. title String that represents the title of the popup. 212 / 255.content. title is a StringProperty.. 167 / 255.] separator_height Height of the separator.PopupException Bases: exceptions. default to [47 / 255.1. New in version 1. and on_dismiss when it is closed. default to None. separator_color Color used by the separator between title and content.0.uix. 287 . See module documentation for more information.0. ’is being dismissed.ModalView Popup class. content Content of the popup that is displayed just under the title.4. class kivy.dismiss) # open the popup popup.open() class kivy. 1. default to ‘No title’. instance.popup. New in version 1.0. default to 2dp.Exception Popup exception.uix. the dismiss will be canceled.2 Popup Events There are two events available: on_open when the popup is opening. check FloatLayout. If you want absolute positioning.content. Warning: Since the actual RelativeLayout is a Scatter. value is a NumericProperty. The progress bar has no interactive elements. add a widgets with position = (0. the child widget will also move.Widget Class for creating a Progress bar widget. max is a NumericProperty.children. you need self.value = 750 class kivy. This layout allows you to set relative coordinate for children. max=100) >>> pb.The ProgressBar widget is used to visualize progress of some task.0). 288 . The child widgets coordiantes remain (0. instead of self. its add_widget and remove_widget functions are overwritten to add children to the embedded FloatLayout (accessible as content property of RelativeLayout) automatically.progressbar import ProgressBar pb = ProgressBar(max=1000) # this will update the graphics automatically (75% done): pb.value 50 >>> slider. To use it. value_normalized Normalized value inside the 0-max to 0-1 range: >>> pb = ProgressBar(value=50. Only horizontal mode is supported. The RelativeLayout class behaves just like the regular Float Layout. simply assign a value to indicate the current progress: from kivy. value Current value used for the slider. 17. if you create a RelativeLayout. default to 100. i.uix.ProgressBar(**kwargs) Bases: kivy..uix.progressbar. For example.0).children.4. So if you want to access the added child elements. when you change the position of the RelativeLayout.widget.note: The :class:‘RelativeLayout‘ is implemented as a :class‘FloatLayout‘ inside a :class:‘Scatter‘.5 value_normalized is an AliasProperty. It is a display-only widget. default to 0.e. except that its child widgets are positioned relative to the layout. . max Maximum value allowed for value. they are relative to the containing layout.value_normalized 0.20 Relative Layout New in version 1. vertical mode is not available yet. See module documentation for more details.uix.0. and there are some advantages / constraints that you should consider: 1. do_scale=False. do_translation_y=False) 289 . It is a container only. to_local().21 Scatter Scatter is used to build interactive widgets that can be translated. 17.) 3. without changing them. not size. 0. 17.uix.scatter. and the previous matrix is restored when the drawing is finished. all interactions are enabled.21. The scatter position has no impact of the position of children. For touch events.add_widget(image) 17. see module documentation for more information. the widget does not have a graphical representation. That specific behavior makes the scatter unique.class kivy. use scale.jpg’) scatter. The children are positionned relative to 0. you will need to use to_parent().21. Scatter has its own matrix transformation: the modelview matrix is changed before the child is drawn.RelativeLayout(**kw) Bases: kivy. You can selectively disable them using the do_{rotation. rotated and scaled with two or more fingers on a multitouch system. do_scale=False) Allow only translation on x axis: scatter = Scatter(do_rotation=False.2 Control Interactions By default. You must take care of size of children yourself.Scatter RelativeLayout class. 2. This applies to the size too. (read #1. the scatter converts from the parent matrix to the scatter matrix automatically in on_touch_down/move/up events. The scatter is not a layout. The idea is to combine Scatter with another widget. translation. That makes possible the rotation / scale / translation of the entire children tree.uix. If you are doing things manually. Disable rotation: scatter = Scatter(do_rotation=False) Allow only translation: scatter = Scatter(do_rotation=False.relativelayout.1 Usage By default. If you want to resize the scatter. for example Image: scatter = Scatter() image = Image(source=’sun. scale} properties. 0. and be able to touch them.uix. the scatter widget will be removed and readded to the parent when it is touched (brought to front. post_multiply=False. See module documentation for more information.5 Behaviors Changed in version 1. Transformation to be applied to the scatter widget anchor: tuple.0: If no control interactions are enabled. bbox Bounding box of the widget in parent space: ((x.Scatter(**kwargs) Bases: kivy. default to False If true the transform matrix is post multiplied (as if applied before the current transform) auto_bring_to_front If True. Generally.3 Automatic Bring to Front If the Scatter. then touch handler will never return True. This is useful when you are manipulating several scatter widgets and don’t want the active one to be partially hidden.99506983235e+19 (2^66).uix.Widget Scatter class.17. You can put children outside the bounding box of the scatter. h)) # x. scale_max=3. but the maximum scale is 9. You cannot do infinite scale down/up with our implementation. Parameters trans: transformation matrix from transformation lib. above all other widgets in the parent).21. you don’t hit the minimum scale (because you don’t see it on the screen). You can also limit the minimum and maximum scale allowed: scatter = Scatter(scale_min=.auto_bring_to_front property is True.) 17. 0) The point to use as the origin of the transformation (uses local widget space) post_multiply: bool. anchor=(0. do_collide_after_children If True.5. apply_transform(trans. 17. class kivy.1. 0)) Transforms scatter by trans (on top of its current transformation state).21.21. y = lower left corner bbox is a AliasProperty. default to (0. auto_bring_to_front is a BooleanProperty.scatter. New in version 1. 290 .3. the collision detection for limiting the touch inside the scatter will be done after dispaching the touch to the children. That means we have a limit for scaling.4 Scale Limitation We are using a 32-bit matrix in double representation. (w. y). the widget will be automatically pushed on the top of parent widget list for drawing.widget. default to True. 0. default to 0.4. scale Scale value of the scatter. Warning: This widget is still experimental. scale_max is a NumericProperty. and its API is subject to change in a future vers 291 . default to True. rotation Rotation value of the scatter. do_rotation is a BooleanProperty.01 transform Transformation matrix.Scatter This is essentially an unbounded Scatter widget.uix.scatter. default to 1e20 scale_min Minimum scaling factor allowed. do_translation_y Allow translation on Y axis.uix. default to True. do_scale Allow scaling. default to the identity matrix.do_rotation Allow rotation.22 Screen Manager New in version 1. transform_inv is a ObjectProperty. transform_inv Inverse of the transformation matrix.scatter. transform is a ObjectProperty. scale_min is a NumericProperty. do_translation Allow translation on X or Y axis. default to True. rotation is a AliasProperty.ScatterPlane(**kwargs) Bases: kivy. scale is a AliasProperty. class kivy. do_translation is a AliasProperty of (do_translation_x + do_translation_y) do_translation_x Allow translation on X axis do_translation_x is a BooleanProperty. convenience class to make easier the writting of infinite planes 17. do_translation_y is a BooleanProperty. scale_max Maximum scaling factor allowed. default to the identity matrix. default to True. do_scale is a BooleanProperty. or even do fancy animation using custom shaders. and a ‘Setting Screen’: from kivy. based of moving the screen coordinate / scale.lang import Builder from kivy.screenmanager import ScreenManager.current = ’menu’ """) # Declare both screen 292 .app import App from kivy. sm. Here is an example with a ‘Menu Screen’. a Screen display nothing.current = ’Title 2’ Please note that by default. 17. Screen # Create the manager sm = ScreenManager() # Add few screens for i in xrange(4): screen = Screen(name=’Title %d’ % i) sm.add_widget(screen) # By default.manager.uix.uix. Builder.manager.1 Basic Usage Let’s construct a Screen Manager with 4 named screen. Best way is to subclass. Multiple transitions are supported.The screen manager is a widget dedicated to manage multiple screens on your application. You need to use that class as a root widget for your own screen. it’s just a RelativeLayout. The default ScreenManager displays only one Screen at time. the first screen added into the ScreenManager will be # displayed. you absolutely need to give a name to it: from kivy. When you are creating screen. you can change to another screen: # Let’s display the screen named ’Title 2’ # The transition will be automatically used. Please note the root.current: this is how you # can control the ScreenManager from kv. and use a TransitionBase to switch from one to another Screen.load_string(""" <MenuScreen>: BoxLayout: Button: text: ’Goto settings’ on_press: root.22.screenmanager import ScreenManager. Then. Screen # Create both screen.current = ’settings’ Button: text: ’Quit’ <SettingsScreen>: BoxLayout: Button: text: ’My setting button’ Button: text: ’Back to menu’ on_press: root. Each screen have by default a # property manager that give you the instance of the ScreenManager used.manager. 2 Changing transition You have multiple transition available by default. manager is a ObjectProperty.uix. class kivy. from any direction • SwapTransition . This is a know issue.implementation of the iOS swap transition • FadeTransition . it’s normal. default to ‘’ transition_progress Value that represent the completion of the current transition.relativelayout.add_widget(SettingsScreen(name=’settings’)) class TestApp(App): def build(self): return sm if __name__ == ’__main__’: TestApp(). default to None.class MenuScreen(Screen): pass class SettingsScreen(Screen): pass # Create the screen manager sm = ScreenManager() sm. This is because we are using FBO. manager Screen manager object. 293 .transition property: sm = ScreenManager(transition=FadeTransition()) Note: Currently.RelativeLayout Screen is an element intented to be used within ScreenManager.screenmanager. name Name of the screen. and don’t have any logic to do supersampling on them. read-only. if you see sharped-text during the animation. such as: • SlideTransition .shader to wipe from right to left the screens You can easily switch to a new transition by changing the ScreenManager. if any is occuring. set when the screen is added within a manager.slide screen in/out.uix. and working to have a transparent implementation that will give the same result as it would be rendered on the screen. To be more concrete.current name is a StringProperty.Screen(**kw) Bases: kivy.22.shader to fade in/out the screens • WipeTransition . This is the name used for ScreenManager. must be unique within a ScreenManager. Check module documentation for more information.add_widget(MenuScreen(name=’menu’)) sm.run() 17. all Shader based Transition doesn’t have any anti-aliasing. and the screen that will be showed. current Name of the screen currently show. 294 .If a transition is going on.current = ’second’ current_screen Contain the current displayed screen. class kivy. screen_names List of the names of all the Screen widgets added. You must not change this property manually. By default.uix. use current instead. Screen sm = ScreenManager() sm. previous() Return the name of the previous screen from the screen list. This is the main class that will control your Screen stack. it is read-only and updated if the screen list changes.screenmanager import ScreenManager. check the transition_state transition_progress is a NumericProperty. an instance of SwapTransition will be given. read-only. get_screen(name) Return the screen widget associated to the name. next() Return the name of the next screen from the screen list.floatlayout. screens_names is a AliasProperty. the manager will show only one screen at time. If you want to know if it’s an entering or leaving animation. default to None. The list is read only. or the screen to show. screens List of all the Screen widgets added.FloatLayout Screen manager. You must not change the list manually. or the name of a screen changes.add_widget(Screen(name=’first’)) sm. the state will stay on the last one (in or out).ScreenManager(**kwargs) Bases: kivy. default to []. Screen. or None if not found.add_widget() instead. default to ‘out’.screenmanager. Use screens is a ListProperty. If you want to show # another one. transition Transition object to use for animate the screen that will be hidden. and memory. transition_state is an OptionProperty. the first added screen will be showed.add_widget(Screen(name=’second’)) # by default. transition_state Value that represent the state of the transition: •‘in’ if the transition is going to show your screen •‘out’ if the transition is going to hide your screen After the transition is done. whatever is the mode.uix. default to 0. read-only. just set the current string: sm.uix. from kivy. current_screen is an ObjectProperty. the value will got from 0 to 1. By default. screenmanager. just set the current string: sm. By default. Events on_progress: Transition object.7 (= 700ms) is_active Indicate if the transition is currently active is_active is a BooleanProperty.For example. this class doesn’t any assign fragment/vertex shader. If you want to create your own fragment shader 295 . screen_out Property that contain the screen to hide.uix.current = ’second’ class kivy.ShaderTransition(**kw) Bases: kivy.screenmanager import ScreenManager. read-only. start(manager) (internal) Start the transition.TransitionBase(**kw) Bases: kivy.uix. Automatically set by the ScreenManager. stop() (internal) Stop the transition. default to . manager Screen manager object. the first added screen will be showed. default to None. This is automatically called by the ScreenManager. add_screen(screen) (internal) Used to add a screen into the ScreenManager duration Duration in seconds of the transition.uix. remove_screen(screen) (internal) Used to remove a screen into the ScreenManager screen_in Property that contain the screen to show. default to False.screenmanager.screenmanager. This is automatically called by the ScreenManager. manager is a ObjectProperty. default to None. If you want to show another one.add_widget(Screen(name=’first’)) sm. like SlideTransition. Automatically set by the ScreenManager. set when the screen is added within a manager. default to None. Screen. WipeTransition sm = ScreenManager(transition=WipeTransition()) sm. if you want to change to a WipeTransition: from kivy. class kivy. duration is a NumericProperty. SwapTransition. screen_out is a ObjectProperty. progression float Fired during the animation of the transition on_complete: Transition object Fired when the transition is fininshed. read-only.event.uix.TransitionBase Transition class that use a Shader for animating the transition between 2 screens. This class act as a base for others implementation.add_widget(Screen(name=’second’)) # by default.EventDispatcher Transition class is used to animate 2 screens within the ScreenManager. screen_in is a ObjectProperty. default to left. Can be one of ‘left’. ‘up’ or ‘down’. uniform sampler2D tex_in. you need to declare the header yourself. right.screenmanager. This is shader implement a "fading" # transition. when a new window appear on the screen. direction Direction of the transition. can be used to show a new screen from any direction: left. default to None. up or down.23 Scroll View New in version 1.ShaderTransition Fade transition. fs is a StringProperty.for transition. and include the “t”.uix. } """ # And create your transition tr = ShaderTransition(fs=fs) sm = ScreenManager(transition=tr) fs Fragment shader to use.0.4. fs = """$HEADER uniform float t.FadeTransition(**kw) Bases: kivy.SwapTransition(**kw) Bases: kivy. class kivy.WipeTransition(**kw) Bases: kivy. 296 .screenmanager.uix. “tex_in” and “tex_out” uniform: # Create your own transition. direction is an OptionProperty. vs Vertex shader to use. default to None.screenmanager. tex_coord0). that look like iOS transition.TransitionBase Swap transition. vec4 cout = texture2D(tex_out.SlideTransition(**kw) Bases: kivy.screenmanager. class kivy. based on a fragment Shader. class kivy. ‘right’. t). vs is a StringProperty.uix.screenmanager. The ScrollView widget provides a scrollable/pannable viewport that is clipped at the scrollview’s bounding box.screenmanager.TransitionBase Slide Transition.screenmanager. cin.uix.uix. void main(void) { vec4 cin = texture2D(tex_in. tex_coord0).screenmanager.uix.uix. class kivy. based on a fragment Shader. 17.ShaderTransition Wipe transition. uniform sampler2D tex_out.uix. gl_FragColor = mix(cout. size_hint property to get the desired scroll/pan effect. it is recognized as a scrolling gesture and translatation (scroll/pan) will begin. 400)) root. and applies a viewport/window to it according to the scroll_x and scroll_y properties.scroll_timeout a maximum time period. In your configuration file.1 Scrolling Behavior ScrollView accepts only one child.StencilView ScrollView class. so the content size will fit your ScrollView exactly (you will have nothing to scroll). default). these properties are used: • ScrollView. size_hint_y=None) #Make sure the height is such that there is something to scroll.23.ScrollView(**kwargs) Bases: kivy. 1).8. By default. New in version 1.17. You must carefully specify the ScrollView.23.uix.scroll_distance a minimum distance to travel. and set the size_hint_y property to None: layout = GridLayout(cols=1.stencilview.uix. size_hint is (1. If a touch travels scroll_distance pixels within the scroll_timeout period. To scroll a GridLayout on Y-axis/vertically. default to 250 milliseconds.0. spacing=10. layout.2 Limiting to X or Y Axis By default.1.4 Controlling Timeout.add_widget(layout) 17. the touch down event is dispatched to the child instead (no translation). size=(400. If the timeout occurs. you can set: [widgets] scroll_timeout = 150 class kivy. None). ScrollView allows scrolling in both the X and Y axes. Distance and Trigger New in version 1.23. height=40) layout.23. default to 20 pixels. To determine if interaction is a scrolling gesture. 17. size_hint_y=None.you cannot do both at the same time. set the child’s width identical to that of the ScrollView (size_hint_x=1.setter(’height’)) for i in range(30): btn = Button(text=str(i). • ScrollView. not the size.3 Managing the Content Size ScrollView manages the position of the child content.bind(minimum_height=layout. 297 .add_widget(btn) root = ScrollView(size_hint=(None. If you want to reduce the default timeout. you can some default values for this widget: [widgets] scroll_timeout = 250 scroll_distance = 20 scroll_friction = 1. See module documentation for more information.1. Touches are analyzed to determine if the user wants to scroll or control the child in some other manner . You can explicitly disable scrolling on an axis by setting ScrollView. 17.do_scroll_y to False.do_scroll_x or ScrollView.scrollview. You must deactivate at least one of the size_hint instructions (x or y) of the child to enable scrolling. 0. . auto_scroll is a BooleanProperty. default to 20 (pixels). do_scroll_x is a BooleanProperty. default to [. New in version 1.0. If you don’t want that behavior. do_scroll_y is a BooleanProperty.0. .7. do_scroll_y Allow scroll on Y axis.auto_scroll Automatic scrolling is the movement activated after a swipe. vbar is a AliasProperty. As soon as the distance has been traveled. default to True bar_color Color of horizontal / vertical scroll bar. bar_margin Margin between the bottom / right side of the scrollview when drawing the horizontal / vertical scroll bar. scroll_friction Friction is a factor for reducing the scrolling when the list is not moved by a touch. default to 0 bar_width Width of the horizontal / vertical scroll bar. bar_width is a NumericProperty. The speed is reducing from this equation: 2 ^ (t * f) # t is the time from the touch up # f is the friction 298 .9]. bar_margin is a NumericProperty. The position and size are normalized between 0-1. default to True. scroll_distance is a NumericProperty. do_scroll is a AliasProperty of (do_scroll_x + do_scroll_y) do_scroll_x Allow scroll on X axis. size) of the horizontal scrolling bar. according to the default value in user configuration.7. in pixels. default to True. The result will be a tuple of scroll distance that can be added to scroll_x and scroll_y do_scroll Allow scroll on X or Y axis. New in version 1. When you do a swipe. default to 2 convert_distance_to_scroll(dx. scroll_distance Distance to move before scrolling the ScrollView.0.2. the movement speed is calculated.2. the ScrollView will start to scroll. This property is used internally for drawing the little horizontal bar when you’re scrolling. readonly. When you release a touch. depending on the content size and the scrollview size. New in version 1. The width is interpreted as a height for the horizontal bar.2. hbar Return a tuple of (position. It is advisable that you base this value on the dpi of your target device’s screen. dy) Convert a distance in pixels to a scroll distance. New in version 1. in RGBA format. and is used to move the list automatically when touch up happens. according to the lastest touch movement. and no touch event will go to children. and represent a percentage of the current scrollview height.7. bar_color is a ListProperty.2. it will start to move the list. just set the auto_scroll to False. . size) of the vertical scrolling bar. This is to prevent autoscroll to trigger while the user has slowed down on purpose to prevent this. the content’s right side will touch the right side. scroll_stoptime is a NumericProperty. scroll_x X scrolling value. If the user has not moved scroll_distance within the timeout. scroll_timeout Timeout allowed to trigger the scroll_distance. scroll_moves is a NumericProperty. This property is controled by ScrollView only if do_scroll_x is True. pos or size properties change. Changed in version 1.5. the scrolling will be disabled. scroll_x is a NumericProperty. and represent a percentage of the current scrollview height. readonly. If 1. and the touch event will go to the children. default to 1. the content’s top side will touch the top side. This property is used internally for drawing the little vertical bar when you’re scrolling. The moves property specifies the amount of previous scrollmoves that should be taken into consideration when calculating the automatic scrolling speed. between 0 and 1. If 1. This property is controled by ScrollView only if do_scroll_y is True. New in version 1. according to the default value in user configuration. according to current value of scroll_x and scroll_y. default to 0. If 0. the list movement will stop faster. scroll_y. If you set to a bigger value. according to the default value in user configuration. the content’s left side will touch the left side of the ScrollView. If 0.By default.0: Default value changed from 250 to 55. scroll_stoptime Time after which user input not moving will disable autoscroll for that move. the friction factor is 1. default to 300 (milliseconds) New in version 1. scroll_moves The speed of automatic scrolling is based on previous touch moves.0. default to 55 (milliseconds). update_from_scroll(*largs) Force the reposition of the content.5.0. scroll_timeout is a NumericProperty. If you set the friction to 0. New in version 1. If the user has not moved within the stoptime. or if the size of the content changes. in milliseconds. vbar Return a tuple of (position. scroll_y is a NumericProperty. default to 1. It will reduce the speed by a factor of 2 each second. the list speed will never stop. 299 . default to 5.0. scroll_friction is a NumericProperty. autoscroll will not start. This method is automatically called when one of the scroll_x.2. vbar is a AliasProperty. between 0 and 1. scroll_y Y scrolling value.5. The position and size are normalized between 0-1. the content’s bottom side will touch the bottom side of the ScrollView. This is to prevent accidental slowing down by the user at the end of the swipe to slow down the automatic scrolling. config. 17. you need two things: • a ConfigParser instance with default values • a JSON file Warning: The kivy.title property is used by Settings when a panel is added . The SettingsPanel. This module is a complete and extensible framework for building a Settings interface in your application..7. SettingsPanel represents a group of configurable options. You cannot use the default ConfigParser from Python libraries. 300 . and you’re done! Settings are also integrated with the App class.24. The interface consists of a sidebar with a list of panels (on the left) and the selected panel (right).24 Settings New in version 1. Use Settings.it determines the name of the sidebar button.1 Create panel from JSON To create a panel from a JSON-file. SettingsPanel controls a ConfigParser instance..ConfigParser is required. The panel can be automatically constructed from a JSON definition file: you describe the settings you want and corresponding sections/keys in the ConfigParser instance.0.17.add_kivy_panel() to configure the Kivy core settings in a panel. . config.title property to “Windows”. value Fired tion/key/value of a ConfigParser changes on_close Fired when the Close-button is pressed.read(’myconfig..0) In the JSON example above.e. Here is an example: [ { "type": "title". config. key. It will automatically instantiate SettingsPanel and add it to Settings: from kivy. Make sure you have default values for all sections/keys in your JSON file! The JSON file contains structured information to describe the available settings.You must create and handle the ConfigParser object.Settings(**kwargs) Bases: kivy.other keys are assigned to corresponding properties of that class. i. Check module documentation for more information on how to use this class. To load the JSON example to a Settings instance.json’) s.1. Type title bool numeric options string path Associated class SettingTitle SettingBoolean SettingNumeric SettingOptions SettingString SettingPath (new from 1.add_json_panel() method. Events on_config_change: ConfigParser instance. { "type": "bool". Only the “type” key is mandatory: an instance of the associated class will be created and used for the setting .ini’) s = Settings() s. "true": "auto" } ] Each element in the root list represents a setting that the user can configure. section. "section": "graphics".uix.json’) # then use the s as a widget. "desc": "Set the window in windowed or fullscreen". when sec- 301 .uix. It will create a new instance of SettingTitle and apply the rest of the key/value pairs to the properties of that class. "key": "fullscreen". use the Settings.add_json_panel(’My custom panel’. “title”: “Windows” sets the SettingTitle. the first element is of type “title”. SettingsPanel will read the values from the associated ConfigParser instance.settings. "title": "Windows" }.add_json_panel(’Another panel’. ’settings_test2. "title": "Fullscreen".BoxLayout Settings UI. class kivy..config import ConfigParser config = ConfigParser() config. ’settings_custom.boxlayout. 5. class kivy.gridlayout. register_type(tp.config. The title will be reused by the Settings in the sidebar. default to None. filename=None. get_value(section. data=None) Create new SettingsPanel. default to None.settings. you might want to adapt this function. unselect() Unselect the current selection if it exists.uix.uix. filename=None.SettingsPanel(**kwargs) Bases: kivy. If you don’t want to use a ConfigParser instance. If it does not exist. menu (internal) Reference to the widget that will contain the sidebar menu.add_json_panel(title. with the JSON definition filename.uix. key) Return the value of the section/key from the config ConfigParser instance. Check the Create panel from JSON section in the documentation for more information about JSON format. selection is a ObjectProperty. menu is a ObjectProperty.uix. config. add_json_panel() for more information. return None. add_kivy_panel() Add a panel for configuring Kivy. cls) Register a new type that can be used in the JSON definition. config. See module documentation for more information. Check the documentation of get_panel_by_uid(uid) Return the panel previously added from his UID.GridLayout This class is used to contruct panel settings.settings. data=None) Create and add a new SettingsPanel using the configuration config. content is a ObjectProperty. create_json_panel(title. class kivy.0. Feel free to include or exclude it in your configuration.SettingItem(**kwargs) Bases: kivy. select(panel) Select a panel previously added on the widget. config A kivy. settings A Settings instance that will be used to fire the on_config_change event.FloatLayout 302 . title Title of the panel. This function is used by SettingItem to get the value for a given section/key. default to None.ConfigParser instance. for use with a Settings instance or subclass. selection (internal) Reference to the selected label in the sidebar. content (internal) Reference to the widget that will contain the panel widget.floatlayout. and the usage of this function. New in version 1. This panel acts directly on the kivy configuration. content is a ObjectProperty. default to None. selected_alpha is a NumericProperty.uix. will open a Popup with a Textinput so the user can enter a custom value. Look at SettingBoolean. This is automatically set.uix. key Key of the token inside the section in the ConfigParser instance. popup (internal) Used to store the current popup when it’s shown 303 . section is a StringProperty. default to None. value is a ObjectProperty. panel (internal) Reference to the SettingsPanel with this setting. It is visualized with a Label widget that. according to the ConfigParser instance.Base class for individual settings (within a panel). disabled Indicate if this setting is disabled. default to None. default to None. any further call to add_widget will call the content. desc Description of the setting.add_widget. selected_alpha (internal) Float value from 0 to 1. key is a StringProperty. desc is a StringProperty. As soon as the content object is set.on_config_change() event. panel is a ObjectProperty. SettingNumeric and SettingOptions for usage example. all touches on the setting item will be discarded.settings. If True. Any change to the value will trigger a Settings. This class cannot be used directly. title is a StringProperty. default to ‘<No title set>’. default to False. default to None. value Value of the token. You don’t need to use it. disabled is a BooleanProperty. title Title of the setting.SettingString(**kwargs) Bases: kivy. used to animate the background when the user touches the item. default to None section Section of the token inside the ConfigParser instance. Events on_release Fired when the item is touched then released content (internal) Reference to the widget that contains the real setting. default to 0. It builds a row with title/description (left) and setting control (right). class kivy.settings. it is used for implementing the other setting classes.SettingItem Implementation of a string setting on top of SettingItem. rendered on the line below title. when clicked. default to ‘<No title set>’. ’yes’]) Warning: You need a minimum of two values. If you use “yes” and “no” in your ConfigParser instance: SettingBoolean(.uix. popup is a ObjectProperty.SettingBoolean(**kwargs) Bases: kivy. when clicked.settings. popup is a ObjectProperty. options List of all availables options. 304 . default to None. and index 1 as True values is a ListProperty. It is visualized with a Label widget that.popup is a ObjectProperty.SettingItem Implementation of a Path setting on top of SettingItem. default to None. default to []. textinput (internal) Used to store the current textinput from the popup. when clicked. default to None. It is visualized with a Switch widget. This must be a list of “string” items.settings.SettingOptions(**kwargs) Bases: kivy. when clicked.settings.uix. It is visualized with a Label widget that.. will open a Popup with a Textinput so the user can enter a custom value.uix. popup (internal) Used to store the current popup when it is shown..SettingPath(**kwargs) Bases: kivy.settings.. values Values used to represent the state of the setting. popup is a ObjectProperty. ‘1’] class kivy.SettingItem Implementation of an option list on top of SettingItem. default to None. and to listen for changes.settings.uix. Otherwise. you can change them by setting values. New in version 1. it will crash.uix.1. default to None. 0 and 1 are used for values.uix.uix. default to [‘0’. class kivy. values=[’no’. class kivy.SettingNumeric(**kwargs) Bases: kivy.0. popup is a ObjectProperty. By default.SettingItem Implementation of a boolean setting on top of SettingItem.uix. the index 0 will be used as False.SettingString Implementation of a numeric setting on top of SettingString. popup (internal) Used to store the current popup when it is shown. :) options is a ListProperty.settings. will open a Popup with a list of options from which the user can select. and to listen for changes. class kivy. will open a Popup with a FileChooserListView so the user can enter a custom value.settings. textinput (internal) Used to store the current textinput from the popup.settings. It is visualized with a Label widget that. uix. padding is 10.slider.Slider(**kwargs) Bases: kivy. max Maximum value allowed for value. To create a slider from -100 to 100 starting at 25: from kivy. padding is a NumericProperty.slider import Slider s = Slider(min=-100. min is a NumericProperty. It prevents the cursor from going out of the bounds of the slider bounding box. max=80) >>> slider. It allows drawing a cursor of 20px width. The padding is used for graphical representation and interaction. range Range of the slider. padding Padding of the slider.range [10. The range of the slider is reduced from padding * 2 on the screen.Widget Class for creating Slider widget. It supports horizontal and vertical orientation. without having the cursor going out of the widget. orientation is an OptionProperty.uix. orientation Orientation of the slider. default to 10.17. By default. max=100. 80] >>> slider. Check module documentation for more details. maximum value): >>> slider = Slider(min=10. default to 100. in the format (minimum value. Can take a value of ‘vertical’ or ‘horizontal’. value=25) To create a vertical slider: from kivy. min Minimum value allowed for value. min/max and a default value.slider import Slider s = Slider(orientation=’vertical’) class kivy.25 Slider The Slider widget looks like a scrollbar. default to ‘horizontal’.uix. default to 0.widget. 100) 305 . max is a NumericProperty.range = (20.uix. max 100 range is a ReferenceListProperty of (min. New in version 1.value value_normalized is an AliasProperty.5 slider.value slider. min=0. value Current value used for the slider. slider.value_normalized slider.value = 1 slider.5 >>> >>> 0 >>> >>> 1 slider = Slider(value=50. default to 1. max) step Step size of the slider. based on the normalized value.max step is a NumericProperty. 306 . default to 0.>>> slider. Determines the size of each interval or step the slider takes between min and max.value = 0 slider. value_pos is an AliasProperty.0.value_normalized = 1.value_normalized = . If the value range can’t be evenly divisible by step the last step will be capped by slider. max=100) slider.value_normalized You can also use it for setting the real value without knowing the minimum and maximum: >>> >>> >>> 100 >>> >>> 200 slider = Slider(min=0.value_normalized slider.value slider.4. max=200) slider.min 20 >>> slider. value_pos Position of the internal cursor. value is a NumericProperty. value_normalized Normalized value inside the range (min/max) to 0-1 range: >>> >>> 50 >>> 0. # available values values=(’Home’.uix. ’have text’.spinner. None). ’Other’.17.uix. 44).base import runTouchApp from kivy.spinner import Spinner spinner = Spinner( # default value showed text=’Home’.button.4. 307 .5}) def show_selected_value(spinner. pos_hint={’center_x’: . Touching the spinner displays a dropdown menu with all other available values. # just for positioning in our example size_hint=(None. text): print ’The spinner’.0. size=(100. In the default state. text spinner.Button Spinner class. from which the user can select a new one.uix. ’Custom’). see module documentation for more information dropdown_cls Class used to display the dropdown list when the Spinner is pressed. is_open By default. a spinner show its currently selected value. ’center_y’: . ’Work’.26 Spinner New in version 1. Example: from kivy.bind(text=show_selected_value) runTouchApp(spinner) class kivy. spinner. the spinner is not open.Spinner(**kwargs) Bases: kivy. dropdown_cls is a ObjectProperty. Spinner is a widget that provide a quick way to select one value from a set.5. default to DropDown. Set to true to open it. New in version 1.Button Special button used in the dropdown list. class kivy. as many as the layout can fit.4.NumericProperty. We just set the default size_hint_y and height. values Values that can be selected by the user. minimum_size Minimum size needed to contain all children. minimum_height Minimum height needed to contain all children.uix. The option class require at least: •one text property where the value will be put •one on_release event that you need to trigger when the option is touched.0. option_cls Class used to display the options within the dropdown list displayed under the Spinner.button.uix. class kivy.8. default to []. option_cls is a ObjectProperty.StackLayout(**kwargs) Bases: kivy.properties.5. minimum_size is a ReferenceListProperty of (minimum_width.0.stacklayout.is_open is a BooleanProperty.SpinnerOption(**kwargs) Bases: kivy. default to False. default to SpinnerOption. New in version 1.0.27 Stack Layout New in version 1. minimum_height) properties. It must be a list of strings. minimum_height is a kivy. 17.layout.8.uix. The text property in the class will represent the value. New in version 1.0. StackLayout arranges children vertically or horizontally.uix. 308 .Layout Stack layout class. See module documentation for more information. default to 0. values is a ListProperty.spinner. in pixels.0.StencilView(**kwargs) Bases: kivy. orientation is an OptionProperty.stencilview.0. New in version 1. It provides an efficient way to clip the drawing area of children. The user can swipe to the left/right to activate/deactivate it: 309 . Only supports ‘lr-tb’ and ‘tb-lr’ at the moment. default to 0.NumericProperty. See module documentation for more information. default to 0. like a mechanical light switch.minimum_width Minimum width needed to contain all children.0.8. The StencilView uses the stencil graphics instructions under the hood.widget.uix. orientation Orientation of the layout.Widget StencilView class. StencilView limits the drawing of child widgets to the StencilView’s bounding box. Any drawing outside the bounding box will be clipped (trashed). Note: As with the stencil graphics instructions. class kivy. padding is a NumericProperty.29 Switch New in version 1.4. spacing Spacing between children. 17. default to ‘lr-tb’. 17. minimum_width is a kivy.7. spacing is a NumericProperty. The Switch widget is active or inactive. tb mean Top to Bottom. default to 0.properties.28 Stencil View New in version 1. Note: lr mean Left to Right.uix. padding Padding between widget box and children. you cannot stack more than 8 stencil-aware widgets. in pixels. it will work. ’is’. instance.bind(active=callback) By default. active is a BooleanProperty. value): print ’the switch’. active Indicate if the switch is active or inactive. active_norm_pos is a NumericProperty. The image is centered within the widget. See module documentation for more information. default to 0. the representation of the widget is static. Note: If you want to control the state with a single touch instead of swipe. default to 0. in the 0-1 range. touch_distance (internal) Contains the distance between the initial position of the touch and the current position to determine if the swipe is from left or right.switch. value switch = Switch() switch. The minimum size required is 83x32 pixels (defined by the background image). active_norm_pos (internal) Contains the normalized position of the movable element inside the switch. default to None.uix. default to False.Widget Switch class.Switch(**kwargs) Bases: kivy. 310 . touch_control is a ObjectProperty. use ToggleButton instead. not just the part with graphics. class kivy.widget.uix.switch = Switch(active=True) To attach a callback that listens to activation state: def callback(instance. touch_distance is a NumericProperty. As long as you swipe over the widget’s bounding box. The entire widget is active. touch_control (internal) Contains the touch that currently interacts with the switch. with a header area for the actual tab buttons and a content area for showing current tab content.floatlayout import FloatLayout kivy. ’center_y’: .17.5.uix. Warning: This widget is still experimental. The TabbedPanel provides one default tab. .uix.5} default_tab_content: set1_content Label: id: set1_content text: ’First tab content area’ BoxLayout: id: set2_content Label: text: ’Second tab content area’ Button: 311 .30 TabbedPanel New in version 1.30.lang import Builder Builder. ’’’ from from from from kivy.app import App kivy.3. and its API is subject to change in a future vers The TabbedPanel widget manages different widgets in tabs.tabbedpanel import TabbedPanel kivy.5.5 pos_hint: {’center_x’: . 17.load_string(""" <Test>: size_hint: .1 Simple example ’’’ TabbedPanel ============ Test of the widget TabbedPanel.0. ")) # now categorize widgets inserted above in a specific header TabbedPanelHeader: text: ’Tab 2’ content: set2_content TabbedPanelHeader: text: ’Tab 3’ content: set3_content """) class Test(TabbedPanel): pass class TabbedPanelApp(App): def build(self): return Test() if __name__ == ’__main__’: TabbedPanelApp(). but not for doing the content switching. and set its content separately: tp = TabbedPanel() th = TabbedPanelHeader(text=’Tab2’) tp. It is a special button containing a content property. Your app is responsible for adding the content of individual tabs. The tabbed panel handles switching of the main content object. are added in addition to the default tab. for all the tabs.add_widget(th) An individual tab. per user action.bind(on_default_tab = my_default_tab_callback) Accordingly.2 Customize the Tabbed Panel You can choose the direction the tabs are displayed: tab_pos = ’top_mid’ An individual tab is called a TabbedPanelHeader.text: ’Button that does nothing’ RstDocument: id: set3_content text: ’\\n’. This content can be any of the widget choices. such as a label or button: th. represented by a TabbedPanelHeader. active at a given time. There is always a default tab added when the tabbed panel is instantiated. Tabs that you add individually as above. Thus. on_default_tab event is provided for associating a callback: tp. You add the TabbedPanelHeader first. or it could be an indivual widget.run() 17. an 312 . including its text: tp.default_tab_text = ’Something Specific To Your Use’ The default tab machinery requires special consideration and management. depending on your needs and design.30. "You are in the third tab. needs its content set. It could be a layout with a deep hierarchy of widget. you will want to customize the default tab. "-----------".join(("Hello world". and for managing it.content = your_content_instance Note: There is one “shared” main content area. default to [1.children To access the list of tabs: tp. For example. 1. To change the appearance of this tab strip. 0. background_color is a ListProperty. 1]. 313 .background_down = ’path/to/tab_head/img_pressed’ A TabbedPanelStrip contains the individual tab headers. 1.content.Tabs and content can be removed in several ways: tp. a). used itself for background_image. 0. See module documentation for more information. 0.tabbedpanel.uix. left).background_normal = ’path/to/tab_head/img’ tab_header_instance. 1) # green Rectangle: size: self.clear_widgets() # to clear all the widgets in the content area or tp. background_image Background image of the main shared content object. b. override the canvas of TabbedPanelStrip. background_image is a las://data/images/defaulttheme/tab’.TabbedPanel(**kwargs) Bases: kivy. .remove_widget(Widget/TabbedPanelHeader) or tp. 0. g.GridLayout The TabbedPanel class.children: tp. in the kv language: <TabbedPanelStrip> canvas: Color: rgba: (0.tab_list To change the appearance of the main tabbed panel content: background_color = (1.pos By default the tabbed panel strip takes its background image and color from the tabbed panel’s background_image and background_color. 1. Can be changed for a custom background.uix. bottom. StringProperty. default to ‘at- border Border used for BorderImage graphics instruction. 0. use content. Read the BorderImage instructions for more information. use these two properties: tab_header_instance.size pos: self. 0] background_image = ’path/to/background/image’ To change the background of a individual tab.clear_tabs() # to remove the TabbedPanelHeaders Warning: To access the children of the tabbed panel. in the format (r.5) #50% translucent red border = [0.gridlayout. class kivy. background_color Background color. right. It must be a list of four values: (top. tab_height Specifies the height of the tab header. default_tab_content is a AliasProperty default_tab_text Specifies the text displayed on the default tab header. 314 . bottom_right. default to TabbedPanelHeader. default_tab_text is a StringProperty. Note: For convenience. default to 40.4. and is read-only. tab_pos Specifies the position of the tabs relative to the content. content is a ObjectProperty. tab_pos is a OptionProperty. default to ‘None’. tab_list is a AliasProperty.border is a ListProperty. 16.0. default_tab Holds the default tab. 16) content This is the object holding the content of the current tab. defaults to ‘default tab’. switch_to(header) Switch to a specific panel header. right_top. class kivy. top_right. read-only. right_bottom. New in version 1.uix.TabbedPanelContent(**kwargs) Bases: kivy. right_mid. tab_height is a NumericProperty. top_left.uix. tab_list List of all the tab headers. 16. left_mid. New in version 1. tab_width Specifies the width of the tab header. AliasProperty. default to ‘bottom_mid’. top_mid. default_tab is a AliasProperty default_tab_cls Specifies the class to use for the styling of the default tab. Can be one of: left_top. default to (16. current_tab Links to the currently select or active tab.FloatLayout The TabbedPanelContent class. bottom_left. left_bottom. default_tab_content Holds the default tab content.floatlayout.0. default to 100.4. tab_width is a NumericProperty. current_tab is a Warning: default_tab_cls should be subclassed from TabbedPanelHeader default_tab_cls is a ObjectProperty.tabbedpanel. bottom_mid. the automatically provided default tab is deleted when you change default_tab to something else. tabbed_panel is a ObjectProperty default to None .GridLayout A strip intended to be used as background for Heading/Tab.class kivy.tabbedpanel.uix. y) Coordinates in pixels.uix.31 Text Input New in version 1. cursor navigation. content is a ObjectProperty default to None .1 Usage example To create a multiline textinput (‘enter’ key adds a new line): 315 .Exception The TabbedPanelException class. multiline. 17. class kivy. Unicode.tabbedpanel. A button intended to be used as a Heading/Tab for TabbedPanel widget.TabbedPanelException Bases: exceptions. You can use this TabbedPanelHeader widget to add a new tab to TabbedPanel.TabbedPanelHeader(**kwargs) Bases: kivy.uix. selection and clipboard features are supported. The TextInput widget provides a box of editable plain text.TabbedPanelStrip(**kwargs) Bases: kivy.31. Note: Two different coordinate systems are used with TextInput: • (x.togglebutton.ToggleButton A Base for implementing a Tabbed Panel Head.uix.tabbedpanel.0. content Content to be loaded when this tab header is selected. col) Cursor index in characters / lines. used for selection and cursor movement.uix. 17.4. class kivy. mostly used for rendering on screen • (row. tabbed_panel link to the panel that tab strip is a part of.gridlayout. or if another widget requests the keyboard.textinput import TextInput textinput = TextInput(text=’Hello world’) To create a monoline textinput. You can get the currently selected text from the TextInput. instance textinput = TextInput(text=’Hello world’. value): print ’User pressed enter in’. multiline=False) textinput. value textinput = TextInput() textinput. value): print ’The widget’.bind(on_text_validate=on_enter) To run a callback when the text changes: def on_text(instance. meaning that the input box will be highlighted. instance else: print ’User defocused’. value): if value: print ’User focused’.selection_text property. You can bind a callback to the focus property to get notified of focus changes: def on_focus(instance. 316 . set the multiline property to false (‘enter’ key will defocus the textinput and emit on_text_validate event): def on_enter(instance. and keyboard focus will be requested: textinput = TextInput(focus=True) The textinput is defocused if the ‘escape’ key is pressed. ’have:’.bind(text=on_text) You can ‘focus’ a textinput. instance.uix.bind(focus=on_focus) 17.from kivy.31.2 Selection The selection is automatically updated when the cursor position changes. instance textinput = TextInput() textinput. 0. las://data/images/defaulttheme/textinput_active’ New in verdefault to ‘at- background_color Current color of the background.4. 1] #White background_normal Background image of the TextInput when it’s not in focus’. _ background color is a ListProperty. left). It must be a list of four values: (top.4. a) format. This will also unfocus the textinput. 16.textinput.widget.uix.31. New in version 1.4.uix. 317 . Right Copy selection Cut selection Paste selection Select all the content undo redo class kivy.1. b. las://data/images/defaulttheme/textinput’ New in verdefault to ‘at- border Border used for BorderImage graphics instruction.3 Default shortcuts Shortcuts Left Right Up Down Home End PageUp PageDown Backspace Del Shift + <dir> Control + c Control + x Control + p Control + a Control + z Control + r Description Move cursor to left Move cursor to right Move cursor to up Move cursor to down Move cursor at the beginning of the line Move cursor at the end of the line Move cursor to 3 lines before Move cursor to 3 lines after Delete the selection or character before the cursor Delete the selection of character after the cursor Start a text selection. background_normal is a StringProperty. in (r. default to [1.1. background_active Background image of the TextInput when it’s in focus’. col) if you want to move the cursor.TextInput(**kwargs) Bases: kivy. cursor Tuple of (row. Events on_text_validate Fired only in multiline=False mode.Widget TextInput class. background_active is a StringProperty. bottom. Can be used for a custom background.1. See module documentation for more information. right. The scrolling area will be automatically updated to ensure that the cursor will be visible inside the viewport. Down. Read the BorderImage instruction for more information about how to use it. You can set a new (row.2. 1. sion 1. Dir can be Up. g. New in version 1. border is a ListProperty. when the user hits ‘enter’. default to (16. Used with background_normal and background_active. col) of the current cursor position. 16) cancel_selection() Cancel current selection (if any). 1.17. Left. sion 1. 16. cursor_row Current row of the cursor. The value of cursor_blink is automatically computed. cursor_col is a AliasProperty to cursor[0]. cursor_pos is a AliasProperty. default to False cursor_col Current column of the cursor. in (x.3. cursor_index() Return the cursor index in the text/value. cursor_pos Current position of the cursor. cursor_offset() Get the cursor x offset on the current line. This function is automaticlly called when ctrl+r keys are pressed. and back the cursor •do nothing. if we are at the start. delete_selection(from_undo=False) Delete the current text selection (if any). do_redo() Do redo operation New in version 1. read-only. cursor_blink This property is used to blink the cursor graphics. 318 .cursor is a AliasProperty. y). cursor_blink is a BooleanProperty. read-only. do_backspace(from_undo=False) Do backspace operation from the current cursor position. read-only. Setting a value on it will have no impact. This action re-does any command that has been undone by do_undo/ctrl+z. do_cursor_movement(action) Move the cursor relative to it’s current position. cursor_row is a AliasProperty to cursor[1].0. This action might do several things: •removing the current selection if available •removing the previous char. Action can be one of : •cursor_left: move the cursor to the left •cursor_right: move the cursor to the right •cursor_up: move the cursor on the previous line •cursor_down: move the cursor on the next line •cursor_home: move the cursor at the start of the current line •cursor_end: move the cursor at the end of current line •cursor_pgup: move one “page” before •cursor_pgdown: move one “page” after Warning: Current page has three lines before/after. col) of the cursor from text index. col) of the cursor from an (x. read-only. padding_y) properties. Changing the line_height will have no impact. the font file can be ignored. in the format (padding_x. default to True padding Padding of the text. foreground_color Current color of the foreground. and you can start to write on the textinput. inside the widget box. default to [0. For example. padding_x is a NumericProperty. from_undo=False) Insert new text on the current cursor position. New in version 1. multiline If True. padding is a ReferenceListProperty of (padding_x. font_size is a NumericProperty. in pixels. The solution is to use a font that has the glyphs you need to display. 1] #Black get_cursor_from_index(index) Return the (row. foreground_color is a ListProperty. focus is a BooleanProperty. The path can be absolute or relative.ttf that has the glyph. you will see ‘[]’ blank box characters instead of the actual glyphs. b. However. multiline is a BooleanProperty. “enter” action will defocus the textinput instead of adding a new line. use a font like 319 . focus If focus is True. . in (r. padding_x Horizontal padding of the text. default to ‘DroidSans’. g. y) position. insert_text(substring.2. This property is automatically computed from the font_name. If the font used lacks the glyphs for the particular language/symbols you are using. get_cursor_from_xy(x. line_height is a NumericProperty. you can mostly use this without trouble. If False. the widget will be able show multiple lines of text. 0.do_undo() Do undo operation New in version 1. default to 0. 0. y) Return the (row. font_name is a StringProperty. padding_y). font_size Font size of the text.0. default to False font_name Filename of the font to use.3. This function is automatically called when ctrl+z keys are pressed. This action un-does any edits that have been made since the last call to reset_undo(). default to 10. a) format.0. Warning: Depending on your text provider. Relative paths are resolved by the resource_find() function. the keyboard will be requested. line_height Height of a line. to display freesans. _ font size. This might be changed by the current theme. 4. default to None. password If True. Changed in version 1. this property will represent the cursor index where the selection started. default to 4. tab_width is a NumericProperty. the user will not be able to change the content of a textinput. selection_color is a ListProperty.4. in (r.0.1843.0. readonly. inside the widget box. See scroll_x for more information. New in version 1. If there is no action. selection_text is a StringProperty. New in version 1. default to ‘’. This might be changed by the current theme. default to [0.4. a) format. selection_text Current content selection. scroll_y Y scrolling value of the viewport. default to 0. each tab will be replaced by four spaces on the text input widget.3.0. tab_width By default. the scroll_x and scroll_y properties may be changed. readonly. selection_color Current color of the selection. Warning: The color should always have “alpha” component different from 1. select_text(start.0. b. New in version 1.5] selection_from If a selection is happening. selection_to If a selection is happening.3. default to None. g. end) Select portion of text displayed in this TextInput New in version 1. padding_x is a NumericProperty. readonly. scroll_y is a NumericProperty.6549. Changed in version 1. The scrolling is automatically updated when the cursor is moving or text is changing.0. default to False reset_undo() Reset undo and redo lists from memory.4. 0. . or finished. selection_from is a AliasProperty. since the selection is drawn after the text.0. readonly is a BooleanProperty. selection_to is a AliasProperty. You can set a lower or higher value. select_all() Select all of the text displayed in this TextInput New in version 1.2.8313. default to False readonly If True.0. default to 0. the widget will display its characters as the character ‘*’. or finished. 320 . 0. password is a BooleanProperty. default to 0. scroll_x is a NumericProperty. scroll_x X scrolling value of the viewport. this property will represent the cursor index where the selection started.padding_y Vertical padding of the text. Garbage collector might need more elements before flushing it. When you touch/click it.get_widgets(’mygroup’) # do your job del l Warning: It’s possible that some widgets that you have previously deleted are still in the list. see module documentation for more information.32 Toggle button The ToggleButton widget acts like a checkbox.) btn2 = ToggleButton(text=’Female’. use: widget = TextInput(text=u’My unicode string’) text a StringProperty.0. the state toggles between ‘normal’ and ‘down’ (opposed to a Button that is only ‘down’ as long as it is pressed). group=’sex’. group must be a hashable object. group=’sex’. do: l = ToggleButton.Button Toggle button class. Important: Always release the result of this method! In doubt. you can use the same properties that you can use for a Button class.only one button in a group can be in ‘down’ state. The return of this method is informative. Only one button in a group can be in ‘down’ state. If None. an empty list will be returned. class kivy.3.togglebutton. group Group of the button. like a string. To configure the ToggleButton. group is a ObjectProperty 321 .text Text of the widget. If specified.button. state=’down’) btn3 = ToggleButton(text=’Mixed’. Creation of a simple hello world: widget = TextInput(text=’Hello world’) If you want to create the widget with an unicode string. no group will be used (button is independent).ToggleButton(**kwargs) Bases: kivy. you’ve been warned! New in version 1. group=’sex’) Only one of the buttons can be ‘down’/checked at the same time. The group name can be a string or any other hashable Python object: btn1 = ToggleButton(text=’Male’. Toggle buttons can also be grouped to make radio buttons . static get_widgets(groupname) Return the widgets contained in a specific group.uix.uix. 17. If the group doesn’t exist. The TreeView always creates a default root node. ’children’: []}]}.add_node(TreeViewLabel(text=’Item 1’)) tv.add_node(TreeNodeLabel(text=node[’node_id’]. as with: def populate_tree_view(tree_view.add_node(TreeViewLabel(text=’SubItem 1’).17.add_node(TreeViewLabel(text=’My first item’)) tv.1 Introduction A TreeView is populated with TreeViewNode instances.1. follow the pattern of TreeViewLabel. Extend TreeViewNode to create custom a custom node type for use with TreeView. It’s currently very basic. which combines Label and TreeViewNode. perhaps you would need a utility function to populate the tree view. TreeViewNode is a class object containing needed properties for serving as a tree node. or even your own widget.1.2’. ’children’: [{’node_id’: ’1.. is_open=True).3’.2’. but you cannot use a TreeViewNode directly.0. child_node) tree = {’node_id’: ’1’. {’node_id’: ’1. Warning: This widget is still experimental. n1) If you have a large tree structure. ’children’: [{’node_id’: ’1.33. {’node_id’: ’1.add_node(TreeNodeLabel(text=node[’node_id’]. you could create two nodes.33 Tree View New in version 1. ’children’: []}]} 322 . node): if parent is None: tree_node = tree_view.1. is_open=True)) else: tree_node = tree_view.add_node(TreeViewLabel(text=’SubItem 2’). parent) for child_node in node[’children’]: populate_tree_view(tree_view.add_node(TreeViewLabel(text=’My second item’)) Or. tree.1.1’. You must combine it with another widget. parent. To use the TreeViewLabel class. such as Label. n1) tv. based on TreeViewLabel.1’. supporting a minimal feature set.1’.4. 17. producing TreeViewLabel for direct use in a TreeView instance. directly attached to root: tv = TreeView() tv. For constructing your own subclass. ’children’: [{’node_id’: ’1. ’children’: []}.1.. create two nodes attached to a first: tv = TreeView() n1 = tv. Button. {’node_id’: ’1. and his API is subject to change in a future vers TreeView is a widget to represent a tree structure. ’children’: []}]}. y).Widget TreeView class.indent_level * node. defaults to False. combine Button + TreeViewNode like this: class TreeViewButton(Button. Parameters node: instance of a TreeViewNode Node to add into the tree parent: instance of a TreeViewNode.tv = TreeView(root_options=dict(text=’Tree One’).TreeView(**kwargs) Bases: kivy.treeview. you can use TreeView. if needed. Events on_node_expand: (node.widget. For example.width . the width allocated will be: treeview. for a given node. defaults to None Parent node to attach the new node get_node_at_pos(pos) Get a node at the position (x. the root node will be appear as a closed node. parent=None) Add a new node in the tree. ) Fired when a node is being collapsed add_node(node. indent_level Width used for identation of each level. if a node is at level 4. See module documentation for more information.indent_start .treeview. class kivy. It is the developer’s responsibility to correctly handle adapt the graphical representation nodes. If you want to change that. TreeViewNode): pass You must know that. The allocated width for the node will depend of the current width of the TreeView and the level of the node. None. Computation of spacing for eaching level of tree is: :data:‘indent_start‘ + level * :data:‘indent_level‘ 323 .2 Creating Your Own Node Widget For a button node type.uix.level You might have some trouble with that. ) Fired when a node is being expanded on_node_collapse: (node.add_widget(tv) The root widget in the tree view is opened by default. hide_root is a BooleanProperty. except the first level. indent_level=4) _ _ populate tree view(tv.uix. This will pass options to the root widget: tv = TreeView(root_options=dict(text=’My root label’)) 17. tree) some_containing_widget. hide_root Use this property to show/hide the initial root node.treeview.33. and has a text set as ‘Root’. only the size_hint_x will be honored. hide_root=False.root_options property. If True. indent_level is a NumericProperty, defaults to 16. indent_start Indentation width of the level 0 / root node. This is mostly the initial size to accommodate a tree icon (collapsed / expanded). See indent_level for more information about the computation of level indentation. indent_start is a NumericProperty, defaults to 24. iterate_all_nodes(node=None) Generator to iterate over all nodes, expanded or not. iterate_open_nodes(node=None) Generator to iterate over expanded nodes. To get all the open nodes: treeview = TreeView() # ... add nodes ... for node in treeview.iterate_open_nodes(): print node load_func Callback to use for asynchronous loading. If set, asynchronous loading will be automatically done. The callback must act as a Python generator function, using yield to send data back to the treeview. The callback should be in the format: def callback(treeview, node): for name in (’Item 1’, ’Item 2’): yield TreeViewLabel(text=name) load_func is a ObjectProperty, defaults to None. minimum_height Minimum height needed to contain all children. New in version 1.0.9. minimum_height is a kivy.properties.NumericProperty, defaults to 0. minimum_size Minimum size needed to contain all children. New in version 1.0.9. minimum_size is a ReferenceListProperty of (minimum_width, minimum_height) properties. minimum_width Minimum width needed to contain all children. New in version 1.0.9. minimum_width is a kivy.properties.NumericProperty, defaults to 0. remove_node(node) Remove a node in a tree. New in version 1.0.7. Parameters node: instance of a TreeViewNode Node to remove from the tree root Root node. By default, the root node widget is a TreeViewLabel, with text ‘Root’. If you want to change the default options passed to the widget creation, use the root_options property: treeview = TreeView(root_options={ ’text’: ’Root directory’, ’font_size’: 15}) 324 root_options will change the properties of the TreeViewLabel instance. However, you cannot change the class used for root node yet. root is a AliasProperty, defaults to None, and is read-only. However, the content of the widget can be changed. root_options Default root options to pass for root widget. See root property for more information about the usage of root_options. root_options is a ObjectProperty, default to {}. select_node(node) Select a node in the tree. selected_node Node selected by TreeView.select_node(), or by touch. selected_node is a AliasProperty, defaults to None, and is read-only. toggle_node(node) Toggle the state of the node (open/collapse). class kivy.uix.treeview.TreeViewException Bases: exceptions.Exception Exception for errors in the TreeView. class kivy.uix.treeview.TreeViewLabel(**kwargs) Bases: kivy.uix.label.Label, kivy.uix.treeview.TreeViewNode Combine Label and TreeViewNode to create a TreeViewLabel, that can be used as a text node in the tree. See module documentation for more information. class kivy.uix.treeview.TreeViewNode(**kwargs) Bases: object TreeViewNode class, used to build node class for TreeView object. color_selected Background color of the node when the node is selected. color_selected is a ListProperty, defaults to [.1, .1, .1, 1] even_color Background color of even nodes when the node is not selected. bg_color is a ListProperty, default to [.5, .5, .5, .1]. is_leaf Boolean to indicate if this node is a leaf or not. Used to adjust graphical representation. is_leaf is a BooleanProperty, defaults to True, and automatically set to False when child is added. is_loaded Boolean to indicate if this node is already loaded or not. This property is used only if the TreeView uses asynchronous loading. is_loaded is a BooleanProperty, default to False is_open Boolean to indicate if this node is opened or not, in case if there are child nodes. This is used to adjust graphical representation. 325 Warning: write it. This property is automatically set by the TreeView. You can read but not is_open is a BooleanProperty, defaults to False. is_selected Boolean to indicate if this node is selected or not. This is used for graphical representation. Warning: write it. This property is automatically set by the TreeView. You can read but not is_selected is a BooleanProperty, default to False. level Level of the node. level is a NumericProperty, defaults to -1. no_selection Boolean to indicate if we allow selection of the node or not. no_selection is a BooleanProperty, defaults to False nodes List of nodes. The nodes list is different than the children list. A node in the nodes list represents a node on the tree. An item in the children list represents the widget associated with the node. Warning: write it. This property is automatically set by the TreeView. You can read but not nodes is a ListProperty, defaults to []. odd This property is set by the TreeView widget automatically. BooleanProperty, defaults to False. odd_color Background color of odd nodes when the node is not selected. bg_color is a ListProperty, default to [1., 1., 1., 0.]. parent_node Parent node. This attribute is needed because parent can be None when the node is not displayed. New in version 1.0.7. parent_node is a ObjectProperty, default to None. Read-only. odd is a 326 17.34 VKeyboard New in version 1.0.8. Warning: This is experimental and subject to change as long as this warning notice is prese VKeyboard is an onscreen keyboard for Kivy. Its operation is intended to be transparent to the user. Using the widget directly is NOT recommended. Read the section Request keyboard first. 17.34.1 Modes This virtual keyboard has a docked and free mode: • docked mode (VKeyboard.docked = True) Generally used when only one person is using the computer, like tablet, personal computer etc. • free mode: (VKeyboard.docked = False) Mostly for multitouch table. This mode allows more than one virtual keyboard on the screen. If the docked mode changes, you need to manually call VKeyboard.setup_mode(). Otherwise the change will have no impact. During that call, the VKeyboard, implemented in top of scatter, will change the behavior of the scatter, and position the keyboard near the target (if target and docked mode is set). 17.34.2 Layouts The virtual keyboard is able to load a custom layout. If you create a new layout, put the JSON in <kivy_data_dir>/keyboards/<layoutid>.json. Load it by setting VKeyboard.layout to your layoutid. The JSON must be structured like this: { "title": "Title of your layout", "description": "Description of your layout", "cols": 15, "rows": 5, ... } Then, you need to describe keys in each row, for either a “normal” mode or a “shift” mode. Keys for this row data must be named normal_<row> and shift_<row>. Replace row with the row number. Inside each row, you will describe the key. A key is a 4 element list in the format: 327 [ <text displayed on the keyboard>, <text to put when the key is pressed>, <text that represents the keycode>, <size of cols> ] Here are example keys: # f key ["f", "f", "f", 1] # capslock ["\u21B9", " ", "tab", 1.5] Finally, complete the JSON: { ... "normal_1": [ ["‘", "‘", ["3", "3", ["6", "6", ["9", "9", ["=", "=", ], "‘", "3", "6", "9", "=", 1], 1], 1], 1], 1], ["1", "1", ["4", "4", ["7", "7", ["0", "0", ["\u232b", "1", 1], ["2", "2", "4", 1], ["5", "5", "7", 1], ["8", "8", "0", 1], ["+", "+", null, "backspace", 2] "2", "5", "8", "+", 1], 1], 1], 1], "shift_1": [ ... ], "normal_2": [ ... ], ... } 17.34.3 Request Keyboard The instantiation of the virtual keyboard is controlled by the configuration. Check keyboard_mode and keyboard_layout in the Configuration object. If you intend to create a widget that requires a keyboard, do not use the virtual keyboard directly, but prefer to use the best method available on the platform. Check the request_keyboard() method in the Window. class kivy.uix.vkeyboard.VKeyboard(**kwargs) Bases: kivy.uix.scatter.Scatter VKeyboard is an onscreen keyboard with multitouch support. Its layout is entirely customizable and you can switch between available layouts using a button in the bottom right of the widget. Events on_key_down: keycode, internal, modifiers Fired when the keyboard received a key down event (key press). on_key_up: keycode, internal, modifiers Fired when the keyboard received a key up event (key release). available_layouts Dictionary of all available layouts. Keys are the layout ID, and the value is the JSON (translated in Python object). available_layouts is a DictProperty, default to {} background Filename of the background image. background a StringProperty, default to atlas://data/images/defaulttheme/vkeyboard_bac 328 background_border Background image border. Used for controlling the border property of the background. background_border is a ListProperty, default to [16, 16, 16, 16] background_color Background color, in the format (r, g, b, a). If a background is set, the color will be combined with the background texture. background_color is a ListProperty, default to [1, 1, 1, 1]. callback Callback can be set to a function that will be called if the VKeyboard is closed by the user. target is a ObjectProperty instance, default to None. collide_margin(x, y) Do a collision test, and return True if the (x, y) is inside the vkeyboard margin. docked Indicate if the VKeyboard is docked on the screen or not. If you change it, you must manually call setup_mode(). Otherwise, it will have no impact. If the VKeyboard is created by the Window, the docked mode will be automatically set by the configuration, with keyboard_mode token in [kivy] section. docked is a BooleanProperty, default to False. key_background_color Key background color, in the format (r, g, b, a). If a key background is set, the color will be combined with the key background texture. key_background_color is a ListProperty, default to [1, 1, 1, 1]. key_background_down Filename of the key background image for use when a touch is active on the widget. key_background_down a StringProperty, atlas://data/images/defaulttheme/vkeyboard_key_down. default to key_background_normal Filename of the key background image for use when no touches are active on the widget. key_background_normal a StringProperty, default atlas://data/images/defaulttheme/vkeyboard_key_normal. key_border Key image border. Used for controlling the border property of the key. key_border is a ListProperty, default to [16, 16, 16, 16] key_margin Key margin, used to create space between keys. The margin is composed of four values, in pixels: key_margin = [top, right, bottom, left] to key_margin is a ListProperty, default to [2, 2, 2, 2] layout Layout to use for the VKeyboard. By default, it will be the layout set in the configuration, according to the keyboard_layout in [kivy] section. layout is a StringProperty, default to None. layout_path Path from which layouts are read. 329 layout is a StringProperty, default to <kivy_data_dir>/keyboards/ margin_hint Margin hint, used as spacing between keyboard background and keys content. The margin is composed of four values, between 0 and 1: margin_hint = [top, right, bottom, left] The margin hints will be multiplied by width and height, according to their position. margin_hint is a ListProperty, default to [.05, .06, .05, .06] refresh(force=False) (internal) Recreate the entire widget and graphics according to the selected layout. setup_mode(*largs) Call this method when you want to readjust the keyboard according to options: docked or not, with attached target or not: •If docked is True, it will call setup_mode_dock() •If docked is False, it will call setup_mode_free() Fell free to overload theses methods to create a new positioning behavior. setup_mode_dock(*largs) Setup the keyboard in docked mode. Dock mode will reset the rotation, disable translation, rotation and scale. Scale and position will be automatically adjusted to attach the keyboard in the bottom of the screen. Note: Don’t call this method directly, use setup_mode() instead. setup_mode_free() Setup the keyboard in free mode. Free mode is designed to let the user control the position and orientation of the keyboard. The only real usage is for a multiuser environment, but you might found other ways to use it. If a target is set, it will place the vkeyboard under the target. Note: Don’t call this method directly, use setup_mode() instead. target Target widget associated to VKeyboard. If set, it will be used to send keyboard events, and if the VKeyboard mode is “free”, it will also be used to set the initial position. target is a ObjectProperty instance, default to None. 17.35 Video The Video widget is used to display video files and streams. Depending on your Video core provider, platform, and plugins, you will be able to play different formats. For example, the pygame video provider only supports MPEG1 on Linux and OSX. GStreamer is more versatile, and can read many video containers and codecs such as MKV, OGV, AVI, MOV, FLV (if the correct gstreamer plugins are installed). Our VideoBase implementation is used under the hood. Video loading is asynchronous - many properties are not available until the video is loaded (when the texture is created): 330 duration=on_duration_change) class kivy.mkv’.4. position is a NumericProperty. play=True) # create the video. value def on_duration_change(instance. position Position of the video between 0 and duration. indicates if the video is done playing (reached end of stream). state String.mkv’) 331 .avi’) video. default to {}. The position defaults to -1.def on_position_change(instance. default to False. value): print ’The position in the video is’.uix. duration is a NumericProperty. Warning: Calling seek() before video is loaded has no impact. kivy.video. New in version 1.0: Use state instead. value): print ’The duration of the video is’.bind(position=on_position_change. default to -1. options Options to pass at Video core object creation. video video = Video(source=’PandaSneezes.0. duration Duration of the video. and start later video = Video(source=’movie.4. eos is a BooleanProperty. New in version 1.image. default to False. and start later video = Video(source=’movie. state=’play’) # create the video.2. and is set to a real position when the video is loaded. indicates if the video is playing.play = True play is a BooleanProperty.mkv’) # and later video. and is set to a real duration when the video is loaded.0.Video(**kwargs) Bases: kivy. The duration defaults to -1. Percentage must be a value between 0-1.properties. eos Boolean. or stop the video: # start playing the video at creation video = Video(source=’movie.0: Use state instead.mkv’.uix.Image Video class. You can start/stop the video by setting this property: # start playing the video at creation video = Video(source=’movie. options is a play Deprecated since version 1. default to -1. pause. seek(percent) Change the position to a percentage of duration. Boolean. See module documentation for more information. Deprecated since version 1.4. indicates whether to play.ObjectProperty. 2. because of the complex assembly of numerous base widgets. For example.# and later video.jsa: [ {"start": 0. default to 1.36. volume and seek. The player will automatically load the associated annotation file if it exists. volume Volume of the video.1 Annotations If you want to display text at a specific time and duration.5]. 0 means mute. consider annotations. here is a short version of a jsa file that you can find in examples/widgets/softboy. An annotation file has a ”. "duration": 2. 332 . The video player widget can be used to play video and let the user control the play/pause.5.2. The key and value must match one of the VideoPlayerAnnotation items.jsa” extension.0. The annotation file is JSON-based. 0. "bgcolor": [0. volume is a NumericProperty.36 Video player New in version 1.state = ’play’ state is a OptionProperty. {"start": 2. The widget cannot be customized much. 0. providing a list of label dictionary items. 17. 0. 1 means full volume. "text": "This is an example of annotation"}. 17. in the range 0-1. default to ‘play’.4. "duration": 2. "text": "You can change the background color"} ] For our softboy.avi example, the result will be: If you want to experiment with annotation files, test with: python -m kivy.uix.videoplayer examples/widgets/softboy.avi 17.36.2 Fullscreen The video player can play the video in fullscreen, if VideoPlayer.allow_fullscreen is activated by a double-tap on the video. By default, if the video is smaller than the Window, it will be not stretched. You can allow stretching by passing custom options to a Video instance: player = VideoPlayer(source=’myvideo.avi’, state=’play’, options={’allow_stretch’: True}) class kivy.uix.videoplayer.VideoPlayer(**kwargs) Bases: kivy.uix.gridlayout.GridLayout VideoPlayer class. See module documentation for more information. allow_fullscreen By default, you can double-tap on the video to make it fullscreen. Set this property to False to prevent this behavior. allow_fullscreen a BooleanProperty, default to True annotations If set, it will be used for reading annotations box. 333 duration Duration of the video. The duration defaults to -1, and is set to the real duration when the video is loaded. duration is a NumericProperty, default to -1. fullscreen Switch to control fullscreen view. This must be used with care. When activated, the widget will remove itself from its parent, remove all children from the window, and will add itself to it. When fullscreen is unset, all the previous children are restored, and the widget is reset to its previous parent. Warning: The re-add operation doesn’t care about the index position of it’s children within the parent. fullscreen a BooleanProperty, default to False image_loading Image filename used when the video is loading. image_loading a StringProperty image_overlay_play Image filename used to show a “play” overlay when the video is not yet started. image_overlay_play a StringProperty image_pause Image filename used for the “Pause” button. image_pause a StringProperty image_play Image filename used for the “Play” button. image_play a StringProperty image_stop Image filename used for the “Stop” button. image_stop a StringProperty image_volumehigh Image filename used for the volume icon, when the volume is high. image_volumehigh a StringProperty image_volumelow Image filename used for the volume icon, when the volume is low. image_volumelow a StringProperty image_volumemedium Image filename used for the volume icon, when the volume is medium. image_volumemedium a StringProperty image_volumemuted Image filename used for the volume icon, when the volume is muted. image_volumemuted a StringProperty options Optional parameters can be passed to Video instance with this property. options a DictProperty, default to {} 334 play Deprecated since version 1.4.0: Use state instead. Boolean, indicates if the video is playing. You can start/stop the video by setting this property: # start playing the video at creation video = Video(source=’movie.mkv’, play=True) # create the video, and start later video = Video(source=’movie.mkv’) # and later video.play = True play is a BooleanProperty, default to False. position Position of the video between 0 and duration. The position defaults to -1, and is set to the real position when the video is loaded. position is a NumericProperty, default to -1. seek(percent) Change the position to a percentage of duration. Percentage must be a value between 0-1. Warning: Calling seek() before video is loaded has no impact. source Source of the video to read. source a StringProperty, default to ‘’. .. versionchanged:: 1.4.0 state String, indicates whether to play, pause, or stop the video: # start playing the video at creation video = Video(source=’movie.mkv’, state=’play’) # create the video, and start later video = Video(source=’movie.mkv’) # and later video.state = ’play’ state is a OptionProperty, default to ‘play’. thumbnail Thumbnail of the video to show. If None, VideoPlayer will try to find the thumbnail from the source + .png. thumbnail a StringProperty, default to ‘’. .. versionchanged:: 1.4.0 volume Volume of the video, in the range 0-1. 1 means full volume, 0 means mute. volume is a NumericProperty, default to 1. class kivy.uix.videoplayer.VideoPlayerAnnotation(**kwargs) Bases: kivy.uix.label.Label Annotation class used for creating annotation labels. Additionnals key are available: •bgcolor: [r, g, b, a] - background color of the text box •bgsource: ‘filename’ - background image used for background text box 335 •border: (n, e, s, w) - border used for background image duration Duration of the annotation. duration is a NumericProperty, default to 1 start Start time of the annotation. start is a NumericProperty, default to 0 17.37 Widget class The Widget class is the base class required to create a Widget. Our widget class is designed with a couple of principles in mind: Event Driven The widget interaction is built on top of events that occur. If a property changes, the widget can do something. If nothing changes in the widget, nothing will be done. That’s the main goal of the Property class. Separate the widget and its graphical representation Widgets don’t have a draw() method. This is done on purpose: The idea is to allow you to create your own graphical representation outside the widget class. Obviously you can still use all the available properties to do that, so that your representation properly reflects the widget’s current state. Every widget has its own Canvas that you can use to draw. This separation allows Kivy to run your application in a very efficient manner. Bounding Box / Collision Often you want to know if a certain point is within the bounds of your widget. An example would be a button widget where you want to only trigger an action when the button itself is actually touched. For this, you can use the Widget.collide_point() method, which will return True if the point you pass it is inside the axis-aligned bounding box defined by the widget’s position and size. If a simple AABB is not sufficient, you can override the method to perform the collision checks with more complex shapes, e.g., a polygon. You can also check if a widget collides with another widget with Widget.collide_widget(). We also have some defaults that you should be aware of: • A Widget is not a Layout: it will not change the position nor the size of its children. If you want a better positionning / sizing, use a Layout. • The default size is (100, 100), if the parent is not a Layout. For example, adding a widget inside a Button, Label, will not inherit from the parent size or pos. • The default size_hint is (1, 1). If the parent is a Layout, then the widget size will be the parent/layout size. • All the Widget.on_touch_down(), Widget.on_touch_move(), Widget.on_touch_up() doesn’t do any sort of collisions. If you want to know if the touch is inside your widget, use Widget.collide_point(). 17.37.1 Using Properties When you read the documentation, all properties are described in the format: <name> is a <property class>, defaults to <default value> For example: 336 :data:‘Widget.pos‘ is a :class:‘~kivy.properties.ReferenceListProperty‘ of (:data:‘Widget.x‘, :data:‘Widget.y‘) properties. If you want to be notified when the pos attribute changes, i.e., when the widget moves, you can bind your own callback function like this: def callback_pos(instance, value): print ’The widget’, instance, ’moved to’, value wid = Widget() wid.bind(pos=callback_pos) Read more about the Properties. class kivy.uix.widget.Widget(**kwargs) Bases: kivy.event.EventDispatcher Widget class. See module documentation for more information. Events on_touch_down: Fired when a new touch happens on_touch_move: Fired when an existing touch is moved on_touch_up: Fired when an existing touch disappears Changed in version 1.0.9: Everything related to event properties has been moved to EventDispatcher. Event properties can now be used in contructing a simple class, without subclassing Widget.Changed in version 1.5.0: Constructor now accept on_* arguments to automatically bind callbacks to properties or events, as the Kv language. add_widget(widget, index=0) Add a new widget as a child of this widget. Parameters widget: Widget Widget to add to our list of children. index: int, default to 0 (this attribute have been added in 1.0.5) Index to insert the widget in the list >>> >>> >>> >>> root = Widget() root.add_widget(Button()) slider = Slider() root.add_widget(slider) canvas = None Canvas of the widget. The canvas is a graphics object that contains all the drawing instructions for the graphical representation of the widget. There are no general properties for the Widget class, such as background color, to keep the design simple and lean. Some derived classes, such as Button, do add such convenience properties, but generally the developer is responsible for implementing the graphics representation for a custom widget from the ground up. See the derived widget classes for patterns to follow and extend. See Canvas for more information about the usage. center Center position of the widget. center is a ReferenceListProperty of (center_x, center_y) 337 center_x X center position of the widget. center_x is a AliasProperty of (x + width / 2.) center_y Y center position of the widget. center_y is a AliasProperty of (y + height / 2.) children List of children of this widget. children is a ListProperty instance, default to an empty list. Use add_widget() and remove_widget() for manipulating the children list. Don’t manipulate the children list directly until you know what you are doing. clear_widgets() Remove all widgets added to this widget. cls Class of the widget, used for styling. collide_point(x, y) Check if a point (x, y) is inside the widget’s axis aligned bounding box. Parameters x: numeric X position of the point (in window coordinates) y: numeric Y position of the point (in window coordinates) Returns bool, True if the point is inside the bounding box. >>> Widget(pos=(10, 10), size=(50, 50)).collide_point(40, 40) True collide_widget(wid) Check if the other widget collides with this widget. Performs an axis-aligned bounding box intersection test by default. Parameters wid: Widget class Widget to collide with. Returns bool, True if the other widget collides with this widget. >>> wid = Widget(size=(50, 50)) >>> wid2 = Widget(size=(50, 50), pos=(25, 25)) >>> wid.collide_widget(wid2) True >>> wid2.pos = (55, 55) >>> wid.collide_widget(wid2) False get_parent_window() Return the parent window. Returns Instance of the parent window. Can be WindowBase or Widget get_root_window() Return the root window. Returns Instance of the root window. Can be WindowBase or Widget 338 height Height of the widget. height is a NumericProperty, default to 100. id Unique identifier of the widget in the tree. id is a StringProperty, default to None. Warning: If the id is already used in the tree, an exception will be raised. on_touch_down(touch) Receive a touch down event. Parameters touch: MotionEvent class Touch received Returns bool. If True, the dispatching of the touch will stop. on_touch_move(touch) Receive a touch move event. See on_touch_down() for more information on_touch_up(touch) Receive a touch up event. See on_touch_down() for more information opacity Opacity of the widget and all the children. New in version 1.4.1. The opacity attribute controls the opacity of the widget and its children. Be careful, it’s a cumulative attribute: the value is multiplied to the current global opacity, and the result is applied to the current context color. For example: if your parent have an opacity of 0.5, and one children have an opacity of 0.2, the real opacity of the children will be 0.5 * 0.2 = 0.1. Then, the opacity is applied on the shader as: frag_color = color * vec4(1.0, 1.0, 1.0, opacity); opacity is a NumericProperty, default to 1.0. parent Parent of this widget. parent is a ObjectProperty instance, default to None. The parent of a widget is set when the widget is added to another one, and unset when the widget is removed from its parent. pos Position of the widget. pos is a ReferenceListProperty of (x, y) properties. pos_hint Position hint. This property allows you to set the position of the widget inside its parent layout, in percent (similar to size_hint). For example, if you want to set the top of the widget to be at 90% height of its parent layout, you can write: 339 Parameters 340 . default to 1. The keys ‘y’. Position hint is only used in FloatLayout and Window. relative to its parent’s width. Represents how much space the widget should use in the direction of the X axis. The value is in percent as a float from 0. ‘top’. to 1.5 represents 50%. ‘center_y’. size_hint_x is a NumericProperty. 0.9}) The keys ‘x’. will use the parent width. height) properties. where 1. size_hint_y) See size_hint_x for more information size_hint_x X size hint. default to False Change to True if you want to translate coordinates to relative widget coordinates.add_widget(button) root. size_hint_y Y size hint. relative=False) Transform local coordinates to parent coordinates. relative=False) Transform parent coordinates to local coordinates. size_hint Size hint. See size_hint_x for more information to_local(x. Parameters relative: bool. ‘center_x’. Parameters widget: Widget Widget to remove from our children list.widget = Widget(pos_hint={‘top’: 0. remove_widget(widget) Remove a widget from the children of this widget. y. >>> >>> >>> >>> root = Widget() button = Button() root. See Float Layout for further reference. pos_hint is a ObjectProperty containing a dict. default to 1. size is a ReferenceListProperty of (width. means the full size of his parent. size_hint_y is a NumericProperty. right is a AliasProperty of (x + width) size Size of the widget. Only Layout and Window make use of the hint. y. to_parent(x. will use the parent height.. size_hint is a ReferenceListProperty of (size_hint_x. ‘right’.remove_widget(button) right Right position of the widget. 38.uix. initial=True. reStructuredText is an easy-to-read. And this is a reference to top_:: $ print "Hello world" """ document = RstDocument(text=text) 341 . The whole styling and implementation are not stable until this warning has been removed. Warning: This widget is highly experimental. y. some ‘‘interpreted text‘‘. y Y position of the widget. x is a NumericProperty.relative: bool. 17. to_widget(x. y is a NumericProperty. top Top position of the widget. x X position of the widget. relative=False) Transform local coordinates to window coordinates. what-you-see-is-what-you-get plaintext markup syntax and parser system. width is a NumericProperty.38 reStructuredText renderer New in version 1. default to 0.0. relative=False) Convert the given coordinate from window to local widget coordinates. 17. _top: Hello world =========== This is an **emphased text**. to_window(x.Exception Fired when the widget gets an exception.. y. default to 100. default to False Change to True if you want to translate relative positions from widget to its parent. default to 0. class kivy.widget.1 Usage with Text text = """ . top is a AliasProperty of (y + height) width Width of the widget.WidgetException Bases: exceptions.1. goto(ref.38. If no path is given.RstDocument(**kwargs) Bases: kivy. If it’s not found.uix. RstDocument. class kivy.ScrollView Base widget used to store an Rst document.scrollview. nothing will be done. document_root Root path where :doc: will search any rst document.rst you can write: Go to my next document: :doc:‘moreinfo.uix.rst will be loaded.rst’) You can reference other documents with the role :doc:. document_root is a StringProperty. then it will use the directory of the first loaded source.rst. the document moreinfo. See module documentation for more information. For example. You also need to call You can do: from kivy. Warning: This dictionary is needs special handling. For this text: .rst‘ It will generate a link that. colors Dictionary of all the colors used in the RST rendering.source: document = RstDocument(source=’index. _myref: This is something I always wanted.The rendering will output: 17. default to None. in the document index.. *largs) Scroll to the reference. colors is a DictProperty.render() if you change them after loading. when clicked.clock import Clock from functools import partial 342 .2 Usage with Source You can also render a rst file by using RstDocument. New in version 1. If the filename doesn’t exist. render() Force document rendering. text is a StringProperty. resolve_path(filename) Get the path for this filename. and its title.. then the calculation of the scrolling would be wrong. default to None.g.. ’myref’). when the document is loaded from a text file.3. toctrees Toctree of all loaded or preloaded documents. 0.) Clock. This dictionary is filled when a rst document is explicitly loaded. you can do a direct call if the document is already loaded. However. it return the document_root + filename. preload(filename) Preload a rst file to get its toctree. toctrees is a DictProperty.schedule_once(partial(doc. 343 .. the key will be ‘’. default to {}. default to None.0. text RST markup text of the document. The result will be stored in toctrees with the filename as key.doc = RstDocument(. show_errors Indicate if RST parsers errors must be shown on the screen or not. e. show_errors is a BooleanProperty. or where preload() has been called. or if the size of the RstDocument is not fixed yet. title Title of the current document. title is a StringProperty.1) Note: It is preferable to delay the call of the goto if you just loaded the document.goto. default to False source Filename of the RST document. because the layout might not be finished. default to ‘’ in read-only. source is a StringProperty. If the document has no filename. 344 . 345 . class.Part III APPENDIX The appendix contains licensing information and an enumeration of all the different module. function and variable names available in Kivy. 346 . CHAPTER EIGHTEEN LICENSE Kivy is released under the terms of the GNU LGPL Version 3. please see the file AUTHORS that accompanies the Kivy source code distribution (next to COPYING).org/licenses/lgpl-3. 347 . An online version of the license can be found at http://www.gnu. You should have received a copy of the LGPL alongside your Kivy distribution.txt In a nutshell the license allows you to use Kivy in your own projects. closed source. regardless if they are open source. Kivy – Copyright 2011. See the file COPYING in the Kivy root folder. you have to share those changes with us. For a more thorough legal explanation of the terms and conditions. All rights reserved. For a list of authors.0. The one thing the license does enforce is that if you make changes to the Kivy sourcecode itself. please refer to the documents listed above. The Kivy Authors. commercial or free. 348 . providers. 227 kivy.keybinding. 230 kivy. 161 kivy.instructions.providers. 159 kivy.input.graphics.motionevent.markup.input.providers. 115 kivy. 198 kivy. 123 kivy. 144 kivy.wm_common. 219 kivy.mouse. 246 kivy.audio.input.clock.providers. 198 kivy. 164 kivy.modules.animation.support. 151 kivy.graphics.core. 142 kivy.graphics.wm_touch. 177 kivy.anchorlayout. 231 kivy.input. 233 kivy.modules.probesysfs.doubletap.input. 108 kivy.urlrequest.input.modules. 159 kivy.modules. 118 kivy.core.postproc.base.linuxwacom.compiler.input.opengl. 151 kivy. 232 kivy.postproc.graphics.graphics.clipboard.text. 233 kivy.input.network.input. 233 kivy.spelling.cache.transformation. 129 kivy.input. 98 kivy.input.shape.video.lib. 241 kivy. 165 kivy.PYTHON MODULE INDEX k kivy.modules.core.accordion.input.core.properties.graphics. 247 kivy.postproc.debug. 127 kivy. 161 kivy.input.core.providers.tuio.graphics. 160 kivy.recorder. 233 kivy. 212 kivy.providers. 253 kivy. 230 kivy.ignorelist. 246 kivy.uix. 229 kivy.postproc. 214 kivy.resources. 120 kivy. 231 kivy. 130 kivy.providers. 243 kivy.event.graphics.recorder. 229 kivy.screen. 231 kivy.metrics. 210 kivy. 237 kivy.core. 241 kivy.window.loader.app.modules.input.retaintouch.gl. 145 kivy.input.core.core. 230 kivy.atlas.mtdev. 167 kivy.interactive. 116 kivy.gesture.input.input.graphics.graphics. 241 kivy. 246 kivy.config.modules.factory.graphics. 162 kivy.mactouch.providers.logger. 192 kivy. 141 kivy. 249 kivy.input. 201 kivy. 97 kivy.graphics.core.postproc.androidjoystick. 233 kivy.touchring.input.providers. 249 kivy. 229 kivy. 257 349 .input. 166 kivy.gl_instructions.vertex_instructions.lib.graphics.camera.opengl_utils.providers. 134 kivy.providers.input. 219 kivy. 131 kivy. 202 kivy.stencil_instructions. 126 kivy.input.parser. 175 kivy. 245 kivy.graphics. 246 kivy. 253 kivy.providers. 195 kivy.monitor. 168 kivy.core. 235 kivy. 243 kivy.uix.context_instructions.factory. 211 kivy.texture.core.wm_pen.dejitter.context.uix. 200 kivy.shader.input. 230 kivy.inspector.network.hidinput.fbo.provider. 247 kivy.image. 230 kivy.ext.text.lang. weakmethod. 296 kivy.uix.uix.uix.uix. 267 kivy.uix.uix. 289 kivy.uix.dropdown. 156 350 .uix. 152 kivy. 264 kivy. 321 kivy.uix.widget. 284 kivy. 300 kivy.utils. 278 kivy. 309 kivy.bubble. 341 kivy.scrollview.uix.uix.uix.uix.codeinput.uix. 327 kivy.uix.camera.gridlayout.stacklayout.filechooser.modalview.boxlayout.progressbar.settings.checkbox. 291 kivy.popup. 288 kivy. 270 kivy. 276 kivy. 315 kivy. 332 kivy. 268 kivy.scatter.uix.uix. 286 kivy.spinner. 283 kivy. 305 kivy. 287 kivy. 330 kivy.uix.uix. 307 kivy.uix. 262 kivy.uix.video. 322 kivy.stencilview. 259 kivy.relativelayout.kivy.tabbedpanel.videoplayer. 272 kivy.uix.uix.uix.uix. 273 kivy.uix.uix.uix.image.uix. 258 kivy.uix. 336 kivy.layout. 308 kivy. 153 kivy.screenmanager.rst.uix. 309 kivy.uix.carousel.slider.switch.textinput.uix.vector. 266 kivy.uix.button.togglebutton.treeview.uix.label. 263 kivy. 311 kivy.uix.vkeyboard.floatlayout. graphics.graphics. angle (kivy.texture.Widget method). a (kivy. 199 Accordion (class in kivy. 224 add_postproc_module() a (kivy.properties).anchorlayout.core.graphics.vertex_instructions.anchorlayout).EventLoopBase allow_fullscreen (kivy.gesture.AnchorLayout method). add_screen() (kivy.Rotate attribute). 310 337 add() (kivy. 167 add_mipmap() (kivy. 131 277 add_handler() (kivy.uix.Settings AnchorLayout (class in kivy. adddefaultsection() (kivy.window.Texture method). 189 add_point() (kivy.uix.add_reload_observer() (kivy. 196 method).GestureStroke method).graphics.Switch atadd_widget() (kivy. 200 method). angle() (kivy. 301 257 add_kivy_panel() (kivy.Canvas attribute). 280 method).settings.config.TransitionBase 257 method).InstructionGroup after (kivy.graphics.gesture.INDEX A method).fbo.widget.image.vertex_instructions. 295 AccordionItem (class in kivy.ImageData anchors (kivy.Settings anchors (kivy.AnchorLayout method).uix.instructions.context_instructions.graphics.gl_instructions. 129 attribute).EventLoopBase method).uix. 193 125 AliasProperty (class in kivy.EventLoopBase anchor_y (kivy.Ellipse attribute).ClearColor atadd_reload_observer() (kivy.graphics.graphics.InstructionGroup method).treeview.MarkupLabel atmethod). 333 add_gesture() (kivy.checkbox.Color attribute).accordion).gesture.base. 197 323 angle (kivy.graphics. 191 (kivy.Switch attribute).Image attribute).uix.graphics.uix.WindowBase active (kivy.Color atadd_reload_observer() (kivy.accordion.uix.switch.instructions.TreeView method).Ellipse attribute). after (kivy.uix.uix. 163 add_node() (kivy.uix.base.uix. tribute). 182 a (kivy.graphics.uix. 170 active_norm_pos (kivy.videoplayer.ConfigParser method).GestureDatabase allow_stretch (kivy.graphics.accordion).uix.ConfigParser 183 method).anchorlayout. 255 accordion (kivy.core. 302 tribute).ClearColor attribute).VideoPlayer method). 188 add_point() (kivy.settings.CheckBox attribute).core. 125 add() (kivy.Point method).graphics. 130 add_widget() (kivy.Fbo tribute). 154 131 angle_end (kivy. tribute).base.Vector method). 255 216 AccordionException (class in kivy.switch.graphics.graphics.graphics.graphics.markup.context_instructions.Rotate attribute).Gesture method). 220 351 .config.vector. method).text.Fbo tribute). 267 add_stroke() (kivy. 310 method). 128 attribute).AccordionItem at.base. 180 method). 182 add_point() (kivy.ExceptionManagerBase anchor_x (kivy.uix.uix.label. 258 add_input_provider() (kivy.Canvas attribute). 150 add_event_listener() (kivy.uix. 192 add_callback() (kivy.uix.image. 128 attribute).uix.Label attribute).accordion). method). 181 128 a (kivy. 255 active (kivy.screenmanager.Point angle_end (kivy. 258 add_json_panel() (kivy. accordion.angle_start (kivy.uix.uix.uix.app).motionevent. 200 attribute).ModalView apply_transform_2d() (kivy. 317 attach_to (kivy.modalview.modalview.ScrollView attribute).Button atAtlas (class in kivy.TextInput tribute).scrollview. 140 background_color (kivy. 333 attribute). 220 available_layouts (kivy.uix.uix.uix. 181 anim_func (kivy.image).b (kivy.core.input.uix.Canvas method).Animation background (kivy.VKeyboard atattribute).scrollview.uix.Accordion at.vkeyboard.context_instructions.uix.animation.bubble.Bubble ask_update() (kivy. 197 attribute). 227 background_color (kivy.videoplayer.DropDown atangle_start (kivy.textinput.uix.Bubble atappend() (kivy. 328 App (class in kivy. 269 attribute). 298 tribute). 328 162 axis (kivy.ModalView attribute).graphics.Button atask_update() (kivy.b (kivy.vertex_instructions.graphics. background_color (kivy.graphics.uix.TextInput method).Cache static method).ModalView at. 255 attribute).uix.dropdown. 285 method).scrollview.Rotate atanim_cancel_duration (kivy.button. 317 annotations (kivy.VideoPlayer at.Scatter attribute).Bubble attribute).uix.Callback method).button.uix.BuilderBase method). 329 arrow_pos (kivy.uix.uix.carousel. 265 background (kivy.scatter. 285 animated_properties (kivy.instructions.tabbedpanel.uix.carousel. 261 ask_update() (kivy. 263 179 background_image (kivy.tabbedpanel.vkeyboard.uix.MotionEvent attribute).lang. 112 background_color (kivy. 182 auto_width (kivy.Color attribute).graphics. 119 tribute).AccordionItem auto_bring_to_front (kivy. 277 anim_duration (kivy.graphics.uix. 99 background_active (kivy.Callback background_image (kivy.graphics. 263 attach_to (kivy.uix.ScrollView at- B 352 .Carousel tribute).Image attribute).Scatter tribute).atlas).uix.accordion.textinput. 195 attribute). 263 method).dropdown.uix.Canvas background_normal (kivy.graphics.background_selected tribute). 317 arrow_image (kivy. 118 tribute).VKeyboard anim_available (kivy.DropDown at.textinput.Image method).uix.graphics.bubble.gl_instructions.uix.image. attribute). 328 Animation (class in kivy. 193 attribute).ClearColor atanim_move_duration (kivy. 313 (kivy.Image attribute). 313 ask_update() (kivy. 162 anim_delay (kivy.instructions.image. 196 anim_index (kivy.bubble.VKeyboard tribute).Button atapply_transform() (kivy.Ellipse attribute). 100 attribute). 265 axis (kivy.TextInput AnimationTransition (class in kivy.uix. 180 attribute). 238 attribute). 261 apply() (kivy.bubble.ScrollView atauto_dismiss (kivy.graphics. 269 attribute).image.uix.uix.ScrollView atauto_scroll (kivy. 285 (kivy.modalview.scrollview.accordion.scatter.animation).Rotate attribute).Image attribute).background_normal (kivy.core. 285 bar_margin (kivy.ClearColor attribute).uix.uix.VKeyboard 261 attribute).background_border (kivy. 189 anim_delay (kivy.modalview. 261 background_down (kivy.accordion.vkeyboard.uix.button.vkeyboard. 191 tribute). 298 tribute).image.ModalView atanim_reset() (kivy. 297 bar_width (kivy.AccordionItem method).MotionEvent background_color (kivy.uix.image.Bubble attribute).TabbedPanel method). tribute).context_instructions. 290 background_color (kivy.uix.core. 162 b (kivy.Ellipse tribute).uix.Accordion at. 255 b (kivy.Carousel tribute).uix. 255 tribute). 162 tribute).Color attribute).uix.graphics.uix.uix.cache.input.graphics.core.TabbedPanel apply_transform_2d() attribute). 278 background_normal (kivy. 99 tribute).graphics.Image attribute).animation). 255 AsyncImage (class in kivy. 290 bar_color (kivy. properties).graphics.Animation blit_buffer() (kivy. 185 callback (kivy.Bubble attribute).Texture method).animation.uix.context_instructions). 182 cancel() (kivy.graphics.graphics.bubble. 178 Bezier (class in kivy.graphics. 194 Bezier (class in kivy.bubble).graphics. 99 196 cancel_property() (kivy.graphics. attribute).boxlayout). 149 children (kivy.Line attribute).uix. 112 C 353 .uix.Line tribute).Line at. 222 Camera (class in kivy.App method).Canvas attribute).animation.app. 140 before (kivy.uix.BoundedNumericProperty CheckBox (class in kivy. 112 circle (kivy. kivy. 317 217 Canvas (class in kivy.camera).uix.TextInput attribute). 263 tribute).Texture attribute).gesture. 185 border (kivy.VKeyboard atbezier_precision (kivy.button).uix. 313 170 border (kivy.Line attribute). 261 cap_precision (kivy. 152 center_y (kivy.Widget attribute).label.spelling.graphics.WindowBase attribute). 265 border (kivy.graphics.vertex_instructions).graphics. 141 before (kivy. method).vertex_instructions. 149 canvas (kivy.uix.vkeyboard.center (kivy.FileChooserController bind() (kivy.texture.core. 338 BoundedNumericProperty (class in check() (kivy.vertex_instructions.Texture method). 250 217 circle (kivy.graphics.urlrequest. 126 CameraBase (class in kivy. 267 attribute).graphics.properties. 261 children (kivy.Label attribute).animation. 259 tribute).instructions.core.lang). 337 BorderImage (class in kivy.cache). 99 bind() (kivy.event.button.Animation method).window. 280 Canvas (class in kivy.app.Widget attribute).scatter.uix.utils).BorderImage cap (kivy. 272 BindTexture (class in cancel_all() (kivy.core.fbo.lang).graphics.Line attribute). Cache (class in kivy.Button (class in kivy. 317 center (kivy. 222 169 bezier_precision (kivy.SpellingBase method). 160 bind() (kivy.uix. 222 285 Carousel (class in kivy. 220 center_x (kivy.uix.graphics).widget.Animation static kivy. 185 build() (kivy.graphics.window. 264 bind() (kivy. 119 225 Callback (class in kivy.properties).Property method).graphics.graphics.network.camera). 220 tribute).graphics).UrlRequest bufferfmt (kivy.uix.uix. 270 bind() (kivy.uix.tribute).uix.uix.Keyboard attribute).graphics.FileChooserProgressBase BindTexture (class in kivy.GestureStroke BorderImage (class in method). 222 border (kivy.uix. 262 chunk_size (kivy. 179 bold (kivy.Widget attribute).graphics.Texture method).Line atattribute).uix.widget.WindowBase atBoxLayout (class in kivy. 298 Builder (in module kivy. 338 BubbleButton (class in kivy. 199 cancel() (kivy.carousel).properties.vertex_instructions.graphics). 178 method). tribute).app.uix.graphics).graphics.uix. 140 bbox (kivy.App method). 149 164 bounds (kivy.TextInput blit_data() (kivy.BorderImage attribute).graphics.Fbo method).graphics.graphics.uix.callback (kivy.widget.Canvas at. 185 border (kivy.vertex_instructions.vertex_instructions). 99 method). 216 cancel_selection() (kivy. 193 BooleanProperty (class in kivy. 179 cap (kivy. 194 bezier (kivy.ModalView attribute). 329 attribute).tabbedpanel.vertex_instructions.lang).Button attribute).filechooser.EventDispatcher method).TabbedPanel at. 337 boundary() (in module kivy.graphics).uix.core.graphics.texture. 131 kivy.checkbox).core.Widget attribute).bubble).Fbo method).vertex_instructions.filechooser.graphics. attribute).instructions).modalview. 263 cap_precision (kivy.uix. 180 BuilderException (class in kivy. 179 bezier (kivy.graphics. 112 tribute).widget. 178 center_stroke() (kivy.texture.textinput.Scatter attribute).Line border (kivy. method).Line atbuild_config() (kivy. 337 border (kivy.Line attribute).window. 185 Callback (class in kivy.Line attribute).graphics. 148 cancel() (kivy.uix.textinput. 216 method). 170 Bubble (class in kivy. 290 BuilderBase (class in kivy. tribute).texture. 222 build_settings() (kivy.instructions).Widget attribute).widget.App method). graphics. 338 183 Color (class in kivy.uix.Bubble attribute). 342 attribute).Fbo attribute).treeview.uix.input.uix.rst. 280 clear_color (kivy. 256 CodeInput (class in kivy.Settings attribute).graphics. col_default_width (kivy.clock). 166 171 content_size (kivy. 181 col_force_default (kivy.graphics.TreeViewNode 191 attribute).widget.core.uix. 200 cols (kivy. 125 clear_stencil (kivy.instructions).RstDocument attribute).ClearBuffers at.texture.Widget method).uix.GridLayout clear_depth (kivy.instructions.uix.Widget clear() (kivy. 269 kivy. 192 195 clear_buffer() (kivy. 201 ConfigParser (class in kivy. 122 content (kivy.core.DropDown atClearBuffers (class in tribute).popup.LabelBase attribute).graphics.ClearBuffers attribute). collapse_alpha (kivy.AccordionItem at.settings. 192 collapse (kivy.uix.gl_instructions.gl_instructions. close_settings() (kivy.uix. 329 method).graphics.EventLoopBase method).context_instructions). clear_color (kivy.Fbo method). counter (kivy.graphics).App method).Widget attribute).core.uix. 275 191 cols_minimum (kivy.ClearBuffers attribute).app.uix.accordion. 325 clear_color (kivy.text.config).ClearBuffers colors (kivy.gridlayout.graphics). 113 166 cls (kivy.TabbedPanelHeader tribute).Recorder attribute).tabbedpanel.uix.uix. 223 attribute).core.graphics.MotionEvent method).graphics.gl_instructions). 227 collide_margin() (kivy. 354 .uix. method). 199 217 clear_color (kivy. tribute).Fbo attribute). 302 ClockBase (class in kivy.clear() (kivy.codeinput). 268 content_width (kivy. 186 tribute). 171 303 Clock (in module kivy.dropdown.App attribute).ClearBuffers 302 attribute).Widget method).uix. 338 content_size (kivy.graphics.graphics. 262 200 content (kivy.uix.WindowBase method). 125 clear_widgets() (kivy. content (kivy. 256 ClearColor (class in kivy.graphics.input. 256 copy_to() (kivy.gl_instructions).uix.graphics.uix. 315 close() (kivy.scrollview.graphics. 191 attribute).fbo.clock). 191 container (kivy. 113 tribute).label. 200 container_title (kivy.tabbedpanel. 277 clear_buffer() (kivy. 182 color (kivy.LabelBase atclose() (kivy.gridlayout.accordion.Popup attribute).InstructionGroup Color (class in kivy.vertex_instructions.GridLayout ContextInstruction (class in attribute).VKeyboard copy_to() (kivy.WindowBase at.uix.AccordionItem ClearColor (class in kivy.config).bubble.core.uix.uix.Label attribute).InstructionGroup method).config (kivy.WindowBase method).accordion.graphics).graphics. 275 kivy. 199 color (kivy.uix.gl_instructions.graphics. 200 Config (in module kivy.input.graphics).vkeyboard. clear_depth (kivy. 238 collide_point() (kivy.content (kivy.GridLayout attribute).Image attribute).SettingsPanel attribute).app.ClearBuffers attribute). 338 171 collide_widget() (kivy.uix.uix.accordion.AccordionItem cm() (in module kivy.settings.content (kivy.convert_distance_to_scroll() tribute).LabelBase attribute). 128 content_height (kivy.gridlayout.GridLayout 166 attribute). clear_stencil (kivy.AccordionItem at338 tribute).graphics.settings.fbo. color_selected (kivy.text.window.motionevent. 122 content (kivy.Texture attribute).Fbo method).graphics.uix.graphics. 275 attribute).accordion.ScrollView method).uix.uix. 275 ContextInstruction (class in kivy.AccordionItem 298 attribute). method).core. container (kivy.widget.image.uix.graphics.MotionEvent method). 314 close (kivy.Line attribute).TabbedPanel atclose (kivy.base.window.text.metrics). 256 ClearBuffers (class in kivy.SettingItem attribute). tribute).recorder.window. 256 (kivy.graphics.gridlayout.Line at. 183 colorfmt (kivy. 144 attribute).uix.widget. 180 clear() (kivy. 287 clearcolor (kivy. 191 config (kivy.widget. 186 attribute).settings.MotionEvent attribute).Scatter attribute). 318 (kivy.providers.Texture delete_selection() method).UrlRequest 318 method).base.uix.disabled (kivy.uix.Bezier attribute).EventDispatcher depack() method).motionevent. 225 (kivy.uix.DropDown cursor_col (kivy.window.uix.uix.Metrics method).metrics.WindowBase device (kivy. 238 method).direction (kivy. 318 cursor_row (kivy.SettingItem attribute). 314 217 default_tab_text (kivy.textinput.utils). 269 318 (kivy.Bezier attribute).TextInput at. 302 (kivy.core.uix. 290 default_tab (kivy.tabbedpanel.app. decode_result() (kivy. 238 dash_length (kivy.dispatch() (kivy.graphics. 294 current_slide (kivy.TextInput dismiss_on_select (kivy.tabbedpanel. 318 dash_offset (kivy. 265 current_tab (kivy.uix.uix.MotionEvent dash_length (kivy.uix. 314 D 355 .properties).uix.carousel.tabbedpanel. 113 dirselect (kivy.graphics.uix.graphics.textinput.Bezierdo_cursor_movement() attribute).utils).TextInput dismiss() method).textinput.EventLoopBase tribute).vertex_instructions. 318 cursor_offset() (kivy.tuio.TextInput create_from_data() (kivy.ModalView cursor_index() (kivy.TuioMotionEventProvider attribute).input. dash_offset (kivy. 290 dash_offset (kivy.Carousel at.do_scale (kivy.Vector method). 163 do_redo() (kivy. 250 do_rotation (kivy.carousel. 126 create_trigger() (kivy.properties.uix.MotionEvent create_property() (kivy.input.ScreenManager DictProperty (class in kivy.uix.uix.TextInput attribute).Line 318 attribute).graphics.graphics.input.textinput.Layout method).TabbedPanel at.uix.Line attribute). 217 create_json_panel() (kivy.uix.ScreenManager 265 attribute).FileChooserController tribute).textinput. dismiss() method). 128 distance() (kivy.uix.Line do_backspace() (kivy.Atlas static method).dispatch() (kivy. 155 attribute).graphics. 285 method). 227 method). 303 tribute). 144 depack() (kivy.texture.MotionEvent method).uix. current_screen (kivy.TextInput attribute).uix.Bezier distance() (kivy.uix.graphics. 186 method).Carousel attribute).textinput.image.textinput.uix.TextInput attribute).default_tab_cls (kivy.uix.vertex_instructions.urlrequest.settings.atlas.vector. default_tab_content (kivy.textinput.uix.SettingItem attribute).graphics.TabbedPanel create() (kivy.uix.uix. 318 method).input. 314 create() (kivy.tabbedpanel.TextInput at.uix.core.Vector method).TextInput method). 303 122 create_window() (kivy.Line attribute).clock. 314 static method).EventDispatcher method).dropdown. 225 distance2() (kivy.uix.TabbedPanel at.TextInput method).TabbedPanel 236 attribute). 317 cursor_blink (kivy.event. 223 do_layout() (kivy.vertex_instructions.uix.scatter.uix. 126 tribute).dropdown.Settings density() (kivy.screenmanager.Scatter attribute).vector.tabbedpanel.screenmanager.Scatter dash_offset (kivy. 314 attribute).screenmanager. 152 desc (kivy.MotionEvent method).filechooser.event.directory (kivy.input.textinput.uix.ImageData attribute).layout.SlideTransition attribute). 269 method).motionevent. 291 tribute).Property method). 223 method).modalview. 151 difference() (in module kivy.TextInput at.Texture method).uix. 118 create() (kivy.DropDown attribute). 155 dash_length (kivy. 296 tribute). 152 attribute).texture. 148 dispatch_input() (kivy.scatter. 234 (kivy.ClockBase method).uix. deprecated() (in module kivy. 178 distance() (kivy. 227 dash_length (kivy.textinput.TabbedPanel attribute). 270 cursor (kivy.scatter.vertex_instructions.App attribute). 318 method). 283 data (kivy.textinput.motionevent. 171 current (kivy.graphics.network. 238 method).graphics.settings. 318 cursor_pos (kivy. 294 direction (kivy. 178 do_collide_after_children (kivy.input. uix.vertex_instructions).atlas.filechooser).uix.graphics. 336 kivy. 129 dropdown_cls (kivy.uix.VKeyboard at.filechooser. 223 do_undo() (kivy. 227 EventLoop (in module kivy.motionevent.Canvas ExceptionHandler (class in kivy.uix. 271 dot() (kivy. 342 method). 118 tribute).filechooser).Sound attribute). 127 tribute).screenmanager.Animation attribute).uix.base. ensure_window() (kivy.dropdown).uix.FileChooserController tribute). 144 tribute). 291 tribute). 159 E F 356 .Scatter at.spinner.factory). 238 296 dsz (kivy.treeview.TransitionBase kivy.metrics). 250 attribute).input.base).motionevent. 181 291 Ellipse (class in kivy.motionevent.core.scrollview.audio.filechooser). 243 draw() (kivy.FileChooserListView (class in tribute).exit() (kivy.uix.Metrics method).gesture.Atlas attribute).MotionEvent tribute). 271 168 FileChooserController (class in duration (kivy.base).textinput. tribute).instructions.FileChooserController duration (kivy.FileChooserController tribute).loader.filename (kivy.graphics).VideoPlayer at.Gesture method). 270 duration (kivy.base).vkeyboard.TreeViewNode atdpi() (kivy.uix.input.event).graphics. 180 tribute).utils). 153 171 even_color (kivy. 238 exc_info (kivy.MotionEvent at. 238 error_image (kivy.dy (kivy.uix.Line attribute). 144 EventDispatcher (class in kivy.uix. 128 docked (kivy.LoaderBase attribute). 194 ExceptionManager (in module kivy. 270 attribute).debug.Video attribute).video.input.input.fake_exc_info() (in module kivy.network.lib.WindowBase method).screenmanager).scatter.graphics. 291 ellipse (kivy. 269 ExceptionManagerBase (class in kivy.uix.Spinner at.TextInput method).uix. 238 filename (kivy.FadeTransition (class in kivy.uix.entry_released() (kivy. 329 method). do_translation_x (kivy.uix.Scatter at220 tribute).graphics.VideoPlayerAnnotation FileChooserProgressBase (class in attribute).Vector method). 243 tribute).MotionEvent at. 272 dx (kivy.uix. 126 dpos (kivy.ScrollView attribute).uix. 270 duration (kivy. 298 do_translation (kivy.motionevent. attribute).base. 199 100 file_encodings (kivy.scatter.metrics.Canvas method).input.filechooser).input.metrics.MotionEvent at. 298 tribute).base).MotionEvent attribute).Video attribute). 271 document_root (kivy.Scatter attribute).uix. 182 duration (kivy. 130 dsy (kivy.motionevent.vertex_instructions. 238 do_scroll_y (kivy.scrollview.ellipse (kivy.VideoBase attribute).UrlRequest atdouble_tap_time (kivy.filechooser.EventLoopBase method).uix. 127 dpos (kivy. 333 kivy.motionevent.EventLoopBase 318 method).MotionEvent at. 331 dot_product() (kivy.window. 130 error (kivy.uix. 325 dpi_rounded() (kivy.video. escape_markup() (in module kivy.uix.filechooser.base). 238 do_scroll_x (kivy.videoplayer. 128 method).RstDocument at.uix.animation.input.videoplayer.do_scroll (kivy.MotionEvent attribute). 155 eos (kivy. 238 Factory (in module kivy.ProcessedTraceback atdraw() (kivy. 144 115 dpi() (kivy.ScrollView at. 331 kivy.input.debug).core.scatter. 186 do_translation_y (kivy.graphics.video.Metrics method).urlrequest.MotionEvent attribute). Fbo (class in kivy.uix.motionevent.graphics.uix.scrollview.input.dz (kivy. 295 FileChooserIconView (class in duration (kivy. dp() (in module kivy.MotionEvent attribute).uix.uix.vector.fbo).entry_touched() (kivy. 129 DropDown (class in kivy.rst. 238 Fbo (class in kivy. 298 tribute).motionevent.EventLoopBase (class in kivy.ScrollView at.core.graphics). 128 tribute).Line attribute).lib. Ellipse (class in kivy. 307 dsx (kivy. uix.graphics.core.core. 122 get_color_from_hex() (in module kivy.TextInput method).App method).textinput. get() (kivy. 122 method). 149 tribute).ImageData attribute).Image attribute).TextInput attribute).utils). 130 GestureStroke (class in kivy.window.graphics.app. 113 attribute).Cache static method).Sound method). 131 get_rigid_rotation() (kivy.get_min() (kivy.treeview.text. 171 fullscreen (kivy.text.uix.NumericProperty font_name (kivy.uix. 241 filename (kivy. 280 (kivy. 131 get_root_window() (kivy.get_format() method).get_mipmap() method). 338 tribute). 271 get_application_icon() (kivy. 144 foreground_color (kivy.gesture).Label attribute).clock.FileChooserController get_application_name() (kivy.input.clock. 164 focus (kivy.app.WindowBase at. 119 G 357 .textinput. 130 method).label.uix.get() (kivy.core.cache. filter_dirs (kivy. 229 filename (kivy.core.uix.clock. 192 fontscale() (kivy. 212 fs (kivy.FileChooserController get_application_config() (kivy.get_cursor_from_index() (kivy. FloatLayout (class in kivy.App method). 271 find() (kivy. 181 (kivy. 200 get_region() (kivy.core. 119 tribute).widget.LabelBase method). 163 319 flip_vertical() (kivy.Widget get() (kivy.core.gesture).uix. 273 319 fmt (kivy.properties. 183 319 get_group() (kivy.postproc.graphics.ClockBase method).FileChooserController tribute).videoplayer.textinput.uix.context_instructions.filechooser.uix.gl_instructions.gesture.filechooser.LabelBase attribute).Label attribute). 166 method).WindowBase method).uix. 319 get_extents() (kivy. 196 g (kivy. get() (kivy.factory. 250 171 flip_vertical (kivy.graphics. 217 gesture_to_str() (kivy. 296 (kivy.get_lastaccess() (kivy.ShaderTransition at. 280 (kivy.VideoBase attribute).textinput. 271 get_node_at_pos() (kivy. 131 method).ClockBase attribute).gesture.uix.properties.textinput.uix.properties.cache.App method).Property method).ClockBase method).image. (kivy.input.texture.TextInput attribute).image.uix.get_parent_window() method). get_group() method).TextInput at. 160 get_random_color() (in module kivy.ClockBase method). 122 method).instructions.uix. 149 fs (kivy.gesture).utils). 191 method).Color at.core.uix. 148 236 files (kivy.Texture get_cursor_from_xy() method).ClearColor at.graphics.settings. 334 method).image. 164 tribute).gesture.window.Cache static method). 229 get_connection_for_scheme() flip() (kivy.floatlayout).ClearColor attribute).BoundedNumericProperty frametime (kivy.properties.widget.clock.get_nice_size() (kivy.graphics.InstructionGroup font_size (kivy.VideoPlayer at.texture. 319 get_max() (kivy.graphics.urlrequest.core. 152 find_double_tap() (kivy.doubletap.TreeView method).recorder.core.BoundedNumericProperty method). 166 font_name (kivy. 113 attribute).uix. 122 font_size (kivy.Color attribute).filechooser.Recorder attribute).Settings g (kivy.uix.textinput.uix.input.InstructionGroup fontid (kivy. tribute).TextInput method).filechooser.graphics.app.shader. 162 static method).uix.ImageData at.MotionEventFactory static 168 method). 319 get_fps() (kivy.network.metrics.video.screenmanager.MotionEventFactory filename (kivy. 323 get_panel_by_uid() (kivy.label.Metrics method). 271 filters (kivy.image.FileChooserController 113 attribute).ImageData fullscreen (kivy.core.TextInput at.InputPostprocDoubleTap method).graphics.Shader attribute). 152 tribute).Widget g (kivy. 217 (kivy. 131 get_boottime() (kivy.GestureDatabase method).input.GestureDatabase get_rfps() (kivy.Gesture GestureDatabase (class in kivy.uix. 149 tribute).Texture Gesture (class in kivy.audio.get_pos() (kivy.UrlRequest method). 302 g (kivy. opengl).app.opengl).opengl). glBindTexture() (in module kivy. 203 kivy.Cache static method).graphics.gesture.graphics.opengl). 203 202 glDisable() (in module kivy. 119 202 get_value() (kivy.opengl). get_screen() (kivy. getter() (kivy.opengl_utils). 203 gl_get_version_minor() (in module glCompressedTexSubImage2D() (in module kivy. 211 kivy.clock. 338 kivy. 203 gl_get_version_major() (in module glCompressedTexImage2D() (in module kivy.opengl). 203 kivy. 202 glDeleteRenderbuffers() (in module glBindAttribLocation() (in module kivy.opengl).opengl). 321 kivy. 203 202 glDeleteTextures() (in module glBindFramebuffer() (in module kivy.opengl).opengl).graphics.SettingsPanel glBufferSubData() (in module method). 126 202 gl_get_extensions() (in module glClearStencil() (in module kivy. 202 get_score() (kivy.uix. 210 kivy.opengl).graphics.config. 202 get_timestamp() (kivy. 202 125 glClearColor() (in module kivy.opengl). 122 kivy.graphics. 202 getdefault() (kivy.opengl).opengl_utils). 211 202 gl_get_version() (in module glCompileShader() (in module kivy. 202 glDepthFunc() (in module kivy.graphics. 203 gl_has_capability() (in module glCopyTexImage2D() (in module kivy.Gesture method).graphics. 203 kivy.togglebutton.opengl).opengl).opengl). glClear() (in module kivy. 203 gl_has_extension() (in module glCopyTexSubImage2D() (in module kivy.graphics.graphics.graphics.graphics.graphics. 211 kivy. kivy. 203 kivy. 210 kivy.opengl_utils). 202 get_running_app() (kivy. 202 glDeleteProgram() (in module glAttachShader() (in module kivy.graphics. 203 gl_has_texture_conversion() (in module glCreateProgram() (in module kivy. 211 kivy.method).graphics.opengl_utils).opengl).opengl).opengl).graphics.ClockBase method).opengl).settings.graphics.graphics. 211 kivy.graphics. 131 glBlendFunc() (in module kivy.opengl).graphics.opengl_utils). 211 glDeleteBuffers() (in module gl_register_get_size() (in module kivy. 210 202 gl_get_texture_formats() (in module glColorMask() (in module kivy.ConfigParser method).uix.opengl).graphics.opengl). 203 gl_has_texture_format() (in module glCreateShader() (in module kivy. 203 202 glDetachShader() (in module glBlendColor() (in module kivy.graphics.opengl_utils). 203 kivy. 203 gl_has_texture_native_format() (in module glCullFace() (in module kivy.opengl).opengl).graphics.graphics. 302 kivy.opengl).screenmanager.graphics.graphics.event.graphics.graphics.ToggleButton glCheckFramebufferStatus() (in module static method).opengl_utils).opengl_utils).opengl).graphics.graphics.opengl_utils). 203 glBlendEquation() (in module glDisableVertexAttribArray() (in module 358 .ScreenManager 202 method).opengl). glBufferData() (in module kivy.opengl).graphics.graphics. kivy. 202 glDeleteShader() (in module glBindBuffer() (in module kivy.opengl).graphics.opengl).graphics.opengl_utils).graphics. glBlendEquationSeparate() (in module 113 kivy.uix. 203 kivy.graphics. 294 glBlendFuncSeparate() (in module get_time() (kivy.opengl). 202 glDepthMask() (in module kivy. 210 glDeleteFramebuffers() (in module glActiveTexture() (in module kivy.EventDispatcher method). 202 get_widgets() (kivy.graphics. kivy.graphics. 211 kivy.graphics.cache.opengl_utils). glBindRenderbuffer() (in module 203 kivy.graphics.graphics.opengl).graphics.opengl). kivy.graphics.App static method).graphics.graphics.graphics.graphics.opengl).graphics.opengl).graphics.opengl). opengl). 205 glGetShaderInfoLog() (in module kivy. 203 glDrawArrays() (in module kivy.opengl). 204 glGenerateMipmap() (in module kivy. 204 glGetBooleanv() (in module kivy.opengl).graphics.graphics.opengl).opengl). 206 glIsEnabled() (in module kivy.opengl). 206 glGetUniformLocation() (in module kivy.opengl). 206 glLinkProgram() (in module kivy.graphics.graphics.graphics.graphics.graphics.graphics.opengl). 204 glGetActiveUniform() (in module kivy.graphics.opengl). 204 glGenBuffers() (in module kivy.graphics.graphics.graphics.opengl).opengl).graphics.graphics.opengl).opengl).graphics.opengl).graphics.opengl). 206 glIsBuffer() (in module kivy.graphics.opengl).graphics.graphics. 207 glScissor() (in module kivy.graphics. 206 glPolygonOffset() (in module kivy.graphics.graphics.graphics. 206 glIsFramebuffer() (in module kivy.opengl).graphics.opengl). 203 glEnableVertexAttribArray() (in module kivy. 204 glGetAttribLocation() (in module kivy.opengl).opengl).graphics. 204 glFlush() (in module kivy.opengl). 205 glGetFramebufferAttachmentParameteriv() (in module kivy. 204 glGenRenderbuffers() (in module kivy.opengl).graphics.opengl).graphics.opengl). 205 glGetProgramiv() (in module kivy. 206 glLineWidth() (in module kivy. 203 glEnable() (in module kivy. 204 glGenTextures() (in module kivy.opengl).graphics. 206 glGetVertexAttribPointerv() (in module kivy.opengl).graphics. 204 glGetAttachedShaders() (in module kivy.opengl).opengl).graphics.graphics. 204 glFramebufferTexture2D() (in module kivy.opengl).graphics.graphics.graphics.graphics. 203 glDrawElements() (in module kivy. 205 glGetProgramInfoLog() (in module kivy.graphics.opengl).opengl). 204 glGetBufferParameteriv() (in module kivy. 206 glRenderbufferStorage() (in module kivy.opengl).graphics.graphics.graphics.graphics.opengl).graphics. 204 glFrontFace() (in module kivy. 206 glPixelStorei() (in module kivy. 206 glReleaseShaderCompiler() (in module kivy. 205 glGetIntegerv() (in module kivy. 204 glGetError() (in module kivy.opengl).graphics. 206 glIsTexture() (in module kivy. 206 glGetVertexAttribiv() (in module kivy.graphics.opengl).opengl).kivy. 206 glReadPixels() (in module kivy. 207 glShaderBinary() (in module kivy. 204 glFinish() (in module kivy.graphics.opengl). 205 glGetTexParameteriv() (in module kivy.opengl).opengl). 204 glGenFramebuffers() (in module kivy.opengl).graphics.opengl).graphics. 204 glGetActiveAttrib() (in module kivy.graphics.graphics.opengl).opengl).opengl). 206 glGetUniformiv() (in module kivy.opengl). 206 glIsProgram() (in module kivy.opengl).graphics.graphics. 205 glGetFloatv() (in module kivy. 206 glIsShader() (in module kivy.graphics.graphics.opengl). 204 glFramebufferRenderbuffer() (in module kivy. 205 glGetString() (in module kivy.opengl). 205 glGetShaderiv() (in module kivy. 205 glGetTexParameterfv() (in module kivy.opengl).graphics.graphics. 205 glGetShaderSource() (in module kivy.opengl).graphics.opengl). 206 glIsRenderbuffer() (in module kivy. 205 glGetShaderPrecisionFormat() (in module kivy. 207 glSampleCoverage() (in module kivy.opengl). 205 glGetUniformfv() (in module kivy.opengl). 205 glGetRenderbufferParameteriv() (in module kivy. 206 glHint() (in module kivy.graphics.opengl).graphics.graphics.opengl).opengl).opengl). 207 glShaderSource() (in module 359 .graphics.opengl).opengl). 206 glGetVertexAttribfv() (in module kivy. 210 glVertexAttrib4fv() (in module kivy.base.opengl). 209 glVertexAttrib3f() (in module kivy.graphics.graphics.opengl). 276 group (kivy.opengl). 209 glUniform4iv() (in module kivy.graphics. 207 glTexImage2D() (in module kivy.graphics.opengl).graphics. 207 glTexParameteri() (in module kivy. 208 glUniform3f() (in module kivy. 267 group (kivy. 208 glUniform2f() (in module kivy.uix.opengl). 207 glStencilOpSeparate() (in module kivy.graphics.graphics.opengl).opengl). 209 glUniformMatrix2fv() (in module kivy.input.opengl).checkbox. 209 glVertexAttrib2f() (in module kivy.graphics. 208 glUniform4f() (in module kivy.gridlayout).opengl).graphics.graphics.ExceptionHandler method).opengl). 209 glVertexAttrib3fv() (in module kivy.graphics.opengl).rst.opengl).opengl). 209 glVertexAttrib1fv() (in module kivy.opengl). 225 GridLayout (class in kivy. 183 GraphicException (class in kivy. 208 glUniform1fv() (in module kivy.vertex_instructions).graphics.MotionEvent method).graphics.graphics.graphics.uix.opengl).opengl). 209 glValidateProgram() (in module kivy. 129 360 . 208 glUniform4fv() (in module kivy. 209 glUseProgram() (in module kivy. 196 halign (kivy. 342 grab() (kivy.graphics. 210 goto() (kivy.uix.graphics.graphics.graphics.opengl).graphics.opengl).opengl).uix.graphics.opengl).opengl).opengl).motionevent. 209 glUniformMatrix3fv() (in module kivy.graphics.opengl). 207 glTexParameteriv() (in module kivy. 208 glUniform2fv() (in module kivy.graphics.label.uix.graphics.opengl). 209 glVertexAttrib2fv() (in module kivy.ToggleButton attribute).graphics.graphics. 207 glStencilFuncSeparate() (in module kivy.MotionEvent attribute).graphics. 275 GridLayoutException (class in kivy.Color attribute).graphics. 210 glVertexAttribPointer() (in module kivy.graphics.CheckBox attribute).graphics.motionevent.graphics.opengl).graphics.uix.MotionEvent method). 227 grab() (kivy.graphics. 208 glUniform2i() (in module kivy. 208 glUniform3iv() (in module kivy.opengl).gridlayout). 207 glTexSubImage2D() (in module kivy.input.input.graphics.opengl). 321 H h (kivy. 207 glUniform1f() (in module kivy. 208 glUniform2iv() (in module kivy. 181 h (kivy.opengl).graphics.opengl). 210 glViewport() (in module kivy.graphics.opengl).opengl).graphics).graphics. 280 handle_exception() (kivy.togglebutton. 238 grab_current (kivy. 207 glStencilMaskSeparate() (in module kivy.opengl). 208 glUniform4i() (in module kivy.graphics.graphics. 207 glStencilMask() (in module kivy.graphics.opengl). 208 glUniform3fv() (in module kivy.graphics.opengl).graphics. 209 glVertexAttrib4f() (in module kivy.opengl).graphics.opengl). 207 glStencilOp() (in module kivy.kivy.Color attribute).context_instructions. 208 glUniform3i() (in module kivy. 207 glTexParameterf() (in module kivy.graphics.opengl). 239 GraphicException (class in kivy.opengl). 207 glTexParameterfv() (in module kivy.Label attribute).opengl). 208 glUniform1i() (in module kivy.opengl).graphics. 209 glVertexAttrib1f() (in module kivy. 208 glUniform1iv() (in module kivy. 209 glUniformMatrix4fv() (in module kivy.graphics.graphics.opengl). 207 glStencilFunc() (in module kivy.opengl).RstDocument method).opengl).opengl). carousel.videoplayer. 129 (kivy.uix.App attribute). 225 ImageData (class in kivy.videoplayer.core.videoplayer.uix.animation.VideoPlayer 161 attribute).EventLoopBase method).input.in_bounce() (kivy. in_expo() (kivy. 181 static method).videoplayer.window.AnimationTransition static method).uix. 334 in_quart() (kivy.uix.graphics.image). 339 static method). 277 in_out_sine() (kivy. 239 in_out_quad() (kivy. 334 attribute).animation.indices (kivy.Image attribute).core. 104 image() (kivy.Mesh attribute). 102 hsv (kivy.Widget attribute). 102 hide_root (kivy. 113 static method).uix.animation.AnimationTransition 217 static method). 323 tribute).uix. 103 tribute).app.AnimationTransition static method).VideoPlayer in_quad() (kivy.animation.Camera attribute).uix.base. 103 identity() (kivy.texture.AnimationTransition image_play (kivy. 102 tribute). 334 image_ratio (kivy.videoplayer. 103 id (kivy.Color at.animation.uix.Mesh tribute).graphics.AnimationTransition image (kivy.Matrix in_out_quart() (kivy.texture.graphics. 334 attribute). 334 index (kivy.core. 324 attribute). 164 in_cubic() (kivy.AnimationTransition static method).uix.graphics.camera.AnimationTransition 171 static method). 161 static method).Carousel attribute).core.image.uix.in_out_circ() (kivy.Image attribute). in_out_bounce() (kivy.animation.animation.videoplayer.AnimationTransition height (kivy.videoplayer.WindowBase attribute).indent_level tribute).ScrollView attribute).graphics.animation.image.Color attribute).VideoPlayer at.VideoPlayer in_quint() (kivy.VideoPlayer at. 265 index (kivy.AnimationTransition hbar (kivy.uix.animation.uix. 102 in_out_elastic() (kivy. 116 image_loading (kivy.Texture attribute). 155 I 361 . 277 inch() (in module kivy.in_sine() static method). 104 attribute).motionevent.ShapeRect attribute).vertex_instructions.CameraBase attribute).TreeView attribute). 100 InputPostprocDejitter (class in in_bbox() (kivy.core.LoaderBase method). 272 image_volumemuted (kivy.vector. 196 in_out_cubic() (kivy.treeview.in_out_expo() (kivy.ExceptionManagerBase static method).Image attribute).AnimationTransition static method). 219 static method). 128 in_out_quint() (kivy.uix.AnimationTransition static method). 100 method).animation.videoplayer. 264 image_volumemedium (kivy. 101 height (kivy.graphics. in_elastic() (kivy.animation.AnimationTransition icon (kivy.animation.Widget attribute). 101 height (kivy. 105 attribute).animation.uix.image). 334 (kivy.base.animation.uix.core. 334 image_pause (kivy.animation.scrollview.Vector static method).TreeView atimage_volumehigh (kivy. 187 indices (kivy.uix.image.animation.input.image.camera.animation. 105 tribute). 334 indent_start (kivy.FileChooserProgressBase tribute). 334 index (kivy.metrics).filechooser.videoplayer. image_volumelow (kivy.treeview.camera. 101 height (kivy.loader.treeview. 163 (kivy. 162 static method).uix.core.graphics. 217 id (kivy.core.widget. 103 idle() (kivy. 163 static method).AnimationTransition static method).VideoPlayer tribute).MotionEvent at.CameraBase in_back() (kivy. 101 height (kivy.VideoPlayer static method).AnimationTransition Image (class in kivy.VideoPlayer at.AnimationTransition image_overlay_play (kivy.AnimationTransition init_camera() method).animation.image).uix. 162 height (kivy.AnimationTransition id (kivy.animation. 338 static method). 298 in_circ() static method).Texture attribute).uix.ImageData attribute).widget.context_instructions.TreeView atimage_stop (kivy.shape. 241 in_out_back() (kivy.uix.transformation.index (kivy.AnimationTransition method).AnimationTransition 323 hsv (kivy.AnimationTransition handle_exception() (kivy. 144 (kivy.VideoPlayer at. 104 Image (class in kivy.animation. 104 attribute). 277 kivy.core. 152 tribute). 161 is_selected (kivy.WeakMethod keycodes (kivy.transformation.TreeView kivy.Keyboard is_color_transparent() (in module kivy. 325 kivy.camera (module).text. 116 is_finished (kivy.uix.vkeyboard.core.uix. method).spinner.uix.motionevent.uix.screenmanager.vkeyboard. 161 tribute).network. 169 is_dead() (kivy.core.Image attribute). 164 is_touch (kivy. 152 method).uix.event (module).retaintouch).textinput.core.window (module). 126 iterate_mipmaps() (kivy. 183 tribute).VKeyboard atmethod). 230 InputPostprocRetainTouch (class in joint (kivy.core.markup (module).image. 156 169 is_double_tap (kivy.core.settings.utils).Line insert() (kivy.graphics. 159 is_open (kivy.MotionEventkivy (module).uix.Spinner attribute).TreeView kivy.UrlRequest kivy. 120 tribute).ImageData kivy.animation (module).window).core. 329 is_active (kivy. 183 tribute).clipboard (module).VKeyboard atInstructionGroup (class in kivy.Matrix key_margin (kivy. 295 keycode_to_string() (kivy.vkeyboard.input.uix.VKeyboard atInstruction (class in kivy.cache (module).vertex_instructions.ignorelist). 168 method).graphics). 164 InputPostprocDoubleTap (class in iterate_open_nodes() (kivy. 229 method).TransitionBase Keyboard (class in kivy. 159 tribute). 303 install_twisted_reactor() (in module kivy.graphics. 329 InstructionGroup (class in key_background_normal kivy.core (module).utils). 224 183 joint_precision (kivy. 97 attribute).support). 219 tribute).core.postproc. 229 method).support).input.core. 329 inverse() (kivy.window. 162 tribute).MotionEvent at.dejitter).core. 239 kivy.doubletap).uix.Line method). 168 attribute). 186 kivy.core.label.graphics. 325 kivy.treeview.uix.interactive). 127 attribute).uix.atlas (module).audio (module).ext (module).graphics.InstructionGroup joint_precision (kivy.postproc.video (module).base (module). 127 kivy. 123 is_loaded (kivy.image.image.treeview.vkeyboard.uix. 250 kivy. 326 kivy.kivy. 175 J K 362 . 151 keep_data (kivy.kivy.kivy. key_background_down 192 (kivy.utils).event. 224 insert_text() (kivy.graphics.Keyboard attribute).uix.motionevent. 165 tribute).window.treeview.instructions).kivy. 98 is_event_type() (kivy.uix.TreeViewNode at.spelling (module).instructions).input. 307 kivy.kivy. 167 iterate_all_nodes() (kivy.uix.vkeyboard.SettingItem attribute).uix.urlrequest.Line attribute).input. 319 install_android() (in module kivy. 151 key (kivy.Label attribute).graphics.uix. 186 insert() (kivy.TreeViewNode at.treeview.TextInput method).core. 134 tribute). 192 (kivy.instructions. 192 attribute). 166 italic (kivy.graphics.graphics).graphics.treeview.uix.postproc.kivy.graphics. 152 key_border (kivy.vertex_instructions. 160 is_open (kivy. 324 kivy.text (module). 108 method).input.TreeViewNode at.treeview.core.app (module).input. 230 joint (kivy.gl (module). 325 kivy. 329 interpolate() (in module kivy.Line attribute). 277 install_gobject_iteration() (in module keep_ratio (kivy.image (module). key_background_color 151 (kivy. 239 kivy. attribute). 324 InputPostprocIgnoreList (class in kivy.config (module).Image attribute).VKeyboard atInteractiveLauncher (class in kivy.postproc.TreeViewNode at.VKeyboard atintersection() (in module kivy.clock (module). 329 Instruction (class in kivy. 118 is_leaf (kivy.uix.support).weakmethod.EventDispatcher kivy. 280 kivy.InstructionGroup method).core. postproc. 321 kivy.uix. 286 kivy.graphics.lib (module). 249 kivy.input.input.uix.uix.floatlayout (module).graphics.uix. 98 kivy_config_fn (in module kivy).recorder (module). 273 kivy.properties (module). 307 kivy. 315 kivy. 309 kivy.uix.wm_common (module).togglebutton (module).input.input. 97 363 .graphics.metrics (module). 231 kivy. 230 kivy. 296 kivy.filechooser (module).uix.graphics. 241 kivy.graphics.anchorlayout (module).uix.uix.modules. 231 kivy.dropdown (module). 144 kivy.graphics. 134 kivy.spinner (module).shader (module).input. 151 kivy. 253 kivy.widget (module). 198 kivy.checkbox (module).gridlayout (module).uix.uix.uix. 153 kivy. 327 kivy.input.keybinding (module).wm_pen (module).video (module).input.opengl_utils (module).scatter (module). 201 kivy.recorder (module). 332 kivy.uix. 200 kivy. 142 kivy. 145 kivy.graphics.providers.instructions (module).input. 230 kivy.mtdev (module).rst (module). 241 kivy. 195 kivy. 233 kivy.touchring (module). 231 kivy.uix.fbo (module). 152 kivy.boxlayout (module).modules.ignorelist (module). 305 kivy.uix.textinput (module). 245 kivy. 131 kivy. 330 kivy.postproc.tabbedpanel (module).providers.monitor (module).wm_touch (module).input. 98 kivy_configure() (in module kivy). 289 kivy.providers.uix.parser (module).lang (module).graphics. 192 kivy.stencilview (module).factory (module). 263 kivy.input.input. 130 kivy.transformation (module).context_instructions (module).weakmethod (module). 233 kivy. 151 kivy.postproc (module).debug (module).vector (module).providers.utils (module). 257 kivy. 322 kivy. 246 kivy.interactive (module).probesysfs (module).uix.providers.button (module). 177 kivy.input.uix.shape (module).uix.uix.stencil_instructions (module). 291 kivy.opengl (module). 268 kivy. 230 kivy.urlrequest (module). 219 kivy.uix.texture (module).gl_instructions (module).input.retaintouch (module).graphics (module).support (module).doubletap (module).uix. 266 kivy.uix. 288 kivy.vertex_instructions (module). 341 kivy. 129 kivy.slider (module). 253 kivy. 198 kivy.tuio (module).graphics.compiler (module).camera (module).uix.input.stacklayout (module).gesture (module). 219 kivy. 276 kivy.loader (module). 258 kivy.graphics.input.network.scrollview (module).resources (module).provider (module).lib.modules.settings (module).dejitter (module).logger (module). 227 kivy.input. 229 kivy.uix. 211 kivy.uix.uix. 233 kivy. 115 kivy.label (module). 272 kivy.graphics. 311 kivy. 309 kivy.input. 336 kivy. 246 kivy.linuxwacom (module).input.screen (module).layout (module). 210 kivy. 98 kivy_modules_dir (in module kivy). 247 kivy.modules.switch (module).uix. 233 kivy. 232 kivy.vkeyboard (module). 264 kivy.videoplayer (module).input (module). 300 kivy. 259 kivy.codeinput (module). 212 kivy.uix. 214 kivy.input.providers.mouse (module). 278 kivy.accordion (module). 308 kivy.inspector (module).providers. 246 kivy. 270 kivy.uix.graphics. 284 kivy. 98 kivy_icons_dir (in module kivy).bubble (module).providers.progressbar (module).postproc.motionevent (module).relativelayout (module).popup (module).input. 287 kivy.uix.treeview (module). 98 kivy_home_dir (in module kivy). 243 kivy.input. 235 kivy. 247 kivy.uix. 202 kivy.screenmanager (module). 237 kivy. 229 kivy. 97 kivy_data_dir (in module kivy). 246 kivy.providers.uix.context (module).providers (module).carousel (module).uix.kivy.network (module).uix.image (module).uix. 262 kivy.mactouch (module).androidjoystick (module). 156 kivy_base_dir (in module kivy).modules.input.uix (module). 98 kivy_options (in module kivy). 243 kivy. 229 kivy.providers.modules (module).modalview (module). 249 kivy. 141 kivy.providers. 241 kivy.uix.graphics.factory (module). 233 kivy. 267 kivy. 230 kivy.hidinput (module).uix.modules.uix. 283 kivy.postproc. 230 kivy. core. 302 Mesh (class in kivy. 97 kivy_shader_dir (in module kivy). 155 linear() (kivy.vector.codeinput. 324 load_kv() (kivy. 275 minimum_height (kivy.uix. 255 min_space (kivy.MatrixInstruction attribute).Property method).screenmanager.uix.TextInput attribute). 149 load() (in module kivy. 305 max_height (kivy.core. 279 label (kivy.factory. 163 load() (kivy. 116 Logger (in module kivy.progressbar.Image static method). 105 link() (kivy.graphics.MatrixInstruction attribute). 187 Mesh (class in kivy.uix.kivy_register_post_configuration() (in module kivy). 113 load_file() (kivy. 319 line_intersection() (kivy. 265 M mag_filter (kivy.input.lang.uix.ClockBase attribute). 148 list() (kivy. 324 L Label (class in kivy.uix.uix. 197 matrix (kivy. 295 margin_hint (kivy.video.BuilderBase method).uix.CodeInput attribute).core. 268 Line (class in kivy.label.Label attribute).graphics.logger). 293 manager (kivy.core.uix.TreeView attribute).audio.uix. 329 layout_path (kivy.AccordionItem attribute).texture. 143 min (kivy.graphics.BuilderBase method). 270 max_iteration (kivy. 265 min_space (kivy.LoaderBase attribute).uix.graphics.graphics).image.uix.graphics.spelling. 187 MatrixInstruction (class in kivy.uix.audio.Vector method).App method).Settings attribute).dropdown.core.text.uix. 256 minimum_height (kivy. 218 min_move (kivy.ext).core.text.vkeyboard. 229 list_languages() (kivy.TransitionBase attribute).ProgressBar attribute). 168 load_config() (kivy.VKeyboard attribute).layout).graphics).properties. 219 matrix (kivy.TreeView attribute).vkeyboard.markup).uix. 140 load_func (kivy. 183 Line (class in kivy.properties).uix.graphics.accordion.logger).uix. 160 load() (kivy.AnimationTransition static method).Slider attribute). 244 manager (kivy.input.gridlayout.MarkupLabel attribute).metrics).context_instructions.SpellingBase method). 330 markup (kivy.label).Carousel attribute).core.debug). 167 markup (kivy.context_instructions).app.app.treeview.lib. 122 menu (kivy.vertex_instructions).audio.DropDown attribute).VKeyboard attribute). 197 max (kivy.Screen attribute).treeview. 115 loading_image (kivy.transformation).vector.uix.core. 98 LoggerHistory (class in kivy.uix.carousel.MotionEventFactory static method). 283 layout (kivy. 221 line_height (kivy. 167 match() (kivy.Sound attribute).core.Sound method). 217 make_traceback() (in module kivy.graphics.Texture attribute).texture. 160 load() (kivy.vkeyboard.vector.uix.TreeViewNode attribute). 281 MarkupLabel (class in kivy.metrics).vertex_instructions).Texture attribute). 166 LabelBase (class in kivy.graphics. 308 minimum_height (kivy.uix.animation. 98 kivy_usermodules_dir (in module kivy). 326 lexer (kivy.markup.Carousel attribute). 329 length (kivy.StackLayout attribute). 160 length() (kivy.GridLayout attribute). 98 kivy_userexts_dir (in module kivy).screenmanager.accordion.core.loader). 288 max (kivy.uix.VKeyboard attribute).Vector static method).BuilderBase method).textinput.clock.slider.carousel. 175 load() (kivy.lang.Vector method).VideoBase method).MotionEventFactory static method).text). 142 364 .settings.loader.graphics). 187 MatrixInstruction (class in kivy.uix. 142 loop (kivy. 140 LoaderBase (class in kivy. 241 list() (kivy. 155 length2() (kivy. 305 min_filter (kivy.stacklayout.treeview. 224 Metrics (class in kivy.uix. 164 ListProperty (class in kivy.LabelBase attribute). 155 level (kivy.Accordion attribute). 114 load_string() (kivy.SoundLoader static method). 141 Matrix (class in kivy.App method).lang. 143 metrics (in module kivy.text.Slider attribute). 165 Layout (class in kivy.slider.uix. filechooser.gridlayout. 172 mouse_pos (kivy.base.norm_image_size (kivy.core.WindowBase at. 241 method).Image attribute).uix.WindowBase name (kivy. 172 move() (kivy.MotionEvent method).on_mouse_down() (kivy. 171 mode (kivy.uix. 156 minimum_width (kivy.Matrix on_pause() (kivy.app.input. 171 tribute).core.window.app.NoSuchLangError (class in kivy. 172 MotionEvent (class in kivy. 294 on_stop() (kivy.GridLayout normalize() (kivy.uix.TreeViewNode attribute).WindowBase kivy.graphics.uix. 218 mipmap (kivy.uix.EventLoopBase method).StackLayout NoLanguageSelectedError (class in attribute). 324 NumericProperty (class in kivy.textinput.label.TreeViewNode mm() (in module kivy. 114 on_rotate() (kivy.input). 172 MotionEventFactory (class in kivy.app.uix.base.motionevent).FileChooserController on_resize() (kivy.WindowBase MotionEventProvider (class in kivy. 148 mipmap (kivy.uix. method).Image method).minimum_size (kivy. 128 next_slide (kivy. 227 method).window.EventLoopBase method).spelling).WindowBase mode (kivy.window.treeview. 172 method). 114 293 on_start() (kivy.Vector method).motionevent.core.properties).WindowBase MotionEventFactory (class in kivy. 172 241 on_keyboard() (kivy. 165 minimum_size (kivy.treeview. 144 attribute).app.window.Gesture method).graphics. 239 on_mouse_up() (kivy.vector.core.image.TreeViewNode attribute). 284 on_close() (kivy.Carousel attribute).WindowBase tribute). 172 on_resume() (kivy.window.on_config_change() (kivy. 324 tribute).App method).core. 276 normalize() (kivy.window.Texture attribute).core.uix. method).WindowBase no_selection (kivy. 172 MotionEventProvider (class in on_motion() (kivy.TreeViewNode atmethod).Image attribute).Screen attribute).App method). 172 name (kivy.input.input. 171 on_flip() (kivy.core.App method).treeview.window. 225 on_dropfile() (kivy.screenmanager.ImageData attribute). 308 method).spelling).core. 326 O N 365 . 171 method). 131 minimum_width (kivy.core.WindowBase MotionEvent (class in kivy.input. 188 method).core. 163 265 on_touch_down() (kivy.image.provider).core.carousel. method).Label attribute).base. 219 128 multiselect (kivy.treeview.treeview.EventLoopBase method).uix.app. 131 attribute).WindowBase multiline (kivy. 326 164 odd_color (kivy.uix.gridlayout. 277 minimum_width (kivy.core. mipmaps (kivy.modalview).core.image. 228 method). 128 next() (kivy. 308 kivy.vertex_instructions.window.input).window. 281 odd (kivy.uix.WindowBase modifiers (kivy.core. 228 on_key_up() (kivy. on_key_down() (kivy.App method).window.core. 172 tribute).StackLayout normalize_stroke() (kivy.window.gesture.WindowBase attribute).App attribute).window.WindowBase move() (kivy.TextInput attribute).Mesh attribute).input. 165 tribute).transformation.image.uix.input). on_start() (kivy.stacklayout.screenmanager.uix. attribute).graphics. on_texture() (kivy.metrics).uix.WindowBase atmethod).window. 276 326 minimum_size (kivy. 326 ModalView (class in kivy.MotionEvent method).app.GridLayout nodes (kivy. 228 on_mouse_move() (kivy. 114 method).TreeView at.texture.TreeView at.stacklayout.core.gesture. 114 multiply() (kivy.treeview. 277 ObjectProperty (class in kivy.core.factory).Mesh at. 114 method).ScreenManager on_stop() (kivy.uix.WindowBase 238 method).window.GestureStroke attribute).uix.uix.core. 149 mipmap (kivy.graphics.properties).core. 114 tribute). 172 319 on_pause() (kivy. 271 method).uix.uix.App method).window. parser).motionevent.Canvas attribute). 106 out_expo() (kivy.AnimationTransition static method).MotionEvent attribute).animation.uix.label. 144 parse_int2() (in module kivy.properties.input. 107 out_quad() (kivy. 144 parse_filename() (in module kivy.DropDown method).stacklayout. 281 padding_x (kivy.GridLayout attribute). 108 ox (kivy. 339 parent_node (kivy.input. 150 options (kivy.input.StackLayout attribute). 106 out_elastic() (kivy.lang.Video attribute).lang.SettingItem attribute).motionevent. 239 osy (kivy.Label attribute).anchorlayout. 194 opacity (kivy. 309 padding (kivy.properties).animation.animation.Canvas attribute).motionevent. 281 padding (kivy. 107 out_sine() (kivy.AnimationTransition static method).widget.boxlayout. 115 opos (kivy.AnimationTransition static method). 115 options (kivy.Label attribute).uix.treeview.uix.graphics.uix.AnimationTransition static method). 305 padding (kivy. 309 osx (kivy.AnimationTransition static method).uix.uix.input.textinput.WindowBase method).animation. 256 orientation (kivy. 144 parse_color() (in module kivy.WindowBase attribute).AnimationTransition static method).ModalView method).Widget attribute).Parser method).window.widget. 339 open() (kivy. 144 parse_level() (kivy.animation.animation. 276 padding (kivy.bubble.widget.core.MotionEvent attribute).MotionEvent attribute).video. 106 out_circ() (kivy.uix. 285 open_settings() (kivy. 339 opacity (kivy.Slider attribute). 172 parent (kivy.parser). 270 open() (kivy.uix. 258 padding (kivy.App method).instructions.Widget method).parser). 305 orientation (kivy.uix.boxlayout.slider.uix.VideoPlayer attribute).parser). 107 out_quart() (kivy.slider.animation. 319 padding_y (kivy. 141 parse_bool() (in module kivy.AnimationTransition static method).videoplayer.uix. 259 orientation (kivy.Slider attribute).widget. 180 opacity (kivy.uix. 326 parse() (kivy.widget.motionevent.modalview.Bubble attribute).SettingOptions attribute). 281 padding_y (kivy.uix. 105 out_bounce() (kivy.stacklayout. 239 oz (kivy. 308 OptionProperty (class in kivy.label.window.uix.spinner.dropdown.uix. 172 on_touch_move() (kivy.TreeViewNode attribute).graphics. 304 options (kivy.uix.uix.MotionEvent attribute).uix.TextInput attribute). 319 panel (kivy. 334 orientation (kivy.parser).uix. 172 on_touch_up() (kivy. 255 orientation (kivy.motionevent.uix.app.gridlayout.input. 228 opos (kivy.uix. 145 parse_float (in module kivy. 239 oy (kivy.motionevent.settings.parser). 107 out_quint() (kivy.accordion.uix. 262 orientation (kivy.MotionEvent attribute). 239 osz (kivy.MotionEvent attribute). 331 options (kivy.settings. 144 366 .animation.parser). 144 parse_float4() (in module kivy.uix.MotionEvent attribute).AnchorLayout attribute).Accordion attribute).animation.uix.WindowBase method).BoxLayout attribute). 141 parse_string() (in module kivy.textinput.AnimationTransition static method).AccordionItem attribute). 106 out_cubic() (kivy.uix. 239 option_cls (kivy.MotionEvent attribute).Parser method).App attribute).uix.AnimationTransition static method).uix.window.TextInput attribute).uix.input.motionevent. 339 on_touch_up() (kivy.Label attribute).input.Spinner attribute).StackLayout attribute).core.on_touch_down() (kivy. 150 options (kivy.BoxLayout attribute).Widget method). 239 P padding (kivy. 319 padding_x (kivy. 339 on_touch_move() (kivy.parser).OptionProperty attribute). 303 parent (kivy.accordion.animation.uix.TextInput attribute).uix.AnimationTransition static method).core. 259 padding (kivy.textinput.app. 144 parse_int (in module kivy.Widget method). 239 out_back() (kivy.label.input.Widget attribute). lang).videoplayer. 272 pause() (kivy.Video attribute). 141 password (kivy.MotionEvent attribute).EventLoopBase method).ScreenManager method).graphics).Camera attribute). 168 position (kivy. 188 PushMatrix (class in kivy.uix. 239 preload() (kivy.filechooser.motionevent. 288 properties() (kivy.motionevent.lang).video.video. 168 platform() (in module kivy.uix. 160 play() (kivy. 303 PopupException (class in kivy. 240 push_attrs_stack (kivy.uix.input.Recorder attribute). 220 points_distance() (kivy.utils).videoplayer.VideoBase attribute).MotionEvent attribute). 331 position (kivy.vertex_instructions.vertex_instructions.Sound method).uix. 335 post_dispatch_input() (kivy. 239 progress_cls (kivy. 153 play (kivy.carousel. 178 points (kivy.EventDispatcher method).uix.Quad attribute). 304 popup (kivy. 190 points (kivy.Parser (class in kivy. 196 Popup (class in kivy.motionevent.uix.graphics.core. 116 psx (kivy.MotionEvent attribute).graphics.Bezier attribute).debug).motionevent.Point attribute). 320 path (kivy.screenmanager.VideoBase method).rst. 224 points (kivy.uix. 239 PopMatrix (class in kivy.properties).Cache static method). 265 print_usage() (kivy.context_instructions). 287 popup (kivy. 271 ProgressBar (class in kivy.MotionEvent method).graphics.graphics.uix.MotionEvent attribute).uix.graphics.graphics.uix.uix.vertex_instructions).input. 228 ppos (kivy.graphics. 294 previous_slide (kivy. 188 Point (class in kivy.lib.input.Triangle attribute). 119 ProcessedTraceback (class in kivy.event.Video attribute).graphics. 228 pop() (kivy. 127 Property (class in kivy.input.MotionEvent attribute).graphics.graphics. 188 points (kivy.TextInput attribute).core.motionevent.input.input. 239 psy (kivy.vertex_instructions. 131 pointsize (kivy.Line attribute).input. 334 play() (kivy.core.Line attribute).Widget attribute). 240 py (kivy. 339 position (kivy.input.cache.uix. 147 property() (kivy. 243 profile (kivy.Carousel attribute).uix. 240 367 .graphics. 236 play (kivy.vertex_instructions.uix.input. 168 Point (class in kivy.input.uix.uix. 271 path (kivy.metrics).context_instructions).GestureStroke method).MotionEvent attribute).Point attribute).uix. 224 pop() (kivy. 239 pos (kivy. 196 px (kivy. 240 pt() (in module kivy.RstDocument method). 189 pos (kivy.Widget attribute).motionevent.video.textinput.Rectangle attribute). 224 points (kivy. 287 pos (kivy.recorder.camera.motionevent.graphics). 226 points (kivy. 239 psz (kivy.graphics.Point attribute).FileChooserController attribute).MotionEvent attribute).MotionEvent method). 188 PopMatrix (class in kivy. 128 ppos (kivy.FileChooserController attribute).settings.VideoPlayer attribute).progressbar).base. 331 play (kivy.SettingString attribute).SettingOptions attribute). 264 play (kivy. 220 points (kivy.motionevent.VideoPlayer attribute).gesture.uix.graphics. 141 ParserException (class in kivy.graphics. 144 push() (kivy.popup).uix. 188 points (kivy.motionevent.widget. 186 points (kivy.video.motionevent. 188 pointsize (kivy.Point attribute).motionevent.video.MotionEvent attribute).input. 127 ProxyImage (class in kivy.MotionEvent attribute).input.loader).VideoBase method). 304 popup (kivy.Quad attribute).EventDispatcher method).SettingPath attribute).Rectangle attribute).MotionEvent method).input.filechooser.audio.settings.MotionEvent method).graphics.graphics.Triangle attribute).vertex_instructions.graphics).filechooser.event.core.settings.MotionEvent attribute).uix. 228 push() (kivy.graphics.vertex_instructions.Bezier attribute).popup). 240 PushMatrix (class in kivy.FileChooserProgressBase attribute).vertex_instructions.widget. 339 pos_hint (kivy. 343 previous() (kivy.input. 224 points (kivy. 220 pos (kivy.input. widget.recorder.vkeyboard.input.core.uix.core.graphics.motionevent.input.base.TextInput attribute).core.event.settings.ClearColor attribute). 200 release_all_keyboards() (kivy.fbo. 192 Rectangle (class in kivy.ProcessedTraceback method). 120 register() (kivy.Image method).window.TreeView ReferenceListProperty (class in kivy. 183 QueryDict (class in kivy.window.InstructionGroup range (kivy.Fbo refs (kivy.pz register_type() (kivy. 166 (kivy.remove_reload_observer() method). 302 reify (class in kivy. 220 remove_input_provider() rectangle (kivy.InstructionGroup Recorder (class in kivy.Recorder attribute).core.MotionEventFactory static remove_widget() (kivy.EventDispatcher render() (kivy.SoundLoader static remove_reload_observer() (kivy. 236 record_profile_mask (kivy.InstructionGroup read_pixel() (kivy.Fbo method). rectangle (kivy. 167 remove_reload_observer() (kivy.input. 125 remove() (kivy. 172 tribute). 224 (kivy.MotionEventFactory remove_widget() (kivy.graphics.VKeyboard 128 method).factory.recorder.lib. remove_node() method).WindowBase static method). 288 Quad (class in kivy.base.Image method).slider.Keyboard method).Recorder at.Fbo refs (kivy. 183 read() (kivy.graphics. 169 220 release() (kivy.graphics.LabelBase method).Color attribute). remove_screen() (kivy.texture.uix.uix. 128 236 (kivy.graphics. 277 remove() (kivy. 281 method).core.text. 129 kivy.tuio.graphics.graphics.core.graphics.graphics. 343 render_as_text() (kivy. record (kivy.text. 173 register() (kivy.uix. 200 remove() (kivy.LabelBase method).WindowBase r (kivy. 120 tribute).base.image.Image record_attrs (kivy.text.markup. refresh() (kivy.Color at.uix.instructions.window.providers.uix.MotionEvent tribute).TuioMotionEventProvider render() (kivy.input. 196 r (kivy. 236 method). 187 (kivy. release() (kivy.cache.vertex_instructions.Line attribute).core. 188 Quad (class in kivy.InstructionGroup method). 241 method).remove_from_cache() method). 229 method).graphics. method). 295 register() (kivy.TransitionBase 166 method). 152 release() (kivy.input.ConfigParser method).properties).ExceptionManagerBase method). 324 150 remove_postproc_module() refresh() (kivy.reload() (kivy.WindowBase method).Widget method).cache.uix.Label attribute).graphics.uix.uix.instructions. remove_event_listener() 320 (kivy.recorder). 166 static method).LabelBase static method).Fbo method).graphics. 181 r (kivy.graphics.input.graphics).uix.graphics). 127 (kivy.MarkupLabel at.gl_instructions.recorder.Cache static method).Line 128 attribute).core. 191 method).fbo.Slider attribute).image. 236 remove_group() (kivy.relativelayout).text. 192 readonly (kivy.debug.utils).vertex_instructions). 305 method).input. 183 tribute).graphics. 163 method).EventLoopBase method).Cache static method). 330 (kivy.release_keyboard() (kivy. 172 r (kivy.vertex_instructions).EventLoopBase method). 183 attribute). 200 register() (kivy. 340 register() (kivy.graphics.graphics.core. 240 at- Q R 368 . 163 tribute).Recorder remove_group() (kivy. 188 Rectangle (class in remove_handler() (kivy.input.context_instructions.ClearColor at.core.uix.treeview.audio. 234 register_event_type() (kivy.base.core.utils).rst.config.window.EventLoopBase method).textinput.Settings method).RstDocument method).screenmanager. 153 RelativeLayout (class in kivy.graphics.label. 160 218 register() (kivy.image.Texture method). context_instructions. 295 Rotate (class in kivy. 115 method).gridlayout.graphics. 189 screen_names (kivy.uix.GridLayout method).Color at.Camera attribute).scatter.urlrequest.uix. 276 attribute).scale (kivy.Scatter (class in kivy. 276 require() (in module kivy).interactive). 264 resolve_path() (kivy.Scale atattribute).context_instructions.resources).rst).uix.uix.LoaderBase method).Vector method). 219 RenderContext (class in rotate() (kivy. 191 scale_max (kivy. attribute). 342 reset_undo() (kivy. 343 s (kivy.gl_instructions.instructions.graphics.input.MotionEvent tribute).uix.treeview.Widget attribute).Scatter attribute). 194 rotation (kivy.core.Scatter attribute). 196 method).graphics. 251 scale (kivy.network.uix.graphics.clock.EventLoopBase method).gridlayout. 291 rgba (kivy. 116 tribute).uix.context_instructions.gesture.GridLayout reset_context (kivy.graphics.resources).uix. 197 result (kivy. attribute).gridlayout.App attribute). 291 rgba (kivy.UrlRequest scale (kivy.graphics. 173 tribute).WindowBase row_force_default (kivy.urlrequest.resources). 181 resource_add_path() (in module kivy.transformation.MotionEvent tribute). 293 rootpath (kivy. 189 resp_headers (kivy.WindowBase atreq_body (kivy. 271 attribute).uix.scale_for_screen() (kivy.uix.UrlRequest Scale (class in kivy.context_instructions).uix.ClockBase method).transformation.uix.UrlRequest at.camera.graphics.Matrix rgb (kivy. 181 scale_min (kivy.graphics).scale_stroke() (kivy.treeview.screenmanager). 131 rgba (kivy. 200 ScatterPlane (class in kivy. 290 tribute).ClearColor at.uix.TextInput run() (kivy.graphics.vector.Matrix RenderContext (class in kivy.ClearColor attribute).context_instructions. s (kivy.graphics).Color at151 tribute).graphics. 151 SafeList (class in kivy.ClockBase root (kivy.graphics.gridlayout.Callback attribute).network.Scatter attribute). 196 method).UrlRequest attribute). 240 rgba (kivy. 129 resolution (kivy.TreeView attribute). 133 kivy.urlrequest. 276 179 rows_minimum (kivy.uix.Callback attribute). 161 runTouchApp() (in module kivy.graphics. 200 method). 251 197 resp_status (kivy.screenmanager.gl_instructions.graphics.core.graphics.TreeView at122 tribute). reset_context (kivy. root_options (kivy.window. 291 rgb (kivy.camera. 195 RstDocument (class in kivy.window.Scale attribute).network. 250 rotation (kivy. 196 resource_find() (in module kivy. 128 resolution (kivy. 291 req_headers (kivy.FileChooserController screen_in (kivy.filechooser.uix.uix.core.ClearColor at.utils).urlrequest.uix.scale_for_screen() (kivy.graphics. 173 attribute).Scatter attribute).uix.Color at. 122 root (kivy. 97 rows (kivy.scatter.app.Color attribute).loader.ScreenManager Rotate (class in kivy. 151 Scale (class in kivy.scatter.method). 189 method).App method).Color attribute).urlrequest.instructions). 324 schedule_once() (kivy.GridLayout attribute). 189 tribute).scatter.graphics.motionevent.textinput.uix. 219 rgb (kivy.run() (kivy. 276 request_keyboard() (kivy.RstDocument method). 115 method). 340 schedule_interval() (kivy.rst. 152 resource_remove_path() (in module SafeMembrane (class in kivy.GestureStroke tribute). 291 right (kivy. 320 run() (kivy.screenmanager.graphics. 191 scale() (kivy. 294 197 S 369 .context_instructions).TransitionBase attribute). 325 Screen (class in kivy.Color attribute). 228 rgb (kivy.UrlRequest row_default_height (kivy.scatter).graphics). 250 attribute).CameraBase at.GridLayout attribute).network.network. 251 tribute). 156 kivy.clock.input.scatter).base).uix.graphics.app.base.graphics.uix.ClearColor attribute). 243 rotate() (kivy. 181 method).graphics.widget. 148 set_icon() (kivy.video.scrollview). 173 set_vkeyboard_class() (kivy. 173 set_window() (kivy.settings). 330 setup_mode_dock() (kivy. 302 SettingNumeric (class in kivy.screenmanager). 302 SettingsPanel (class in kivy. 303 seek() (kivy. 270 select() (kivy.Rotate method).uix.scrollview.videoplayer. 303 selected_node (kivy.uix.uix.spelling.settings.settings). 150 set_title() (kivy.uix.uix.Rotate method).scrollview.uix.uix.vkeyboard.core.treeview.settings.textinput.screenmanager.SettingItem attribute).window.screen_out (kivy.uix. 173 set_max() (kivy.uix.uix. 295 ScreenManager (class in kivy. 325 selection (kivy.TextInput attribute).uix.textinput. 320 select_language() (kivy.uix. 304 SettingItem (class in kivy. 304 SettingOptions (class in kivy.vertex_instructions.settings.uix.Settings method).VKeyboard method).graphics. 331 seek() (kivy.uix.TextInput method).ConfigParser method).settings).uix. 221 select() (kivy.ScrollView attribute). 335 segments (kivy. 299 scroll_y (kivy. 320 selection_to (kivy. 160 seek() (kivy.uix. 298 scroll_moves (kivy.SpellingBase method).WindowBase method).vertex_instructions. 303 setup_mode() (kivy. 320 ScrollView (class in kivy.window.scrollview.filechooser.EventLoopBase method).dropdown. 304 Settings (class in kivy.textinput. 299 scroll_x (kivy.Property method). 287 set() (kivy.core.uix.TextInput attribute).EventDispatcher method).graphics.uix.properties.context_instructions.DropDown method).settings).Bezier attribute). 320 selection_text (kivy.video.uix.uix.scrollview.WindowBase method).uix.uix. 302 select_all() (kivy.textinput.VKeyboard 370 .core. 125 setter() (kivy.uix.settings. 178 segments (kivy. 297 section (kivy.ConfigParser method).Settings attribute).vkeyboard.window.textinput.audio.TextInput attribute).uix.Popup attribute). 272 selection (kivy.ScrollView attribute).TreeView attribute).TextInput attribute).carousel. 301 settings (kivy. 294 screens (kivy.treeview.properties.uix.uix. 128 setdefault() (kivy.uix.popup. 320 scroll_y (kivy. 266 scroll_timeout (kivy. 320 selection_from (kivy.core.uix.uix.uix. 299 scroll_stoptime (kivy. 226 segments (kivy.settings).FileChooserController attribute).uix.uix. 197 set() (kivy. 299 scroll_x (kivy.SettingItem attribute).popup.textinput.uix. 173 scroll_distance (kivy. 125 set() (kivy. 325 select_text() (kivy.window.Sound method).uix. 182 segments (kivy.Bezier attribute).uix.uix.graphics.Ellipse attribute).ScrollView attribute). 266 scroll_distance (kivy.uix.scrollview.ScrollView attribute).settings).uix.TransitionBase attribute).config.VideoPlayer method).uix. 150 set_min() (kivy.WindowBase method).Popup attribute).config.uix. 127 SettingBoolean (class in kivy. 320 selected_alpha (kivy. 168 seek() (kivy.core. 189 set() (kivy.settings).TextInput attribute).Carousel attribute).graphics.settings.base. 294 screenshot() (kivy.ScreenManager attribute).TextInput method).TreeView method).config.ScrollView attribute).uix. 287 separator_height (kivy.settings). 164 select_node() (kivy.carousel.textinput. 304 SettingPath (class in kivy.BoundedNumericProperty method).SettingsPanel attribute).textinput. 302 selection_color (kivy.properties.uix.TextInput attribute).Carousel attribute).graphics.scrollview. 302 SettingString (class in kivy.screenmanager.uix. 298 scroll_friction (kivy. 320 separator_color (kivy.event.Ellipse attribute).ScrollView attribute).Video method).BoundedNumericProperty method).WindowBase method).core. 299 scroll_timeout (kivy.VideoBase method).scrollview.core.graphics.ScrollView attribute). 125 setdefaults() (kivy.uix.ConfigParser method). ProcessedTraceback show_errors (kivy.graphics.uix. 160 sort_func (kivy.VideoBase attribute).graphics.graphics). SoundLoader (class in kivy.core. 243 343 start (kivy.input.input. 295 SpinnerOption (class in kivy.core.graphics).shape). 115 spacing (kivy.debug.MotionEvent attribute).BindTexture attribute). 335 296 status (kivy.graphics.uix.image.uix.graphics.uix.stencil_instructions).audio). 200 start() (kivy. 212 SpellingBase (class in kivy. 100 size (kivy. 266 state (kivy.uix.EventLoopBase method).Sound attribute). 272 StencilPop (class in Sound (class in kivy.vertex_instructions.graphics.carousel.VideoPlayer at214 tribute).audio. 343 kivy.VertexInstruction StencilUnUse (class in attribute). 100 259 stop() (kivy. 241 spos (kivy.uix.filechooser.uix. source (kivy.Texture attribute).graphics.texture.input.videoplayer.rst. size (kivy.input.StackLayout atmethod).VertexInstruction attribute). 295 size_hint_x (kivy.core.graphics.base. 164 StencilPush (class in source (kivy.animation. 278 StencilUse (class in source (kivy.image.uix.Sound attribute).method). 228 shape (kivy.Widget attribute).input.RstDocument attribute).fbo.image. 189 source (kivy. 183 228 size (kivy.uix. 214 190 StencilUse (class in kivy.shape).graphics. 241 size (kivy.Rectangle attribute). 308 shorten (kivy.motionevent.camera.boxlayout.vkeyboard.MotionEvent at. 234 attribute).metrics).uix. 240 ShapeRect (class in kivy.graphics.graphics. 189 attribute).graphics.core. 189 source (kivy. size (kivy. 144 step (kivy.slider.CameraBase method).MotionEventProvider method). source (kivy.uix.ImageData attribute).instructions.uix. 116 size (kivy. 309 sp() (in module kivy.TuioMotionEventProvider size (kivy.screenmanager).uix.Widget attribute).uix.input.BindTexture 214 attribute).uix.spinner). source (kivy. 196 StencilUnUse (class in kivy.lib.input.app.core. 160 214 source (kivy.App method).Image attribute).audio. 340 start() (kivy. 178 kivy.provider.spinner). 164 start() (kivy.Slider attribute). 272 start() (kivy.VideoPlayerAnnotation show_hidden (kivy. 161 173 start() (kivy.uix. 160 size_hint_y (kivy.tuio. 192 kivy.uix. 220 start() (kivy.Carousel attribute). 189 method).screenmanager. 305 state (kivy.base.context_instructions.Widget attribute).stencil_instructions). attribute). 330 tribute).Sound attribute).Rectangle method).FileChooserControllerStencilPop (class in kivy.slider).loader.Image attribute).providers.stacklayout).ImageData attribute).animation. 128 size (kivy. 164 ShaderTransition (class in Spinner (class in kivy. 163 start() (kivy.graphics. 340 method).video.graphics).uix. 168 340 state (kivy.Video attribute).stacklayout. 276 setup_mode_free() (kivy.spos (kivy.core.shader).core.EventLoopBase method).LoaderBase method).button.VKeyboard spacing (kivy.audio).uix.videoplayer. 159 kivy.uix.window.core. 241 StackLayout (class in kivy.TransitionBase size_hint (kivy.FileChooserController attribute). SlideTransition (class in kivy.Label attribute).videoplayer.core.video.Fbo attribute). 308 Shape (class in kivy.label.widget.uix.filechooser.stop() (kivy.Animation method).gridlayout.Animation method).uix. 189 source (kivy.core.uix. 160 StencilPush (class in kivy. stop() (kivy.uix.RstDocument attribute).rst.uix.uix.graphics.widget.image. 336 attribute).stencilview).WindowBase attribute). 335 StencilView (class in kivy.core.VideoPlayer attribute). 128 371 .stencil_instructions).Fbo attribute).motionevent.widget. 263 Slider (class in kivy.uix. 218 start() (kivy.BoxLayout attribute).graphics).core.widget.graphics.GridLayout at. 340 state (kivy.MotionEvent attribute). 331 slides (kivy.MotionEventProvider size (kivy.input.screenmanager). 330 tribute).Widget attribute).Button attribute).uix. 309 Shader (class in kivy.audio. state (kivy. 281 standard_exc_info (kivy. 240 tribute).spelling). 306 spacing (kivy.uix.stencil_instructions). 307 kivy. image.camera.VideoPlayer at320 T 372 .uix. 168 (class in stop() (kivy.tabbedpanel.LoaderBase method).graphics. 317 textinput (kivy. 244 stopTouchApp() (in module kivy.text.Label method). 169 tribute).TabbedPanel attexture (kivy.core.tabbedpanel.screenmanager.uix.label.graphics. 131 attribute). 218 tribute).uix.uix. 234 TabbedPanelStrip (class in kivy.fbo. tribute).TabbedPanel textinput tribute).loader.graphics.image.switch).gesture.spelling. method).Parser method).Fbo attribute). text (kivy.tabbedpanel). 169 method). 131 text (kivy.Sound method).TabbedPanel atTextureRegion (class in kivy.uix. 129 str_to_gesture() (kivy.VKeyboard attribute).uix. 282 texture_update() (kivy. 141 tribute).tuio. 118 thumbnail (kivy.SettingString atswitch_to() (kivy.utils).tabbedpanel).core.debug).GestureStroke text (kivy.texture. 173 texture (kivy.label. 200 texture (kivy.label.lang.VertexInstruction attribute).TabbedPanelStrip stop() (kivy.atlas.Texture atmethod). 296 304 Switch (class in kivy. 282 method).Image attribute).Image attribute).texture (kivy.uix.RstDocument attribute).core.TabbedPanel at. 168 tribute).GestureDatabase template() (kivy. stop() (kivy.graphics.window.Image attribute).graphics.SpellingBase text_size (kivy.CameraBase attribute).TabbedPanel at.VideoBase attribute).Label attribute).shader.Texture (class in kivy.properties).Texture attribute). 218 StringProperty (class in kivy.video.Keyboard attribute).motionevent. 343 text (kivy.provider.lib.providers.vkeyboard.textinput.uix.Shader attribute).uix.uix.tabbedpanel.uix. 161 TabbedPanel (class in kivy.uix. 282 texture_size (kivy.core.texture (kivy.Animation target (kivy. 314 tab_width (kivy.camera.settings.label. 304 method).uix. 295 stop_all() (kivy.input.tabbedpanel.video. 241 TabbedPanelHeader (class in stop() (kivy.core.textinput).texture).Label attribute).window.VertexInstruction tribute).texture (kivy.Label attribute). 240 system_size (kivy. 141 tex_coords (kivy.graphics.TextInput attribute). 100 218 stop_property() (kivy.CameraBase method).graphics. 100 tb_set_next() (in module kivy.text. 240 attribute). 315 stop() (kivy.MotionEvent at.uix.uix. 313 stop() (kivy.tabbedpanel).TransitionBase target (kivy.uix.MotionEvent attexture (kivy.Fbo attribute).instructions.tabbed_panel (kivy. 278 tribute). 166 text_size (kivy.input.core.SettingPath attribute).motionevent.LabelBase attribute).base).uix.texture_size (kivy. 166 method).textinput.core.tabbedpanel. 116 315 stop() (kivy.uix.core. 282 strtotuple() (in module kivy.graphics. 193 string_to_keycode() (kivy.TextInput attribute). 314 tab_pos (kivy. 315 method).core. 330 method). 152 success (kivy.VertexInstruction method).input.texture. 314 tab_list (kivy.tabbedpanel). 149 tex_coords (kivy.core.uix. 216 texture (kivy.animation.window.uix.animation.graphics.rst.uix.WindowBase at. 278 tribute). 191 tab_height (kivy. 314 method). 314 sx (kivy.graphics.settings.VideoBase method). 310 (kivy.tabbedpanel.lang.videoplayer.VertexInstruction atstrip_comments() (kivy.tabbedpanel).input.MotionEvent at. 190 stroke_length() (kivy. 160 attribute). 240 161 sy (kivy.uix.uix. 163 tribute).input.MotionEventProvider method).motionevent.screenmanager).graphics.Animation static target (kivy.label.core.texture). TabbedPanelContent kivy.TuioMotionEventProvider kivy. tribute).instructions.uix.Keyboard tex_coords (kivy. 165 SwapTransition (class in kivy.uix.image. 183 sz (kivy.uix. 193 texture (kivy.MotionEventProvider TabbedPanelException kivy. textures (kivy.LabelBase attribute).BuilderBase method).uix.input.audio.Label attribute).core. 314 228 (class in stop() (kivy. 314 282 tab_width (kivy.uix.uix.gesture. 320 212 suggest() (kivy. TextInput (class in kivy.Atlas attribute). Switch attribute).BuilderBase method). 233 U ud (kivy.uix.SettingsPanel attribute).Sound method). 240 time_start (kivy.SettingItem attribute). 240 title (kivy.input.clock. 340 to_widget() (kivy.motionevent.providers.debug).Widget method).video.screenmanager. 219 Tuio2dCurMotionEvent (class in kivy. 197 translate() (kivy.tuio. 148 ungrab() (kivy.graphics. 341 to_window() (kivy. 244 TreeView (class in kivy. 173 toggle_node() (kivy. 122 tick_draw() (kivy.input. 340 to_parent() (kivy.WindowBase method).accordion. 234 unregister_event_types() (kivy.AccordionItem attribute).TreeView method). 123 unselect() (kivy.motionevent. 256 title_template (kivy.TuioMotionEventProvider method).MotionEvent attribute).ext). 310 touch_distance (kivy. 293 transition_state (kivy.MotionEvent attribute).uix.core.Scatter attribute). 123 time_end (kivy.input.settings.event.providers.widget. 294 transition_progress (kivy.core.Animation attribute).Widget attribute).MotionEventProvider method).audio.Switch attribute).MotionEventProvider method). 302 unzip_extensions() (in module kivy.uix. 234 TuioMotionEventProvider (class in kivy. 234 Tuio2dObjMotionEvent (class in kivy.AccordionItem attribute).vertex_instructions).input. 160 unload() (kivy.Settings method). 190 Triangle (class in kivy.ScreenManager attribute).AccordionItem attribute).window.uix.uix.treeview).properties.widget.switch. 234 update_from_scroll() (kivy.lib. 294 TransitionBase (class in kivy.input.uix.treeview).treeview.switch.uix.uix.MotionEvent attribute).clock.MotionEvent method).screenmanager.transformation. 228 ungrab() (kivy. 241 update() (kivy.MotionEvent attribute).uix. 343 title (kivy. 299 373 .Popup attribute).MotionEvent method).uix.togglebutton).ClockBase method).tuio).base.uix. 287 title (kivy.EventDispatcher method).core.FileChooserProgressBase attribute).accordion.graphics.uix.Screen attribute). 240 time_update (kivy. 256 title (kivy.Matrix method). 343 toggle_fullscreen() (kivy.VideoBase method). 302 title_args (kivy. 240 unbind() (kivy. 272 touch_control (kivy.provider.scatter. 321 top (kivy.debug).scrollview. 325 Triangle (class in kivy.lib.treeview).uix. 325 TreeViewLabel (class in kivy.input. 244 translate_syntax_error() (in module kivy.uix.accordion.uix. 240 uid (kivy.input.uix.graphics).context_instructions).screenmanager. 341 toctrees (kivy.tuio).uix.EventDispatcher method).ScrollView method).RstDocument attribute). 141 unregister() (kivy.settings. 341 total (kivy.settings.uix.uix.motionevent. 291 transform_inv (kivy. 228 update() (kivy.Screen attribute).app.scatter.input.input.uix.animation. 323 TreeViewException (class in kivy. 190 Translate (class in kivy. 310 touches (kivy.Scatter attribute).lang.Widget method).rst.Widget method).motionevent.screenmanager).uix.rst.tuio.Widget method).widget. 291 transition (kivy. 335 tick() (kivy.uix.popup.App attribute).ClockBase method).graphics).input.uix. 325 ToggleButton (class in kivy.tuio).ClockBase method).providers.MotionEvent attribute). 176 update() (kivy.widget.input.Property method).uix.input.uix.uix. 127 unschedule() (kivy.uix. 168 unload_file() (kivy. 243 transform (kivy.lib.RstDocument attribute). 115 title (kivy.EventLoopBase attribute).filechooser.motionevent.TuioMotionEventProvider static method).uix.widget.graphics.debug). 295 Translate (class in kivy.clock. 303 title (kivy. 256 to_local() (kivy.input.input. 219 translate_exception() (in module kivy.uix.treeview). 127 unbind() (kivy.uix.event. 325 TreeViewNode (class in kivy. 240 unload() (kivy.providers. 128 TracebackFrameProxy (class in kivy. 100 transition (kivy.motionevent.tribute).providers. VideoBase (class in kivy. 166 uvpos (kivy.image.shader.screenmanager. 218 WeakMethod (class in kivy.core.Spinner attribute).Vector attribute).video.UrlRequest attribute).Slider attribute).uix.Widget attribute).graphics.context_instructions. V X Y W wait() (kivy.text.texture.core.uix.ScrollView attribute).Translate attribute).Color at.network.progressbar.Line attribute).graphics.urlrequest.uix. 187 width (kivy.Widget attribute).Video attribute). 197 volume (kivy.LabelBase attribute).App attribute).input. 335 xy (kivy. width (kivy.Slider attribute).slider. 283 value (kivy.context_instructions.uix.Keyboard attribute).graphics.uix.UrlRequest method).graphics.network.core. 197 vs (kivy. 251 240 y (kivy.video).video).videoplayer).widget).core.Translate atvertices (kivy.core.core.widget. 156 Widget (class in kivy. 167 240 VideoPlayer (class in kivy.uix.videoplayer). 233 304 WM_Pen (class in kivy.graphics.context_instructions.motionevent.graphics. 333 x (kivy.WindowBase attribute). values (kivy. 212 tribute).uix.Mesh tribute).scrollview.ProgressBar window (kivy.Translate attribute).uix. 225 x (kivy. 156 kivy. 181 v (kivy.url (kivy.window.uix.uix. 341 y (kivy.window.app.graphics.width (kivy.vkeyboard). 218 uvsize (kivy.audio.uix.transformation.providers. 190 VKeyboard (class in kivy.uix.shape.videoplayer.SettingItem attribute).uix.ProgressBar attribute).label.VideoBase attribute).uix.Widget attribute). WindowBase (class in kivy. 192 vertices (kivy.MotionEvent attribute).core.window.Slider attribute).Vector attribute). 332 volume (kivy.uix.Translate volume (kivy.graphics.window).Image attribute).input.SettingBoolean attribute).slider.texture. 296 y (kivy.graphics. 160 attribute). 197 method). 197 attribute).recorder. 306 value_normalized (kivy.widget. 335 y (kivy.widget.uix. 306 (class in values (kivy.Texture attribute).video.Texture attribute).Keyboard attribute).Recorder attribute).vector. 308 233 vbar (kivy. 341 width (kivy.window).Translate view_clip() (kivy.graphics.Shader attribute).ConfigParser method). 170 value (kivy.graphics.Line attribute).Sound attribute).context_instructions. 190 Video (class in kivy.urlrequest.graphics.Translate atvs (kivy. 299 wrap (kivy.Color attribute).ShapeRect attribute). 250 use_kivy_settings (kivy.settings.uix.instructions). 170 WidgetException (class in kivy.graphics). 188 x (kivy. 288 value_normalized (kivy.Texture attribute).widget).y (kivy.vertex_instructions.uix.wm_pen).vertex_instructions. 115 usersize (kivy.ShaderTransition at. 190 volume (kivy.uix.texture. 190 VertexInstruction (class in kivy.Mesh attribute).spinner. 196 width (kivy.motionevent.vector). 164 width (kivy. 224 tribute).Translate attribute).graphics. 170 WipeTransition (class in kivy.graphics.input.urlrequest).Translate attribute). 173 288 value (kivy. 241 valign (kivy. 328 xyz (kivy.core. 125 VertexInstruction (class in kivy.screenmanager). 236 attribute).input.graphics. 251 UrlRequest (class in kivy.settings. 163 width (kivy.ImageData attribute).wm_touch).uix. 218 v (kivy. 331 x (kivy.context_instructions.graphics. 190 tribute). 156 374 .graphics. 337 widget (kivy.input.uix.graphics.slider. 306 296 value_pos (kivy.image.uix.texture.MotionEvent attribute).network.uix. 303 window (kivy. 341 VideoPlayerAnnotation (class in x (kivy.Label attribute). 219 xy (kivy. WM_MotionEvent kivy. 154 write() (kivy.graphics. 218 Vector (class in kivy.graphics.Matrix attribute).Texture attribute). 168 xyz (kivy.VideoPlayer attribute).input. 173 width (kivy.core.config.providers. 341 Window (in module kivy.core.graphics.core.vector.progressbar.weakmethod). Translate attribute).MotionEvent attribute).input.graphics.motionevent. 190 z (kivy.context_instructions. 197 z (kivy.graphics.Translate attribute). 240 375 .Z z (kivy.