How would you build a pixel perfect GUI on Linux?

I would like to create a graphical interface in which every single pixel is under my control (i.e. does not use the standard widgets that GTK + provides). Renoise is a good example of what I want to create.

Does Xlib or XCB reach the best way, or can this be achieved with higher levels like GTK + (maybe even PyGTK)? Should I look at Cairo for drawing?

I would like to work in Python or Ruby, if possible, but C is fine too.

+7
user-interface linux gtk x11 xlib
source share
6 answers

Using the Clutter toolkit (or some other canvas widget / toolkit) you can create such an interface. I would not advise going to the Xlib / XCB or DrawingArea level, because for this it would be necessary to implement most of the common functions already present on the canvases.

+7
source share

In X, there is one problem with this approach that you might not have taken into account. The font size is measured in dots (one dot is 1/72 of an inch) and thus changes in (pixel) size with resolution and monitor size. Text strings will also vary in length depending on the language, so it is impossible to determine how large the buttons should be. This is said in the general GUI tools for X. In addition, it would be easy to just write your own GTK theme engine, which will draw all the widgets exactly as you want (using Cairo [1] or GDK [2]) and do The app always uses this theme. It might also be possible for your application to set the default font size (in points) based on DPI so that it always gets the same pixel size (and, of course, doesn't make your application translatable).

There are at least several graphical interfaces that use this ideal pixel approach based on SDL [3], for example, AGAR [4], PicoGUI [5] and Guichan [6]. Most of them are written in C ++ and some in C, and as far as I know, none of them have bindings for Python and Ruby. Then, using the SDL, you can have only one top-level window, which means that your application (or the GUI toolkit you use) must perform its own window management for various dialogs, etc. But I guess that was what you intended anyway.

[1] cairographics.org/
[2] library.gnome.org/devel/gdk/unstable/index.html
[3] www.libsdl.org/
[4] libagar.org/
[5] picogui.org/
[6] guichan.sourceforge.net/wiki/index.php/Main_Page

+5
source share

You might want something like pygame .

+3
source share

GTK and PyGTK are probably the wrong tools to use. This is not possible because you could make your whole application one big gtk.DrawingArea (an example of this, where it really makes sense, Gargoyle ), but for any complex GUI you are crazy.

+1
source share

http://www.oluyede.org/blog/writing-a-widget-using-cairo-and-pygtk-28/ shows how to create a simple widget using PyGTK and Cairo.

+1
source share

Simply put, you need something that gives you a limited rectangle and a free realm in order to draw everything you want into it. Such objects are commonly referred to as "canvas." I have done this before (in Ruby) using the FXCanvas class available with the Fox toolkit , but there are others available (wxWidgets, for example, but I have no personal experience with this toolkit).

Be careful. Low-level interfaces like this are very flexible, but they also require a lot more work on your part.

+1
source share

All Articles