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

Silverlight and IronPython

emoticon:beaker In preparation for some upcoming talks (and the book) I've been experimenting with IronPython and Silverlight.

In the last few days I've learned the following things:

  • Creating a basic project

    This is the first 'learning hill'. It's not very difficult, but even the most basic project consists of five files (!) and you need to understand what they are all for.

  • Interacting with the browser DOM

    This is actually very easy, but some of the key facts are undocumented. Knowing the browser DOM helps.

  • Calling IronPython from (unmanaged) Javascript

    This needs a small C# helper class as it uses attributes to mark objects as 'Scriptable'. There is also a mistake in the docs on how to reference assemblies!

  • Calling Javascript from IronPython

    Again needs a simple C# class (two if you want to pass arguments and get a return value). Not difficult though.

So now I need to work out some demos to show off what can be done with this. I'm working on creating a 'mini-Resolver' that works in the browser!

I'm not sure if I'll have time to write these up as blog entries before the talks, so you might just have to wait...

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-07-20 23:30:17 | |

Categories: , ,

Resolver Beta News

emoticon:computer Response to the Resolver Beta was much bigger than we expected. Great. Smile

To cope with this we'll be sending out beta 'invites' in waves, a few at a time. We're just making some (more) last minute adjustments (the only thing left is the refactoring of the paste command which will definitely be finished next week). We've also done some tidying up of the API so that we shouldn't have to make any backwards incompatible changes in the near future.

After that we will be sending out more invites at regular intervals - so if you have signed up, don't worry! If you haven't yet signed up to try Resolver, then what are you waiting for!

Our intern Konrad has done an example of using the Gdata API to populate a Resolver spreadsheet from Google calendar. Hopefully this will appear as an article on Resolver Hacks soon. If I speak nicely to him (and stop punching him at work) he claims he might do an example of interacting with Google spreadsheets from Resolver. Smile

Oh and my boss says that I was wrong about him having a secret identity as a TV actor. His real secret identity is as a bodybuilder. Surprised

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-07-20 21:35:29 | |


Python Programmer?

emoticon:file1 Today I was hoping I might get some time to do a bit more hacking with Javascript. Instead I spent the day installing perl scripts, and wrestling with apache configuration files, cron jobs and php! You would hardly know I'm a Python programmer...

I blame it on the fact that my boss is leading a secret double life as a TV Actor. Laughing

Oh, and a hello to Konrad our first intern of the summer. We had many applicants from across Europe and the UK. None of the top five were English (although there were several in the top ten) - four were from Poland and one from Germany. The two we chose are both from Poland [1].

Anyway, Konrad has just started a blog. At least partly in response to us forcing him to work on Windows!

His first entry is on how to get a decent console environment setup on Windows...

[1]A country that is churning out a great many quality programmers. For example, a lot of the Polish applicants had done at least some pair programming and unit testing. We were lucky if the English students had even been taught that testing existed.

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-07-16 21:18:58 | |

Categories: , , ,

Resolver Beta Program

emoticon:firefox We are accepting sign-ups for the Resolver beta:

We have a couple of things we would like to fix first, but we hope to send out beta copies sometime this week. If we are swamped with responses then we might start with just the first couple of hundred people, but you're probably safe if you get in in the next few days!

Currently Resolver is Windows only, but we are interested in knowing about users of Mac and Linux who would like to use Resolver. It will be a while longer before we can get you a copy to try though. Smile

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-07-16 14:33:26 | |


Grid from Javascript

emoticon:html Those of you who read my blog entries of last week may not be surprised by this, but I've been experimenting with the Ext Javascript Library, because of the grid that it has.

The grid can be populated from JSON, XML, or Arrays and includes a built-in cell editor. I haven't done much Javascript, so I've had fun learning.

The ExtJS grid

The image above shows what I've achieved so far. Smile

You can also have a play. If it seems slow to load, that is because I've referenced the full (490k) library plus CSS files when I'm only using a small part of it. If this makes it into any kind of production use then I'll only use the parts of the library that I actually need...

It seems that the grid is intended for showing rows of data rather than being a plain grid of data in quite the way I want. So I haven't yet got row headers looking right (but custom renderers are easy to define).

The data is stored as an array of arrays, using the SimpleStore, and the grid itself is an EditorGrid. It didn't take too long to create this example, but there was a bit of a learning curve so I thought I would show the interesting bits of the code here. You can also download a zipfile of the whole example (520kb).

The first thing to do is to create the column model, which tells the grid how to display each of the columns. The first column will be the row headers whilst the rest of the columns will be populated with a TextField so that they are editable:

columns = ['', 'A', 'B', 'C', 'D', 'E', 'F'];

GridRenderer = {

    init: function(){

        // shorthand alias
        var fm = Ext.form;

        // the column model has information about grid columns
        cols = Array(columns.length);

        // The row index is not editable
        cols[0] = {
           header: '',
           width: 100,
           dataIndex: ''

        for (index = 1; index < columns.length; index++) {
            col = columns[index];

            editor = new Ext.grid.GridEditor(new fm.TextField({ allowBlank: true }));
            cols[index] = {
               header: col,
               dataIndex: col,
               width: 100,
               editor: editor,
               sortable: false

        cm = new Ext.grid.ColumnModel(cols);
        cm.defaultSortable = false;

Next we need to create the datastore, which is populated from an array of arrays. Initially these will all be empty, except for the first column which will contain the row nummbers:

// Create the multi-dimensional array containing the initial data
numRows = 10;
data = Array(numRows);
for (index = 0; index < numRows; index++) {
    data[index] = Array(columns.length);
    data[index][0] = index + 1;
    for (i = 1; i < data[index].length; i++) {
        data[index][i] = '';

// A Simple datastore based on arrays
dataStore = new{ fields: columns, data: data, id: 0 });

Next we need to create and render the grid:

        // create the editor grid
        gridConfig = {
            colModel: cm,
            ds: dataStore
        grid = new Ext.grid.EditorGrid('editor-grid', gridConfig);

        layout = Ext.BorderLayout.create({
            center: {
                margins: {left: 3, top: 3, right: 3, bottom: 3},
                panels: [new Ext.GridPanel(grid)]
        }, 'grid-panel');

        // render it

All this was done inside an object I called GridRenderer, so we need GridRenderer.init to be called when the page is ready:

Ext.onReady(GridRenderer.init, GridRenderer);

Not very difficult, but a simple example of a grid with editable cells. The next thing is to do something with this...

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-07-16 14:30:49 | |

Categories: ,

Scott Adams, Turds and XML

emoticon:mirrormask Scott Adams is the creator of Dilbert and also has a blog.

He blogs a lot and although I disagree with a lot he says, he is a very funny writer. From reading the blog you can see Scott's obsessions played out in the cartoons, and I enjoy some of the cartoons a bit less on their own terms - but it is a worthwhile trade-off.

Anyway, one of his recent entries included describing your job in a single sentence:

My favourite was from someone who works with XML:

I make sure turds are well-formed.

Kind of sums up XML... Smile

Like this post? Digg it or it.

Posted by Fuzzyman on 2007-07-15 17:14:51 | |

Categories: , ,

Hosted by Webfaction