Forum Archive

Porting Pythonista modules to PC

JadedTuna

About

This is a port of Pythonista-only modules to PC. It will allow you to play games written using scene.py module.

Source

Git repo can be found here

Progress

sound.py - 90%

_scene.py - 51%

_scene_types.py - 30%

console.py - 0%

canvas.py - 0%

Help

If you want to help me, please try to find out and explain to me, how push_matrix and pop_matrix functions work :)
I really need them.

Currently working on

Images, text and Hydrogen. Text rendering is working fine, and now I am trying to write load_image and such stuff.

Supported scripts:

Standart library

  1. Piano.py - built in sounds are required
  2. Stopwatch.py
  3. Basic scene

Other scripts

  1. pull-to-refresh.py
  2. air-hockey-menu.py
  3. Some other stuff I don't really remember right now :)
siddbudd

I love your idea, unfortunately I am too new to Python to be of much help, but I have bookmarked you on github :)

JadedTuna

@siddbudd, thanks :). I am currently working on fixing drawing. Because pygame sets start coords to the top-left of the screen, while Pythonista sets it to start coords to down-left of the screen.
Maybe anyone has any ideas how do I do this? Thanks

dgelessus

@ShadowSlayer, simply use [screen height] - y for any y coordinates and you'll achieve the same y coordinate handling as with Pythonista.

nwinspeare

This is a great idea! However, I am new to Pythonista and I have installed anaconda on my windows 8. I have put the files in the Anaconda\Lib\site-packages folder. I can't get python to recognize the module when I try 'import scene'. What am I missing?
Thanks

JadedTuna

Hey people! I am finally back with some fixes. Sorry for not being active for such long time, I had some other stuff to do.

@dgelessus, thanks :). I already understood. Thought I had to add a little bit more stuff: y = size[1] - (y + h).

@nwinspeare, not very sure what your problem is... I've never used anaconda myself. Try to create some file like mytestfile.py in Anaconda\Lib\site-packages\ and then import it in python: import mytestfile. If it gives you error about module not found - Anaconda\Lib\site-packages\ is probably not in your PYTHONPATH.

About the new version.
I managed to fix drawing, so now it works just like in Pythonista!
In the next update I am going to add normal text drawing, and maybe something else :)

P. S. The piano is now working just as it should, except stroke. I think I am going to write my own function for drawing strokes (it won't be very hard), because when I use stroke in pygame.draw.rect, it gives me VERY weird results.

Ned

Thank you for posting this, ShadowSlayer!

I was just starting to work on precisely the same thing. I'm teaching my daughter programming using Python and was distressed to find that we had to choose between writing (reasonably) portable code with PyGame or writing scripts that would run on her iPad (fun).

When this layer is complete, we can write to the Pythonista interface and run almost anywhere.

Have you by any chance heard of anybody working on the converse - a python-only layer that provides PyGame-like classes and functions implemented in terms of the Pythonista modules? That would open up a large collection of PyGame apps that could then run on iOS. Presumably it would be much larger undertaking. (And yes, I realize that PyGame is normally implemented as natively-compiled code. This would be an exception.)

Thanks again!

imnegan

Fantastic work, thanks!

Cethric

@ShadowSlayer push_matrix and pop_matrix are used for transforms (translate, scale and rotate) however pyGame provides the pygame.transform functions so it is not necessary as such for these functions in the port. (I am not currently at my main computer to test this). I believe that if you were using a PyOpenGL backend then it would heavily rely on push and pop functions.
However this does raise an issue of the pythonista scene module changes the transformation matrix, were as the pyGame pygame.transform creates a new surface object.