2

New to the world of Pi. Very impressed! We're considering using a Zero W to power an information display panel appliance which has a small list of requirements:

  1. Pulling data from the internet (and/or reading from local config files either pushed via FTP or modified via SSH)
  2. Doing simple, rudimentary drawing such as circles, rectangles, simple polygons--mostly solid colors, but gradients would also be nice.
  3. Displaying some text. (We would prefer to use a font, but can do block-font rendering using the above if needed.)
  4. Possibly playing simple sounds (WAV, MP3, OGG, whichever is easiest/best.)

Performance is a non-issue. This screen will update once every few minutes, and we don't mind/care if it repaints slowly so people see it updating.

Additionally, since this display appliance will be read-only (i.e. no keyboard or mouse input needed) we would also like to hide the mouse cursor and all window chrome (window titles, dock panels, menus, etc.) If possible we could even boot right to this app instead of Raspbian Desktop, or even further, switch from Raspbian Desktop altogether if there's a better option since a full windowed GUI is not required.

As such, we're looking for the best/recommended way to create such an app. Is there a specific toolkit recommended by RaspberryPi.org? Is there a better distro to install for such a simple need?

Going a different direction, what about Android? Is there a version that can run on the Pi Zero W? That would work too.

4

Most likely, you'll need to pick a language and a graphics library or GUI toolkit.

The way that the GUI is rendered on a Linux system is relatively simple, once you understand what each part does. We don't need a really in-depth knowledge of each part, but I'll give you a brief summary, with the aid of a nice illustration I found:

Display stack

Illustration of the graphical user interface stack by Shmuel Csaba Otto Traian; CC BY-SA 3.0.

  • The display server (in your case X.Org) handles the primitive drawing and events such as mouse/keyboard input. Generally, you wouldn't bother writing your application to talk at this level, because it's a lot of work. Interesting trvia: a lot of newer distributions are considering using Wayland instead of X, because X is getting old and complicated... Not much fun to work with!

  • On top of your display server is your desktop environment (which is LXDE; PIXEL is just a modification of it). The desktop environment also has a window manager, which handles drawing the chrome around your windows (shockingly enough!).

  • Applications such as yours generally use a GUI toolkit. This contains some basic widgets such as buttons, text boxes and so forth which are useful in many situations. The famous two are GTK+ and Qt. This is the important bit for you.

Most languages have bindings to at least one of the above toolkits. C# (through Mono) has bindings to both on Linux. Qt has excellent bindings for C++.

Each toolkit has a slightly different way of doing things, but nearly all support full screen windows with basic graphics primitives, usually with relatively little code. Rather conveniently, there's almost always a Stack Overflow question asking how to perform basic tasks with GUI toolkits etc. These are usually pretty easy to learn from, especially with your level of experience.

In your situation, since performance isn't particularly important, I'd look for a toolkit that's easy to program with in a language that you're comfortable with.

There are a couple of ideas that come to mind:

  • Run a fullscreen browser and use HTML/CSS/JS to create your information display. I personally find HTML much easier to create UIs with than many of the other toolkits, and polygons with gradients would be trivially easy with CSS. However, this would make reading files on your Pi more difficult, so if that's a requirement, this isn't the route for you. However, with JavaScript, you can make requests to other websites.

    It would then simply be a case of opening your browser in fullscreen mode (e.g. opening Chromium in kiosk mode)

  • Use a graphical toolkit like Gtk and Python. Here is a simple example of using Cairo with Gtk to draw shapes. It's a little more involved than HTML/CSS, but with Python, you can also read local files etc.

Both Python and HTML support hiding the mouse cursor (CSS; Python GTK) and playing sounds (JS; Python).

The language you choose will depend on what you're familiar with, and how much time you want to invest. My suggestion is to choose the simplest solution to develop. Don't worry about stripping down to the bare minimum, and the fastest language, unless you've got a particular reason to—the phrase YAGNI comes to mind.

As far as I know, there's no "recommended toolkit" or anything of that sort. As with most things regarding programming, there are many ways to achieve the same goal, and it's all about the tradeoffs you want to make.


To answer your question regarding Android: the Pi Zero is probably a little too weak (see this reddit post) to run Android capably, so it's probably not worth pursuing.

  • 1
    @MarqueIV I ended up adding an unexpectedly large summary of desktop environments, GUI toolkits etc. Perhaps you'll find it helpful as a brief introduction to Linux desktop programming. – Aurora0001 Oct 27 '17 at 15:55
  • 2
    See also unix.stackexchange.com/a/93210/25985 Note that the DE and WM layers are optional. If all you are doing is running a fullscreen app, you probably don't want a DE, but you do want a lightweight stand-alone WM (although potentially you could do this without that as well). – goldilocks Oct 27 '17 at 15:56
  • 1
    @Aurora0001 people like you who post answers like that are what makes sites like those here on StackExchange so great. Im frustrated i can only vote your answer up once. But i can say... thank you. – MarqueIV Oct 27 '17 at 22:56
  • 1
    @MarqueIV If you appreciate the answer you should upvote it ;) That's how we show our appreciation. – goldilocks Oct 28 '17 at 14:07
  • 1
    Thought I did! Did now! – MarqueIV Oct 28 '17 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.