Vitavonni

Sun, 04 Sep 2005

Python GTK adventures

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.

[category: /en | Permalink]
Menu
[planet.debian]
[planet.xmlhack]
[planet SELinux]
[munichblogs]
[email]
[RSS 2 feed]
[English RSS 2]
Categories
< September 2005 >
SuMoTuWeThFrSa
     1 2 3
4 5 6 7 8 910
11121314151617
18192021222324
252627282930 
Archives
2010-Mar
2010-Feb
2010-Jan
2009-Dec
2009-Nov
2009-Oct
2009-Sep
2009-Aug
2009-Jul
2009-Jun
2009-May
2009-Apr
2009-Mar
2009-Feb
2009-Jan
2008-Dec
2008-Nov
2008-Oct
2008-Sep
2008-Aug
2008-Jul
2008-May
2008-Apr
2008-Mar
2008-Feb
2008-Jan
2007-Dec
2007-Nov
2007-Oct
2007-Sep
2007-Aug
2007-Jul
2007-Jun
2007-May
2007-Apr
2007-Mar
2007-Feb
2007-Jan
2006-Dec
2006-Nov
2006-Oct
2006-Sep
2006-Aug
2006-Jul
2006-Jun
2006-May
2006-Apr
2006-Mar
2006-Feb
2006-Jan
2005-Dec
2005-Nov
2005-Oct
2005-Sep
2005-Aug
2005-Jul
2005-Jun
2005-May
2005-Apr
2005-Mar
2005-Feb
2005-Jan
2004-Dec
2004-Nov
2004-Oct
2004-Sep
2004-Aug
2004-Jul
Other links:
Swing and the City - Lindy Hop in Munich