I was a bit surprised to see the example application was written (of all things) in C. Besides being harder and taking longer to write, it's too hard to change (and going to be flaky since a SEGV is so much easier to hit.)
I've done some work on a framework for PyGTK (0.6 only for the moment, but GTK+2 support is coming) that makes writing an app like this one trivial. In fact, the examples include a temperature converter app (`just like ye ole Mr. Raskin said'). The code is so tiny it can fit in a /. comment:
from Kiwi import Delegates, FrameWork, mainquit
class Farenheit(Delegates.GladeDelegate):
widgets = ["quitbutton", "temperature",
"celsius", "farenheit" ]
def __init__(self):
Delegates.GladeDelegate.__init__(self,
"faren", delete_handler=mainquit)
def convert_temperature(self, temp):
farenheit = (temp * 9/5.0) + 32
celsius = (temp - 32) * 5/9.0
return farenheit, celsius
def clear_temperature(self):
self.farenheit.set_text("")
self.celsius.set_text("")
def on_quitbutton__clicked(self, *args):
self.view.hide_and_quit()
def after_temperature__changed(self, entry, *args):
temp = entry.get_text().strip() or None
if temp is None:
self.clear_temperature()
else:
farenheit, celsius = self.convert_temperature(float(temp))
self.farenheit.set_text("%.2f" % farenheit)
self.celsius.set_text("%.2f" % celsius)
delegate = Farenheit()
delegate.show_and_loop()
It's Python, of course :-) Docs and code available under the LGPL: http://www.async.com.br/projects/kiwi/