Python Programming, news on the Voidspace Python Projects and all things techie.

Planet Voidspace

emoticon:beaker For a long time I've meant to use an RSS aggregator to collect the blogs I'm interested in. I like the look of Planet, which runs Planet Python, so for an almost equally long time I've intended to try that.

I've finally got round to it. Installing and configuring Planet is trivially [1] easy. Just upload, edit the config file and setup the cron job. Smile

The result is :

Planet Voidspace

This is just the blogs I want to check regularly, but feel free to browse... Razz

I'm gradually adding feeds, but aiming for a maximum of about ten to twelve new entries every day, without too much duplication of Planet Python. I reckon that these feeds should keep me interested, without killing my productivity.

Planet Voidspace updates every hour and has its own RSS 1.0 and RSS 2.0 feeds.

[1]At least once I'd figured out cron jobs it was...

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-05-05 15:56:57 | |

Categories:


London 2.0

emoticon:info This Wednesday I went to London 2.0, the Python Meetup. This was the first one I have managed to get to, and I was looking forward to it. Starting working at ResolverSystems was the first time I had ever met other Python programmers; and now I get to meet more. Smile

When we arrived (nice venue by the way), Simon Brunning was looking pretty lonely Exclamation Over the course of the evening around ten people came and went, all very cool.

I really enjoyed, lots of geek talk and some good laughs. Especially nice to meet Simon Willison there, he seems a very good chap.

Anyway, I owe a couple of beers; which is as good a reason as any to go along to the next one. Wink

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-05-05 14:11:10 | |

Categories: ,


wxPython in Action

emoticon:nightmare wxPython is one of the best cross platform, open source, GUI toolkits available for Python.

It is a wrapper around the C++ toolkit, wxWidgets. This is a mature project, with a vast array of different widgets at your disposal. Applications written with this toolkit can run under Windows, Mac OS X, and Linux (using GTK I believe). There is even a port in progress for the PocketPC.

Despite having all this going for it, wxPython has a reputation for having a steep learning curve. This is largely because it is a (relatively) thin wrapper around the underlying C++ code. Not only that, but despite a comprehensive demo showing off its features from Python code; it still refers you to the C++ documentation for much of the wxPython API.

For these reasons an introduction to using wxPython, which can also serve as a comprehensive reference would be very welcome. wxPython in Action is certainly hefty enough to fill these boots. It is published by Manning and weighs in at 620 pages. It has the added gravitas of being co-written by Robin Dunn [1], the creator and maintainer of wxPython.

wxPython in Action Cover

Before I launch into the review, and tell you whether I think it adequately fits the role of introduction and reference book, let me tell you about my perspective.

I've written several programs with a GUI, mainly using Tkinter. Although Tkinter is nice for small projects, its limitations rapidly become obvious.

I have used wxPython before, but only under the guise of Wax. Wax provides a wrapper around wxPython, it abstracts away some of the complexity of wxPython, and presents a simple Pythonic interface to the basic components. It still provides access to the wxPython objects that it builds on. This means that any functionality not wrapped by Wax, can be accessed directly.

I'm very happy with Wax. I'm also about to embark on a couple of larger projects needing good user interfaces. My motivation for learning wxPython is therefore to help me understand (and possibly extend) Wax, but also to be able to use the more advanced features of wxPython.

Having done some GUI programming already, I'm familiar with the concepts of widget packing [2], event based programming and callbacks. What I'm looking for, is a good introduction to wxPython that will also serve me as a reference manual well into the future.

After starting to readg wxPython in Action I wasn't looking forward to writing this review. The book starts with a brief and interesting history of wxPython, followed by the Python and wxWidgets evangelism that you might expect. This material then repeats itself several times. It almost feels like the authors wanted to guarantee that wherever you opened the book in the opening chapters you would be convinced of the power of wxPython. Of course I'm already sold. Cool

The book starts well enough. It has simple descriptions of the most trivial wxPython applications. This includes explanations of the basic components, and why things are the way they are. This is very useful. After this I was raring to go, and champing at the bit for an overview of the different widgets available, and some examples of how to use them.

After the introduction wxPython in Action goes into a detailed explanation of the wx event loop (chapter 3, "working in an event driven environment"). I worked my way through this, thinking that at any moment we were going to start applying all this. Instead it launches into an introduction to PyCrust [3] and how to embed it in your own applications. It follows this up with a discussion of the Model-View-Controller paradigm, and how best to factor programs with a complex GUI (chapter5, creating your blueprint).

At this point I gave up, disheartened, and flicked through the rest of the book. I still didn't feel equipped to do much with wxPython, and didn't have the energy to carry on reading.

A few days later when I came to write this review, I had one of those 'doh' moments. Maybe the book isn't meant to be read cover to cover. Smile

Sure enough, in the About this Book pages at the beginning (which I swear I read), it says :

If you are already familiar with wxPython, you'll probably be spending most of your time in parts 2 and 3.

