Monday, 29 December 2014

Eyepiece - some thoughts on GUI interfaces using Python

What a nightmare ...

As a long-term user of IDE (Integrated Development Environment) programming tools, and specifically Visual Basic on Windows, I'm used to being able to drag and drop controls, insert modules and pop-up forms and so on without having to write more than a line or two of code - and to then to add the functionality wherever I need.

With Python, it seems that everything has to be hand-coded using library classes that have multiple rules about how anything is placed, a hierarchy of grids, stickies and classes that are ill-documented. It felt like I was programming back in the 1970's without the benefit of being able to preview what I was doing.

the standard tk (Tkinter) library that is an integral part of Python is a hoary old set of widgets (graphical control objects) and cruft that requires some arcane knowledge and a lot of practice to use - especially since anything more complex than a 'Hello World' application seems to require swathes of code to manage.

Indeed, it was to the point where I was considering using Curses - a kind of text-mode interface that creates forms just using colour and text (including the box-drawing characters).

Then I found wx.Python - a somewhat more modern GUI interface with a larger choice of widgets. It still requires a library of arcane knowledge, and the documentation is just as confusing to a Python newbie like me.

Google (my best friend) turned up a number of IDEs for Python, and specifically for wx.Python. Some were form generators, others were supposedly IDEs

I tried several that completely failed to do anything useful - either they didn't load, or they didn't do what it said on the box.

Then I found Boa Constructor - a Windows IDE specifically for Python (Boa and Python are both big snakes of the constrictor variety). Boa not only does what it says on the virtual box, it is free, and it resembles nothing more nor less than the old Delphi interface, using a mosaic of windows rather than a single one with multiple panes.

The range of widgets is excellent (and can be expanded), it generates the necessary code on the fly and will allow a preview. The form designer is also drag and drop (a bit clunky in places, but still excellent). It even allows you to preview the controls in action while designing the form.

I now have an interface of sorts, but I still have to figure out where to put the various bits and pieces of actual code. What's more, the same code runs on both Windows and the Raspberry Pi ...

Version 0.01 prototype interface on Windows 7
As you can see, the windows interface features the nice, rounded corners, semi-transparent top-bar and windows-style controls, while -

Version 0.01 prototype interface on Raspberry Pi
the Raspberry Pi's Linux interface has the square frame, foursquare controls and the same look and feel as the operating system's GUI (LXDE in this case). On a full Linux system where speed, memory and disc space was less of an issue, the window would take on the look and feel of whatever Desktop Environment was in use be it LXDE, Gnome, KDE etc.

Incidentally, while the interface reacts to input, it doesn't actually do anything useful - yet.

Boa Constructor can be found at:
Boa Constructor at Sourceforge


No comments:

Post a Comment

Comments and suggestions are warmly welcomed.