[Wylug-discuss] XML data storage & GUI design
Roger Leigh
rleigh at whinlatter.ukfsn.org
Mon Nov 21 18:57:14 GMT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mischa Oliver Altmann <een2moa at leeds.ac.uk> writes:
> I plan to store aquired data (e.g. sensors) in an XML file. I have long
> looked for an oppertunity to work with XML but lack just about all
> experience. Is anyone working with XML? Pointers to good resources (incl.
> books) would be appreciated.
I suggest you use one of the common XML libraries, such as libxml2 or
expat. There are probably python bindings for both, or other
python-specific libraries.
These typically represent the XML as a tree (acyclic graph) of
elements, which contain data items (leaf nodes). Functions are
provided to navigate and manipulate the tree. You will implement
routines to convert your data model to and from this tree form.
Depending on how much "XML" you want, you might only need to scratch
the surface, especially if all you want is a "file format". Otherwise
you might also want to investigate XML Schema etc..
> Further more, I would like to create a (fairly basic?) GUI showing sensor
> data (with history) and possibly video from the webcam(s) together with
> control buttons for movement of robot and configuration of extra hardware
> (lights, etc.).
> This GUI feeds off the XML data which is received via a WiFi-link from the
> robot.
>
> I've received several suggestions starting from Python/Tk and Python/GTK+
> to MinGW and QT based ideas. Multiplatform isn't necessary but would be
> ideal. <drifting> put it all on a live-cd... </drifting>
> Can someone patch together some arguments for any one combination?
I think you might possibly find this useful:
http://people.debian.org/~rleigh/gtk/ogcalc/
This demonstrates how to write a simple GTK+ application, in C, C++
and Python, both with and without Glade. You might find the
Python+Glade example useful. In contrast to the tutorials, which just
show you how individual bits work, this aims to demonstrate how to
structure a GUI program, which many folks get wrong because simple
examples usually omit the needed structure.
I strongly suggest you separate the XML processing from the GUI side,
using a common pattern such as MVP (model, view, presenter). For
example, you can have a class (or set of classes) representing your
data (the "model"), which can be converted to and from XML
("serialisation"). Then you have a GUI widget to display/interact
with the model (the view and presenter). The view is the graphical
display, whereas the presenter is the logic that controls user
interaction, which is closely tied to the view but not necessarily
part of it.
http://www.object-arts.com/EducationCentre/Overviews/ModelViewPresenter.htm
http://www.martinfowler.com/eaaDev/ModelViewPresenter.html
Regards,
Roger
- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>
iD8DBQFDghZ9VcFcaSW/uEgRAhrOAKCiGQouG6iYw1ZZEx0NYTdxEQ/8VACgsRkQ
4ixogmxeWkGOJLCpGgkegNo=
=fiKU
-----END PGP SIGNATURE-----
More information about the Wylug-discuss
mailing list