Part 2 (chapters 7 to 12) covers the basic widgets. It gives examples, and also documents the API. Starting with static text and buttons (the very simplest widgets), and moving swiftly on. This is much more like what I was hoping the book would be. It details all the methods and flags and shows how to use them.

Some of these details I've used before when tinkering with Wax, but several times I've had to resort to the C++ documentation. This book could well prove a godsend. Smile

So after chapter seven on a range of widgets, from the simple to the esoteric, come chapters on frames (different types of windows and containers), dialogs and menus. It all seems well written, comprehensive and useful. It includes examples of non-rectangular windows (including how to make them draggable without a menu bar), and using MDI to have several resizeable windows in a parent frame.

As usual though, the real trick with UI design is the layout. I've just reached the chapter on sizers, which are the objects used to control the layout of widgets in containers. Hopefully I'll be able to apply all this soon.

I've learned a bit about the importance of UI design from Movable Python. Its basic functionality is quite simple, and its target audience is developers. To make it a useful as possible I gave access to most of the individual command line switches from the main interface. All the other functionality (like saving default options and configuring the Quick Launch buttons, is done from a single advanced options dialog.

Perhaps predictably, this works fine if you understand what all the options do, but is very cryptic otherwise. The Advanced Options window, is too big. I think "overwhelming" was the comment from the (otherwise very positive) review in the German c't computer magazine.

The next version of Movable Python, will actually have many more features, but hopefully a GUI designed with usability in mind. I expect this to be a long learning curve though. Smile

So in summary, wxPython in Action is a great book. You'll need to watch which bits of the book are actually relevant to what you need to know - Embarassed - but it has served me as a great introduction to wxPython, and hopefully will continue to serve me for several years to come.

[1]Along with Noel Rappin.
[2]Laying out the components of your GUI in container 'widgets', often called panels or frames.
[3]PyCrust is an interactive interpreter session, wrapped as a wx widget.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-05-04 10:39:19 | |

Categories: ,


Open Source Internet Café Software

emoticon:new_document At one of my jobs we're looking for some good, free internet café software.

We have a couple of computers providing free (time limited) internet access in our public café. We'd like a better way of controlling access to the computers than our current hi-tech solution [1].

The internet connection is already filtered by DansGuardian, so it's only access to the computer itself I want to control.

Here's the rub, we want to run the client and server for whichever software we go with, to run on different networks. Both client and server need to run on Windows machine, and the 'server' needs to be easy to use. Internet access will be controlled from our 'info desk', which is staffed by volunteers.

Anyone know of anything I can check out ? I've come across Open Kiosk, which looks good; except it still requires client and server to run on the same network.

[1]Egg timers. Laughing

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-05-02 12:49:31 | |

Categories: ,


Python Related News

emoticon:target A few pieces of Python related news that may (or may not) have slipped under your radar.

Python at OLPC

A gentleman called Ivan Krstic has blogged about a new job he has just taken up.

You may have heard of the One Laptop Per Child, project. On his blog Ivan says :

Starting in June, I will be working full-time on the user stack architecture -- providing a platform for the integrated core application suite that the children will interact with...

Which is made all the more interesting by the next paragraph :

But here's the kicker: large parts of the user stack will be implemented in Python, making my unofficial role at the OLPC one of "head Python evangelist".

Cool. Smile

The Python Virtual Machine

One project I've been keeping half an eye on is pyvm, the Python Virtual Machine. The homepage is concise, but intriguing :

pyvm is new a python virtual machine implementation which can run Python 2.4 bytecode and most of the times produce the expected output.

It's an alternative implementation of the Python interpreter, and I think the main purpose is that it is optimised for speed. It also has a compiler written in Python, making it easier to customise.

Even more intriguing is the latest Freshmeat Announcement, for the version 1.2 release :

