Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: python-sfml2: version 1.1  (Read 6242 times)

0 Members and 1 Guest are viewing this topic.

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
python-sfml2: version 1.1
« on: June 14, 2012, 10:28:56 pm »
The last release, which I announced two weeks ago was a fast release; a snapshot taken on the way to the release candidate build. I had focused on the most important parts of the API (classes/functions most used) to make it the most usable. I’m now pleased to announce that the update is over and that the binding is complete, clean and stable.

When saying complete I am referring to a binding containing all classes and functions available in SFML separated in five different modules: system, window, graphics, audio and network. The network module is provided in order to be exhaustive but its use is discouraged since the standard python library already provides one. Documentation, tutorials and the official examples are included to help you with using it. For example; it explains you how to integrate pySFML2 to PyQt4.

By saying clean, I mean a binding where error messages are handled properly and where you don’t have to use byte strings for everything when you use Python 3.  The source code is also clean so people who’d like to get involved or want to modify it will find code following conventions, using the right Cython syntax and split into different files.

By saying stable, I mean a binding where automatic tests have been performed, hopefully preventing myself from introducing new error later on with changes. Of course I can’t pretend there’s no bugs since it’s the first release and I hope to receive as much feedbacks as possible to fix the remaining issues.

I consider this binding more pythonic as it doesn’t try to emulate multiple definition function such as in C++ that Python doesn’t support, and you won’t have to deal directly with types, which give more flexibility to the binding.

This version includes two more examples: pong.py and shader.py.

Installers for Windows and packages for Ubuntu are provided for ease of installation.

To give you an overview, here are four pieces of code that summarize interesting features that you don't find in the official binding.

Import module independently.
from sfml.window import sf # need only the window module ?
from sfml.audio import sf # need only the audio module ?
 

More flexibility when using vectors.
vector = sf.Vector2()
vector.x = 23 # set an integer
vector.y = 6.42 # set a float
vector.z = Decimal(0.12346578) # set a decimal for advantages over the float datatype
 

The way you handle events in pySFML2 may surprise you :)
for event in window.events:
    if type(event) is sf.CloseEvent:
        window.close()

    if type(event) is sf.KeyEvent and event.pressed:
        character.fire()

    if type(event) is sf.FocusEvent:
        if event.lost: music.stop()
        elif event.gained: music.play()
 

sf.Image has an extra method that allows you to view the current image state. Useful for debugging.
image.load_from_file("myimage.png")
image.create_mask_from_color(sf.Color.YELLOW)
image.show() # launch a viewer with the current image state
 

I’m linking you to the on-line documentation for installation and explanations.

Website: http://openhelbreath.net/python-sfml2/
Documentation: http://openhelbreath.net/python-sfml2/documentation.html
Bugtracker: http://openhelbreath.net/python-sfml2/flyspray/
Github: https://github.com/Sonkun/python-sfml2

The next release should add the last missing official examples (voip.py, x11.py, cocoa.py and win32.py), fix a lot of issues (if any) and provide installers for Mac OSX and packages for Fedora.

I hope there aren’t any major bugs that will prevent you from using the binding.
« Last Edit: June 15, 2012, 05:57:24 am by Sonkun »
Interested in using SFML with Python ? Try out its Python binding!

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: python-sfml2: version 1.1
« Reply #1 on: June 14, 2012, 11:01:36 pm »
I haven't made the Windows installers for 64bits machine yet, I'll provide them tomorrow. Also packages for Debian/Ubuntu are being built, so installing from depot would install the version 1.0 (and not 1.1), it should be done in five hours.
Interested in using SFML with Python ? Try out its Python binding!

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: python-sfml2: version 1.1
« Reply #2 on: June 14, 2012, 11:07:26 pm »
I had forgotten to upload the documentation, it's done now :p
Interested in using SFML with Python ? Try out its Python binding!

Sonkun

  • Full Member
  • ***
  • Posts: 241
    • View Profile
Re: python-sfml2: version 1.1
« Reply #3 on: June 25, 2012, 04:48:15 am »
Someone made a pull request on Github, except him, has anyone tried the binding ? Feedbacks are appreciated :)
Interested in using SFML with Python ? Try out its Python binding!

Hoff123

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Re: python-sfml2: version 1.1
« Reply #4 on: August 08, 2012, 02:33:55 pm »
Hi! This is actually my first post on this forum :).

Anyway so I used to do some python and I love Python.
Continue what you are doing. Even though I'll just use the normal SFML(C++), I think this is very cool.

Oh, and as you might guess I'm quite new to programming and SFML. Even though I've done some Python before, I'm still kind of a noob :).

shackra

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • http://swt.encyclomundi.org
Re: python-sfml2: version 1.1
« Reply #5 on: August 13, 2012, 11:34:30 pm »
I feel like I'll give your bindings a chance...

Edit:
wait, what? GPLv3??
I take it!! :D


Edit of the edit:
You should make available a bug tracker (or fix the old one)!
« Last Edit: August 14, 2012, 03:53:18 am by shackra »

GNU User
Python programmer
Blog

shackra

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • http://swt.encyclomundi.org
Re: python-sfml2: version 1.1
« Reply #6 on: December 16, 2012, 05:28:15 am »
reminder: I'm packaging this bindings for Parabola GNU/Linux-libre ;)

GNU User
Python programmer
Blog