Python Bindings for Haiku

I’ve just today begun working on bindings for python to use Haiku APIs. I managed to create a simple GUI application with a label. Here’s the code:

from BKit import *

class MyApplication(BApplication):
def init(self):
BApplication.init(self, “application/x-vnd.myApp”)
frame = BRect(100, 100, 500, 400)
self.window = BWindow(frame, “My First App”,
B_TILTED_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
frame.Set(10, 10, 11, 11)
label = BStringView(frame, “My Label”, “Python in Haiku Rocks!”);
label.ResizeToPreferred()
self.window.AddChild(label)
self.window.Show()

if name == “main”:
app = MyApplication()
app.Run()

And a screenshot:

http://ompldr.org/vOThnag/screenshot.png

This is all it can currently do, but it only took about an hour to setup and add the functionality. As you can see, the programming closely mimics how the same programming would be done in C++. I was wondering if anyone was interested in helping, had any questions, or just wanted to discuss the role of Python in Haiku.

Are making your own bindings from scratch???

They already exist and are quite advanced:
See Donn Cave’s excellent BeThon 0.5.4

http://www.bebits.com/app/1564

Hi xvedejas,

you are aware of one of this year’s Google Summer of Code project (see latest blog post)?

Regards,
Humdinger