I’ve been a bit adventurous in learning new stuff. I’ve just done some small programs in Python, and found it a compact, powerful language.

I’ve also not done much with Gtk. Nor with glade, which is a pretty interface builder from the Gnome folks.

So why not combine these things to a new project?

So I started playing around with PyGTK.

Here’s the current result:

notekeeper screenshot

This is around 180 lines of python code (250 lines total). Badly written mostly… ;-) but a lot of stuff is already working:

The data is loaded from an xml file (hooray, libxml python bindings), which is used to generate the tree on the left. When you select a node in the tree, the corresponding contents from the xml file (marked up with “bold”, “italic” and “underline” elements) are displayed in the textview on the right. You can edit the contents, cut, copy and paste are working, as are the bold, italic and underline buttons above. They will also change when you move the cursor around.

Another 65 lines of code (that need to be rewritten, albeit they are working) go into refactoring the marked up text into XML, because the textview allows overlapping tags, XML doesn’t. So if you leave this dead code away, it’s just 120 lines of code!

When I’m finished, this will be something like tuxcards (except not in Qt), or CueCards (non-free, windows only, but has a freeware version my mother uses a lot)

So what’s left to do:

  • rewrite the to-xml formatter to use libxml2
  • edit functions for the “pages” in the tree
  • copy & paste for subtrees
  • output (well, save the xml file)
  • file dialogs

But it’s amazing on how much you can do with just 120 lines of python code!

Update: I couldn’t sleep. The code is now 259 lines total, 184 lines of code. It now updates the XML data and dumps it on exit. Saving is now trivial.