Tuesday, 1 March 2016

Heng - Sprint 2: GUI Frameworks

Author: Heng Zhen Jing
Date: 01/03/2016
Title: Sprint 2 - GUI Frameworks

In order to interact with users, a friendly and intuitive interface is a must. This can keep users entertained but not staring at the tonnes of lines of codes, don't know where to start from. Fortunately, there are many libraries which provide powerful and easy to use tools to construct custom interfaces and graphical user interfaces (GUI).

  • Tkinter: It is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit and is Python's de facto standard GUI, and is included with the standard Microsoft Windows and Mac OS X install of Python. It provides common controls, such as buttons, lists, drop-down boxes as you typically see in most window type applications.  Tkinter also includes basic drawing tools, so can be used quite effectively for basic games and graphics too. Some tkinter guides and example codes can be found at:  https://pihw.wordpress.com/lessons/rgb-led-lessons/rgb-led-lesson-5-creating-a-graphical-user-interface/
  • WxPython: It is based on wxWidgets, a cross-platform GUI library written in C++. In addition to the standard dialog, it includes a 2D path drawing API, dockable windows, support for many file formats and both text-editing and word-processing widgets.
Comparison of Tkinter vs WxPython:
Both of them have comparable controls and layouts. The wxPython version is 76 lines and the tkinter version is 48 lines, most of which is accounted for by layout code.

The wxPython uses nested HBOX and VBOX sizers, in which it externalizes the layout classes in its sizer hierarchy, whereas tkinter internalizes layout so that each widget manages its own children using a variety of policies, of which grid is just one. However, wxPython  interface looks way more elegant than tkinter. In term of speed comparison, wxPython interface runs way more slower than tkinter.
  • Kivy: It is based on OpenGL ES 2 and includes native multi-touch for each platform and Android/iOS. It’s an event-driven framework based around a main loop, and is thus very suitable for game development. Your application adds callbacks from the main loop at a scheduled frequency, or by one-off trigger. The Kivy framework is very powerful for handling everything from widgets to animation, and includes its own language for describing user interface and interactions.

The video above shows the implementation of Kivy on Raspberry Pi. Kivy seems to be the most elegant and user-friendly interface. More of Kivy stuff can be found at:https://github.com/mrichardson23/rpi-kivy-screen

Heng Zhen Jing
Blog Entry #5

No comments:

Post a Comment