Whitespaceless python frontend. Regular expression to C, Just in time compiler. Memory filesystem (memfs://) and freezing. Ported to cygwin.

Sounds like there is some interesting developments here.

Tcl/Tk Moves Forward

Tcl/Tk has just released 8.5a4.

This is particularly interesting, becasue one of the goals of Tcl/Tk 8.5 is to provide native looking (and themeable) front end for the GUI toolkit.

See (for example) this Dr. Dobb's Tcl-URL! which says :

QOTW: "[T]the real goal [of Tile] is themeable apps with the existing ease of Tk coding. That has been achieved [with 8.5]." - Jeffrey Hobbs

See the Tk Widgets Look fine under Windows page for reams of screenshots of good looking Tk programs.

Maybe Tkinter is due for a new lease of life when Tk 8.5 makes it way into Python.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-05-02 10:53:33 | |

Categories: ,


rest2web in Subversion

emoticon:newspaper rest2web 0.5.0 alpha is now in subversion.

Included in this is a partial documentation update. I think that it will be easier to work on the remaining features I'd like to add to 0.5.0, if it can be done in smaller incremental steps.

Not only that, but some of the new features need using, commenting on and more work. Hopefully as I add to the documentation this will happen.

The new features are currently best documented in the changelog. This provides an outline of all the changes (so far) since 0.4.0 alpha.

Remaining features targeted for inclusion in 0.5.0 are outlined in the todo list.

The biggest change to rest2web is the new force mode. This allows rest2web to build a simple website just from a directory tree of ReST documents. restindexes, templates and index pages all become optional. Documentation for this feature already exists, see the force mode source file.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-05-01 23:23:55 | |

Categories: , ,


Movable Python 1.0.2

emoticon:movpy2 Movable Python 1.0.2 is now available.

This release if for the Python 2.4 distribution of Movable Python, and is now available for download.

Features new to this release include :

  • Now built with Python 2.4.3.

  • Other updated modules include :

    • pywin32 build 208
    • ctypes 0.9.9.6
    • wxPython 2.6.3.2
    • Firedrop 0.2.1
    • ConfigObj 4.3.1
    • Wax 0.3.33
  • Scripts (and customize.py) are now executed in a specific namespace, no more movpy cruft.

  • When entering interactive mode (movpy -), any additional command line arguments are passed to IPython.

  • imp.find_module has been fixed to work with modules contained in the zipfile. This fix doesn't write any temporary files, but imp.load_module has been patched to accept a StringIO instance.

  • Built in support for matplotlib interactive sessions. (movpy - -pylab)

  • Verified that __future__ statements are handled correctly.

  • New look documentation and website.

To try the new matplotlib support, you'll need the matplotlib files in your lib/ directory. You can then run the following at the command line :

movpy.exe - -pylab

This should drop you straight into a IPython session, with pylab enabled.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-05-01 14:01:26 | |

Categories: ,


ConfigObj, Eggs & Megaframeworks

emoticon:eggs ConfigObj 4.3.1 is now out. So also is Turbogears 0.9a5. Cool

If you look carefully in the Turbogears Changelog you will spot the innocuous looking line :

TurboGears now uses ConfigObj 4.3.0 for configuration

In fact it already uses 4.3.1, but no need to be picky. Wink

Turbogears makes extensive use of setuptools for installing dependencies. Unfortunately this highlighted the fact that easy_install is incapable of handling files served by my download manager downman.py. It creates an egg with a file name downman.py in it. This is despite the perfectly valid HTTP header sent by downman containing the filename [1]. Confused

To get round this problem I've now uploaded some pre-built eggs to the ConfigObj Cheeseshop Page. easy_install will use those eggs without trying to fetch the module from Voidspace. Many thanks to Kevin Dangoor for supplying the fresh eggs.

It also means the eggs are available for anyone else who may want to use setuptools to install ConfigObj. The zip file also contains the documentation, API docs and validate.py which you miss out on; but I guess you can't have it all. Smile

[1]easy_install determines the filename by parsing the URL. Phillip Eby insists it needs to do this before the header is sent. By this I don't mean that it might not be true, merely that I'm not convinced that ignoring the header and using the resource locator to determine the resource name is the only (or best) possible solution. Phillip suggests using PATH_INFO to get round this. I will probably make this change, the reason I've resisted this is because PATH_INFO is difficult to make work on IIs. This might preclude people on cheap hosting accounts using downman. However - a) I don't think anyone is, and b) I can make it optional, so that either would work.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-04-29 17:25:12 | |

Categories: ,


ConfigObj 4.3.1 & validate 0.2.2

emoticon:objects ConfigObj 4.3.1 and validate 0.2.2 are now available.

These are both minor bugfix/feature enhancement releases.

What is New in ConfigObj ?

Changes since ConfigObj 4.3.0 :

  • Added validate.py back into configobj.zip. (Thanks to Stewart Midwinter)
  • Updated to validate.py 0.2.2.
  • Preserve tuples when calling the dict method. (Thanks to Gustavo Niemeyer.)
  • Changed __repr__ to return a string that contains ConfigObj({ ... }).
  • Change so that an options dictionary isn't modified by passing it to ConfigObj. (Thanks to Artarious.)
  • Added ability to handle negative integers in unrepr. (Thanks to Kevin Dangoor.)

What is New in validate ?

Changes since validate 0.2.1 :

  • Addressed bug where a string would pass the is_list test. (Thanks to Konrad Wojas.)

What is ConfigObj ?

ConfigObj is a simple but powerful config file reader and writer: an ini file round tripper. Its main feature is that it is very easy to use, with a straightforward programmer's interface and a simple syntax for config files. It has lots of other features though :

  • Nested sections (subsections), to any level

  • List values

  • Multiple line values

  • String interpolation (substitution)

  • Integrated with a powerful validation system

    • including automatic type checking/conversion
    • repeated sections
    • and allowing default values
  • All comments in the file are preserved

  • The order of keys/sections is preserved

  • No external dependencies

  • Full Unicode support

  • A powerful unrepr mode for storing basic datatypes

What is validate ?

validate.py is a module for validating values against a specification. It can be used with ConfigObj, or as a standalone module.

It is extensible, and as well as doing type conversion from strings, you can easily implement your own functions for transforming values in any way you please.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-04-29 12:25:19 | |

Categories: ,


Hosted by Webfaction

Counter...