Browsing articles tagged with " Pyglet"
Sep
25

Balthasar Week 2 Report

By Eric Shull  //  Blog Post  //  1 Comment

In a post a couple of weeks ago, I mentioned setting up a new GoogleCode project. I’m happy to say that Balthasar is coming along nicely. For details on what Balthasar is and how to get involved, read on.

read more

Jun
29

# PyMT

By Eric Shull  //  Blog Post  //  3 Comments

Tom has been skeptical of Python (I’ve never figured out why), but I now have something to change his mind. Last week I stumbled across PyMT, a cryptic name in which the last two letters stand for one of Tom’s favorite subjects: multi-touch.

PyMT is in version 0.2 and it’s built on pyglet. There’s one tutorial that shows how easy it is to create a GUI with PyMT.

The one thing I’d like to do is get rid of the red dot that appears on clicking. It’s meant to indicate a finger pushing on a multi-touch surface, but it would be nice to be able to make some simple apps without having a giant pimple appear under the cursor whenever one clicks. That said, the multi-touch capabilities are pretty impressive for v0.2

Update: There are some videos demonstrating the software. My personal favorite is the first one featuring the Dell XT2. Having a tablet (albeit not multi-touch), I could get some good out of the 36 lines of code running the app in the demo.

Jun
24

# Override decorator

By Eric Shull  //  Blog Post  //  No Comments

While working with pyglet one day, I made the mistake of subclassing the window class and overriding the __init__ method, which prevented the window from showing. To fix this, it’s easy enough to add a call to super(Window, self).__init__(*args, **kwargs), but I went a different route. Here’s a decorator called override that puts it in for you:

def override(function):
    def wrapper(instance, *args, **kwargs):
        super(instance.__class__, instance).__init__(*args, **kwargs)
        return function(instance, *args, **kwargs)
    return wrapper

To use it, simply use the decorator notation in a subclassed method:

class MyWindow(pyglet.window.Window):
    @override
    def __init__(self, *args, **kwargs):
        # code goes here, no need to call super!