PyOnyx: API for Onyx libs. I need your help!
#1  tuxor 04-30-2012, 07:51 AM

since Python is such a pythonic language and C++ simply isn't, I would love to be able to write small (gui) applications for my Onyx Boox in Python. Maybe you feel the same? Then I really need your help!

At first, it looks like cross compiling PyQt and Python is sufficient. But I have succesfully done this and still only non-graphical applications work. The reason is missing eink screen support in Qt. Onyx handled this issue by writing a big stack of c++ libraries that wrap around the original Qt libraries provided with the imx508 toolchain (

So there is still hope, that we will finally be able to write applications for Onyx Boox devices in Python by taking the effort of writing a Python API for the Onyx libraries. And writing a Python API is actually not that hard, if you use SIP (

I set up the necessary git repo on

For compatibility reasons I built PyQt version 4.8.5 using SIP 4.12.2. So a potential API for the onyx libraries will have to be built using the same SIP version. The source code for this version is available from the respective tarball (sip-4.12.2.tar.gz) in the PyOnyx repository. This tarball also contains the version specific documentation of SIP. The readily compiled Python and PyQt builds are available from "".

Unfortunately, I have no experience with SIP so far. So it would be great if we found somebody with insight in this whole topic of writing an API.

In the end, I want to stress that I won't be able to carry out this project alone. Maybe it's not even that much work (potentially 244 header files to convert, but each one we convert can immediately be used inside of Python) once you know how SIP works. But since I'm really unfamiliar with C++ and SIP, I will have a hard time making my first steps in this project without your support. So I won't start serious work on this project, as long as I'm alone...

#2  tuxor 04-30-2012, 07:01 PM
To give a simple example I set up a simple file and the first sip file: onyx_dialog.sip. Unfortunately message_dialog.sip is not working at the moment. But I'm sure now this whole project will turn out much easier than expected.

Please note: It's _not_ necessary to write an API for _all_ of those onyx/* libraries. We only pick the methods and classes we'd like to use in our Python code. It's really easy to add new methods and classes once we have a basic selection of classes/methods - simply because (once you are familiar with the SIP syntax) the hardest work to do here is setting up the and files.

#3  spaetz 05-01-2012, 05:05 AM
Hi tuxor. I've never used sip and see that you have posted a cross-compiled python. Does it include ctypes which is included in the stdlib? That can also be used to create C-lib interfaces and I have limited experiencence in doing so. (not sure if/how well it works on ARM though).

I have ordered my M92 but have still to receive it (thanks booxtor ;-)), and would be interested in getting some tools done, preferrably in python if at all possible :-)

#4  tuxor 05-01-2012, 05:22 AM
Yes, I built python with CTypes, though I didn't test it yet on my M92, because I have no idea of that module.

Since the onyx libs are really closely connected to the Qt libs, it looked pretty obvious to me connecting any Python API of the onyx libs with the corresponding PyQt modules, which is easy when using SIP, since PyQt is also built using SIP.

Is something similar possible with CTypes?

#5  tuxor 05-01-2012, 05:25 AM
By the way, I compiled the first module for the PyOnyx API and I'm running into a segmentation fault, when using this code.
import PyOnyx
from sys import argv
from PyQt4.QtGui import QApplication,QMessageBox
from PyQt4.QtCore import QObject
app = QApplication(argv)
about = PyOnyx.ui.MessageDialog(QMessageBox.Icon(QMessageBox.Information),[1]),[2]), QMessageBox.No | QMessageBox.Yes)
decision = about.exec_()
print decision
Any ideas how to debug a segmentation fault? It must be somehow related to the line with "about = PyOnyx.ui.MessageDialog(". Because when I comment out everything behind that line, the script runs fine. And the "PyOnyx.sys.SysStatus..." line runs fine, when tested separately.

#6  spaetz 05-01-2012, 05:41 AM
Quote tuxor
Yes, I built python with CTypes, though I didn't test it yet on my M92, because I have no idea of that module.
Mmmh, given that both PyQT and the boox SDK code is C++, ctypes might not be so useful after all, it binds well to C libraries but not C++.

Never used SIP (or QT really), so I am afraid I cannot really help with the segfault. But I think this would be a very promising way forward. While it is a resource-constrained device, I find programming in python to be much more productive than anything else. (Once I get my device, I will try to compile that too).

#7  spaetz 05-01-2012, 05:43 AM
Quote tuxor
Any ideas how to debug a segmentation fault?
I would think that getting a stack trace with GDB would be the next step:

You run the code on the M92 or on the host?

#8  tuxor 05-01-2012, 06:11 AM
Running the code on the host won't work because of missing QWS. So I have to test everything on the M92. And there I don't have gdb

#9  raphman 05-01-2012, 12:30 PM
Hmm, is it really necessary to create new bindings?

I have only taken a short look at the Boox SDK but it seems that all that is needed to update the screen is a re-implementation of (and some accompanying files) in Python.
Apparently, the screen is updated by sending one of a few update commands to the display server (correct name?) over UDP. The display server then copies the appropriate bitmap from framebuffer to display controller and updates the screen using a configurable waveform.
Not sure whether it is easily possible to detect widget updates in PyQt, however.
At least, it should be possible to manually update the screen by sending the appropriate command via UDP.
Did I overlook something?

#10  tuxor 05-01-2012, 04:43 PM
Okay. So let's come to terms: We try to get a Python API for that screen_proxy.h and once we have that, we can still decide whether to expand the API for other Onyx libraries or not. Sounds like a sensible compromise

  Next »  Last »  (1/2)
Today's Posts | Search this Thread | Login | Register