Python, Pyglet, Pygame and Py-Me
April 10, 2013 1:32 AM   Subscribe

Which is better: Pyglet or Pygame?

I'm moving into Python after too long with Java, and though I'm not looking to build a game or anything I have a project in mind in which I want to have some sort of canvas to draw on programatically, some way of playing sounds, etc. As a result, it seems like one of the game libraries probably offers the best option for getting it done. If that's not correct, please correct me!

It seems like the big two are Pyglet and Pygame, and while I googled for a consensus first, there doesn't seem to be much of one and so I would like to gauge the responses from people on AskMe. I trust allyall more than I trust random Redditors, what can I say?

So, for ease of development, utility, support, performance, whatever else you can think of, which one is the better option for putting sprites and lines on screen and doing cool things with input devices?
posted by barnacles to Technology (6 answers total) 7 users marked this as a favorite
 
I have used neither, but I've heard plenty of people talk about Pygame at Python user group meetings. Haven't heard of the other one.
posted by oceanjesse at 4:37 AM on April 10, 2013


I have tried both, although not for your exact use case -- I was trying to visualize data and results from my research. This was also a few years ago. At that point, Pygame's Mac support was atrocious, and it was much more library than I actually needed. (It looks like Pygame's Mac support may have improved since.) Pyglet was lighter-weight and much less of a pain to install.

I don't use either of these libraries now. I just use GLUT and OpenGL through PyOpenGL, since the small amount of code that Pyglet saved me wasn't worth the extra dependency.
posted by Serf at 5:03 AM on April 10, 2013


I think you have two more options worthy of consideration.

Jython is a version of Python that runs on the JVM and should make it easy to create Java objects and call their methods. This would help you make use of your past Java experience, especially the library part. It seems to be active and well based on looking at the project homepage and noting last update from this year, but I have to admit I've never written a single line of code for it.

I have a little experience with PyQt4, which is a Python binding of the cross-platform Qt GUI library. It has a canvas class for graphics, allows you to create OpenGL contexts for graphics, and has a multimedia component called Phonon for playing audio and video. If you are familiar with GUI programming concepts and idioms, the move from Java and AWT or Swing to Python and Qt will be conceptually simple, even though they are quite different in many details. I think it should work fine for your purposes, and I've never had trouble installing it on different OSes, apart from the annoyances different DLL versions sometimes cause on Windows. (Not a problem at all if you only install one version.)

My recommendation would be to go with PyQt4 if you are happy with its documentation and the tutorials & books teaching it you that you can find. I don't have any particular recommendations for the latter, but you can do a web search.

On the cons side, it might be needlessly big if you have only a modestly-sized project in mind.
posted by tykky at 10:12 AM on April 10, 2013


Not giving an answer that you asked for, but when I looked to make the same decisions recently I decided to go with Kivy. It's built on Pygame, but I found much more accessible and faster to just get stuff working. (Also it makes it easy to assemble cross-platform apps if that comes in handy.)
posted by Ookseer at 11:38 AM on April 10, 2013


I've been tinkering with pyglet lately for lower level stuff like writing shaders. I like it, but the reddit thread is right about the small community. It's very rare I search for something and find an answer written after 2010. That being said, it did have a release last year which fixed their Mac support. So there does seem to be people working on it.

To make your decision tougher, Cocos2d was built on top of pyglet and might be more what you are looking for. I haven't used the python version, but the ObjectiveC port has been extremely popular for developing iPhone games.
posted by Gary at 11:23 PM on April 10, 2013


Response by poster: Thank you to everyone who responded; even though I'm still in about the same position I was before, I quite appreciate your answers!

Now, responding in turn to specific points:

tykky: "Jython is a version of Python that runs on the JVM and should make it easy to create Java objects and call their methods. This would help you make use of your past Java experience, especially the library part. ... My recommendation would be to go with PyQt4 if you are happy with its documentation and the tutorials & books teaching it you that you can find."

tykky, I appreciate this point, but for a number of reasons I've decided to leave Java and move on to Python as my go-to language. My development days are well in the past, at this point, and most of what I do involves straight Python, so I'd rather not split the bill (so to speak!).

Beyond that, thanks for pointing out PyQt4 because (heh) I hadn't considered the drawing capabilities of something like Qt with a full widget set. I'll go ahead and investigate that, both for the project I currently have in mind and for things beyond!

Ookseer: "Not giving an answer that you asked for, but when I looked to make the same decisions recently I decided to go with Kivy."

Ookseer, I have been intrigued by what I'd seen of Kivy so far, but I was under the (apparently mistaken) impression it was primarily for touch-capable devices. It certainly looks pretty, though, and since it does desktop machines, as well ... well, crap, one more library to check into! :) However, the multitouch possibilities are already raising some ideas for me.

In the end, I find myself drawn primarily by the idea that Pyglet is more Pythonic than Pygame, even if its support levels are not at the same level. I'm not looking to do anything outrageously difficult, and I like nicely designed APIs. I guess it's useful that there's not much consensus on one or the other, in that now I have to get off my ass and get into 'em both to investigate.

To the internet!
posted by barnacles at 2:10 AM on April 13, 2013


« Older What are these benign lifelong hand dots?   |   Nice restaurants in or around Lafayette, CO Newer »
This thread is closed to new comments.