Monday, January 05, 2009

The Embedded GUI, continued...

After 3 days of mixing it up with Pyglet, I gave up. I had resolved to do things the pygletty way, and I really wanted to use pyglet's shiny batched graphics, but in the end it defeated me. There was simply too many hoops to jump through to draw lines, and draw text and then detect picks with the mouse... etc. If I had more time, this would be the superior solution, but I simply didn't have time to invest in new development.

The next thing to try was wxPython. I went further with wx, but when I realised how little control I had over the look (or even just sizing) of buttons, I became a little discouraged. Then, when wx started hiding exceptions from me with what seemed to be a sys.exit(-1), I gave up. I doubt I'll be going back to wx, its just not... fun.

Getting somewhat desperate, I contemplated putting a BaseHTTPServer in my embedded code, and building the interface using HTML and jQuery. Half a day later, I realized this was a very bad idea. Without a nice framework like Pylons, it would be a nightmare.

Defeated and deflated, with 80% of my time budget spent... I was at a loss. So, I turned back to the old and faithful pygame. It is so much simpler to understand bytes, surfaces, sprites. And hey, If I want to draw text on a sprite, I can. Oh and it has some neat vector drawing operations. A few hours later, I had a custom GUI system, working just the way I wanted. Forms, Buttons, Text Boxes, Labels and Toggle buttons.

I also seem to prefer he way pygame deals with HID events, as compared to pyglet. Pygame gets out of the way and lets me handle things the way I like. :-)

I might actually get this done. Only 8 hrs left....

6 comments:

linuxpoet said...

But no screenshot?

Richard Jones said...

Interesting story. pyglet can be quite hard to wrangle sometimes. I've personally started three GUI toolkits to this date. The latest is actually quite reasonable, I think. I'm sorry I didn't think to fire you a copy of it :(

The direct surface manipulation you get with pygame is pretty damned attractive sometimes when you're elbow-deep in OpenGL buffers :(

_Mark_ said...

Sometimes the overhead of learning the higher level system doesn't seem to justify the cost (especially when you're not trying to share code with people specifically familiar with it); I've gotten a lot more work done with raw WSGI than with django, turbogears, or pylons :-)

Unknown said...

I agree with Mark, it is easier to use framework that you know ultimately well than learn something new (pyglet, wx, ...). This seems to be the main message of your post.

Anonymous said...

Not that this will help you on your quest for a UI library, but cocos 2D attempts to wrap pyglet in a way that might be more familiar to pygame devs. I have only briefly looked at it myself so I can't vouch for how good it is, but it looks promising.

http://www.cocos2d.org/

Ben Sizer said...

I had a very similar experience with wxPython. Turns out it was printing the unhandled exceptions to stdout before exiting, and since I was running in GUI mode (funny that!), I never saw these.

Popular Posts