Skip to content

Theming Kivy

Yuri Ivanov edited this page Oct 13, 2021 · 20 revisions

The Default Theme

The default Kivy theme is loosely based on the Moblin mobile interface. Although we consider it simple and elegant, it may not suit everyone's needs.

There are various approaches to giving Kivy a new and unique look. These are described below including a discussion of their advantages and disadvantages.

The Simplest Approach

The background images for all the Kivy widgets are all pulled from the png file <KIVY_DATA_DIR>/images/defaulttheme-0.png by using the .atlas file alongside it. You will also find other images in this folder that you can modify to change some other visual elements. Their names should be self-explanatory.

The 'defaulttheme-0.png' is used together with the <KIVY_DATA_DIR>/style.kv file to apply the complete style - bitmaps and drawing instructions. This means that by altering these files, you can customize the look of your user interface.

As an alternative to replacing these files, you can create your own versions and use the resource_add_path function so Kivy uses them in preference to the defaults.

Pros

  • Simple to implement
  • Guaranteed compatibility (assuming no broken kv!)
  • Easy to swap out and share

Cons

  • Limited customizability
  • Bitmaps may display poorly on hi-res displays

Resources

FlatKivy

Heavily based on concepts used in Google's Material Design spec and the Windows "Modern" interface, this effort goes a little beyond just retheming the existing UI elements. A preview can be found on YouTube.

One of the main goals of the project is to make theming an application significantly easier. Rather than specifying raw numbers for each UI element, FlatKivy provides user-definable lookup tables for font 'style' (a mixture of actual typeface, font_size, and opacity following google's typography recommendations), colors (the entirety of the color palette in the Material Design document is built in), and a system for defining a set of arbitrary theming rules for widgets that can be applied everywhere transparently. This creates UI elements that are human readable, faster and easier to work with for programmers and designers.

Pros

  • Modern looking
  • Scalable over different resolutions
  • Flexible
  • Based on Google usability studies

Cons

  • Experimatal
  • Undocumented
  • Pioneering (few help resources available)

Status

The project is not supported or developed

Resources

KivyMD

KivyMD - is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. The project's goal is to approximate Google's Material Design spec as close as possible without sacrificing ease of use or application performance. A preview can be found on YouTube.

Pros

  • Modern looking
  • Scalable over different resolutions
  • Flexible
  • Based on Google usability studies

Cons

  • KivyMD widgets are not as flexible in customizing their appearance as Kivy widgets
  • Possible performance drop on weak mobile devices

Status

The project is supported by the KivyMD community

Rolling Your Own

Of course, you are free to create you own widgets or override the graphical properties (both background images and drawing instructions) of the default widgets to create an entirely unique look and feel for your app. This works well for simple widgets, but can quickly become a lot of work when using more complex widgets.

If you choose this route, be sure to consider the full scope of widgets you will require before taking the plunge.

Clone this wiki locally