SFML community forums

Bindings - other languages => Python => Topic started by: m_p_w on September 09, 2016, 06:39:18 pm

Title: pySFML on linux how to make it work
Post by: m_p_w on September 09, 2016, 06:39:18 pm
This might be stupid question, but I am not sure what do to. Basically I have install sfml-dev (2.3.2) and later python-sfml(2.2) and cython(0.23.4) because by my understanding python-sfml is "not a pure python library. Rather, it is a set of extensions that provide a Pythonic API around a C++ library. As such, every PySFML object is really a wrapped C++ object which can be manipulated through Python methods".

Now I have wrote a small program (displaying a window) in python, but I get error 'module' object has no attribute 'RenderWindow'.

What am I doing wrong? I am sorry for asking :(

I know it might sound like I am clinically retarded, but normally after installing pygame, I didn't have to link anything when programming in python in geany IDE, but when it comes to SFML and G++, I had to link the SFML libraries. It is possible that I have to link somehow pySFML (if so, how to do it)?
Title: Re: pySFML on linux how to make it work
Post by: m_p_w on September 10, 2016, 12:14:30 am
I managed to make it work!!!!!

import sfml as sf
from sfml import sf  # I added this line and it works 100% :D

window = sf.RenderWindow(sf.VideoMode(800, 600), "text example")



while window.is_open:
    for event in window.events:
        if type(event) is sf.CloseEvent:
            window.close()

    window.clear()
    window.display()
Title: Re: pySFML on linux how to make it work
Post by: m_p_w on September 10, 2016, 05:40:49 am
Actually only "from sfml import sf" is needed