Lably
Skip to content

Kivy (framework)

Free and multi-platform graphical library for Python

  • 4 min read
  • 4 chapters

Related on Lably

Through Open-source software, Python (programming language) and Mobile app

Kivy is the main framework developed by the Kivy organization, alongside Python for Android, Kivy for iOS, and several other libraries meant to be used on all platforms. In 2012, Kivy got a $5000 grant from the Python Software Foundation for porting it to Python 3.3. Kivy also supports the Raspberry Pi which was funded through Bountysource.

The framework contains all the elements for building an application such as:

  • extensive input support for mouse, keyboard, TUIO, and OS-specific multitouch events;
  • a graphic library using only OpenGL ES 2, and based on Vertex Buffer Object and shaders;
  • a wide range of widgets that support multitouch;
  • an intermediate language (Kv) used to easily design custom widgets.

Kivy is an evolution of the PyMT project.

Code example

Here is an example of the Hello world program with just one button:

<span id="mwUQ"></span><span class="kn" id="mwUg">from</span><span class="w" id="mwUw"> </span><span class="nn" id="mwVA">kivy.app</span><span class="w" id="mwVQ"> </span><span class="kn" id="mwVg">import</span> <span class="n" id="mwVw">App</span> <span class="kn" id="mwWA">from</span><span class="w" id="mwWQ"> </span><span class="nn" id="mwWg">kivy.uix.button</span><span class="w" id="mwWw"> </span><span class="kn" id="mwXA">import</span> <span class="n" id="mwXQ">Button</span> <span class="k" id="mwXg">class</span><span class="w" id="mwXw"> </span><span class="nc" id="mwYA">TestApp</span><span class="p" id="mwYQ">(</span><span class="n" id="mwYg">App</span><span class="p" id="mwYw">):</span> <span class="k" id="mwZA">def</span><span class="w" id="mwZQ"> </span><span class="nf" id="mwZg">build</span><span class="p" id="mwZw">(</span><span class="bp" id="mwaA">self</span><span class="p" id="mwaQ">):</span> <span class="k" id="mwag">return</span> <span class="n" id="mwaw">Button</span><span class="p" id="mwbA">(</span><span class="n" id="mwbQ">text</span><span class="o" id="mwbg">=</span><span class="s2" id="mwbw">"Hello World"</span><span class="p" id="mwcA">)</span> <span class="n" id="mwcQ">TestApp</span><span class="p" id="mwcg">()</span><span class="o" id="mwcw">.</span><span class="n" id="mwdA">run</span><span class="p" id="mwdQ">()</span>

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication