Native UI Framework

  • Open source
  • No commercial version
  • Hardware accelerated
  • Pythonic
  • Cross platform (macOS, iOS, Android, Linux, Windows)
  • Has automated tests

Of Note

  • Kivy is simple
  • Not for making native-looking apps
  • Focus on touchscreen apps and custom UI
  • Not a replacement for Qt or Tkinter

Markup + Code

UI declared in a pythonic markup using Kv Language

Looks like this:

#:kivy 1.9

BoxLayout:
  orientation: 'vertical'

  Label:
    text: 'Label'

  Button:
    text: 'Button'

Installation

brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gstreamer
export USE_OSX_FRAMEWORKS=0 

pip install --upgrade Cython==0.25.2
pip install kivy

...or use Kivy.app

Hello, world


In [ ]:
%%bash
cat hello.kv

In [ ]:
%%bash
cat hello.py

In [ ]:
%%bash
python hello.py > /dev/null 2>&1

Layouts

AnchorLayout, BoxLayout, FloatLayout, RelativeLayout, GridLayout, PageLayout, ScatterLayout, StackLayout


In [ ]:
%%bash
cat boxlayout.kv

In [ ]:
%%bash
python boxlayout.py > /dev/null 2>&1

Widgets


In [ ]:
%%bash
cat widgets.kv

In [ ]:
%%bash
python widgets.py > /dev/null 2>&1

Data binding


In [ ]:
%%bash
cat databinding.kv

In [ ]:
%%bash
python databinding.py > /dev/null 2>&1

Testing

  • Kivy itself is tested

  • For non-UI, unittesting + mocks work as expected

  • Kivy provides mechanisms for running GL tests (screencap comparisons, yuck)

  • For BDD-style testing, kvaut (shameless plug): https://github.com/garyjohnson/kvaut


In [ ]: