PyGame with Skulpt

597 views
Skip to first unread message

Tiago Marques

unread,
May 18, 2016, 1:56:20 PM5/18/16
to Skulpt
Hi everyone!

My name is Tiago Marques and I am trying to execute a Python script that uses PyGame with PyOpenGL primitives in Skulpt with no success. Can anyone show me some example of PyGame with Skulpt so I can see what is my mistake?

Thank you in advance for your time!


Austin Bart

unread,
Jun 15, 2016, 7:47:31 PM6/15/16
to Skulpt
I noticed no one ever responded to this. Here's what I know about this.

To my knowledge, no one has implemented the Pygame library in Skulpt. People have created versions of MatPlotLib and Numpy (albeit limited), but not that library. You could create your own by creating the required files in https://github.com/skulpt/skulpt/tree/master/src/lib

You could also check out the simplegui module that CodeSkulptor uses, and see if that could serve as a base: http://www.codeskulptor.org/docs.html#tabs-Python

Best of luck with this, and sorry that I don't have better news.

~Cory

Sam Wickins

unread,
Mar 16, 2024, 9:54:42 AMMar 16
to Skulpt
Hi,
I know this is an old thread but I have a question that relates and wondered if someone could help me?
I have built a python IDE using skulpt and have imported libraries such as turtle and all works fine. I wanted to also provide the PyGame library and found this on GitHub: https://github.com/Petlja/pygame4skulpt?tab=readme-ov-file
Following the docs I also managed to get this working, but only if I use the skulpt dist files that come with it. Now this is a problem because these files do not support certain python 3 such as print("hi","there") as this is outputted as ("hi"),("there") when of course it should just be a string with space. Now I know I could use the old dist files conditionally when a user imports PyGame and the most recent dist file for any other but as I have a wordpress environment this is tricky as I need to enqueue the JS files and having both equeued maakes the print() issue persist.
My question is, with the newer version of skulpt, did they change the way that libraries were imported? The PyGame docs says to import like this:

    var basePath = 'pygame/';
    Sk.externalLibraries = {
        'pygame': {
            path: basePath + '__init__.js',
        },
        'pygame.display': {
            path: basePath + 'display.js',
        },
        'pygame.draw': {
            path: basePath + 'draw.js',
        },
        'pygame.event': {
            path: basePath + 'event.js',
        },
        'pygame.font': {
            path: basePath + 'font.js',
        },
        'pygame.image': {
            path: basePath + 'image.js',
        },
        'pygame.key': {
            path: basePath + 'key.js',
        },
        'pygame.mouse': {
            path: basePath + 'mouse.js',
        },
        'pygame.time': {
            path: basePath + 'time.js',
        },
        'pygame.transform': {
            path: basePath + 'transform.js',
        },
        'pygame.version': {
            path: basePath + 'version.js',
        },
    };

And this works fine with old skulpt dist. But when the new version is used I get an import error.

Any help would be gratefully received.

Sam 
Reply all
Reply to author
Forward
0 new messages