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

Author Topic: Python binding buggy?  (Read 14542 times)

0 Members and 1 Guest are viewing this topic.

Wolfram

  • Newbie
  • *
  • Posts: 13
    • View Profile
Python binding buggy?
« on: September 11, 2010, 03:27:34 pm »
Huhu,
I tried Python with PySFML 1.6 on Windows 7 64bit with 32bit Python 2.7 but it crashes..
(In C++ i haven't any problems...)

First I tried the sample from the PySFML tutorial, this worked good.
Than I tried the samples in the SDK but it chrashed in the Worm sample when I pressed the enter/return key.
I also tried to make a simple game but it chrashes in this line:
Code: [Select]

Window.Draw( sf.String( "MenuState" , sf.Font.GetDefaultFont(), 30 ) )


Source:
Code: [Select]

from PySFML import sf

class BaseState( object ):
    def Run( self, Window ):
        return None
class MenuState( BaseState ):
    def __init__( self ):
        super( MenuState, self ).__init__()

    def Run( self, Window ):
        while True:
            Event = sf.Event()
            while Window.GetEvent(Event):
                if Event.Type == sf.Event.Closed:
                    return GameState
            Window.Clear()
            Window.Draw( sf.String( "MenuState" , sf.Font.GetDefaultFont(), 30 ) )
            Window.Display()
        return None
class GameState( BaseState ):
    def __init__( self ):
        super( GameState, self ).__init__()

    def Run( self, Window ):
        while True:
            Event = sf.Event()
            while Window.GetEvent(Event):
                if Event.Type == sf.Event.Closed:
                    return None
            Window.Clear()
            Window.Draw( sf.String( "GameState" , sf.Font.GetDefaultFont(), 30 ) )
            Window.Display()
        return None
class Game:
    def Run( self ):
        Window = sf.RenderWindow( sf.VideoMode( 800, 600, 32 ), "PySFMLTest", sf.Style.Close )
        Window.SetFramerateLimit( 60 )

        Next_State = MenuState

        while Next_State is not None:
            State = Next_State()
            Next_State = State.Run( Window )

Main = Game()
Main.Run()


If I remove the Window.Draw(...) lines, it works...
Is the Python binding buggy?

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Python binding buggy?
« Reply #1 on: September 13, 2010, 01:20:42 am »
svenstaro, can you have a look into it? Maybe you adjusted something there for the 1.6 binding.

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Python binding buggy?
« Reply #2 on: September 13, 2010, 03:06:44 am »
It probably doesn't find the media in both cases. Can you post the error please?

Wolfram

  • Newbie
  • *
  • Posts: 13
    • View Profile
Python binding buggy?
« Reply #3 on: September 13, 2010, 01:43:51 pm »
Quote from: "Svenstaro"
It probably doesn't find the media in both cases. Can you post the error please?


Ehm, in my sample I don't use any media, only SFML.
It crashes in both cases without an error.
Windows displays only that python.exe doesn't work anymore.

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Python binding buggy?
« Reply #4 on: September 13, 2010, 02:21:08 pm »
Works for me. Also, you are using media since you are using a font. Can you post the error that you get when running python yourapp.py from the command line?

Wolfram

  • Newbie
  • *
  • Posts: 13
    • View Profile
Python binding buggy?
« Reply #5 on: September 13, 2010, 02:32:04 pm »
Quote from: "Svenstaro"
Works for me. Also, you are using media since you are using a font. Can you post the error that you get when running python yourapp.py from the command line?

Ok, but the font media is build in SFML?! So I don't use any extern media.^^

I run my sample in the python shell:
Code: [Select]
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>

There aren't any errors.. i get only the message from Windows that python.exe doesn't work anymore.

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Python binding buggy?
« Reply #6 on: September 13, 2010, 02:43:48 pm »
I just tested on Windows 7 x64 just for you and it worked.

EDIT: Unless you provide more info I can't really help. Did you try making PySFML yourself with your specific version of Python?

Wolfram

  • Newbie
  • *
  • Posts: 13
    • View Profile
Python binding buggy?
« Reply #7 on: September 13, 2010, 03:20:17 pm »
:-/ for me it does not work..

I tried to build them myself, but i get an error: Unable to find vcvarsall.bat
(I have VC2010 Express.)
(I don't have MinGW and I don't really know which package I need to install to use MinGW.)

Did you use also Python 2.7 on your Windows? Otherwise I'll try Python 3.. :-/

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Python binding buggy?
« Reply #8 on: September 13, 2010, 03:42:38 pm »
I used Python 2.7 and I also tried it in my virtual machine. You could updating your drivers or try it under another OS.

Wolfram

  • Newbie
  • *
  • Posts: 13
    • View Profile
Python binding buggy?
« Reply #9 on: September 13, 2010, 04:11:34 pm »
Hmpf, I tried Python 3.12 but it also crashes :-/
My drivers are up to date.
SFML with C++ works perfectly..
:-/

Maybe I try later to install MinGW and compile PySFML.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Python binding buggy?
« Reply #10 on: September 14, 2010, 11:07:08 am »
Please try the following:
Code: [Select]

while True:
Event = sf.Event()
while Window.GetEvent(Event):
if Event.Type == sf.Event.Closed:
return GameState

Window.Clear()

string = sf.String( "MenuState", sf.Font.GetDefaultFont(), 30 )
Window.Draw( string )

Window.Display()


I somehow think it's a reference counting problem maybe. What Wolfram forgot to say is that when he creates the sf.String object outside the while loop, everything works perfectly, so a media problem can be safely ruled out.

Wolfram

  • Newbie
  • *
  • Posts: 13
    • View Profile
Python binding buggy?
« Reply #11 on: September 14, 2010, 01:36:33 pm »
This works:
Code: [Select]

def Run( self, Window ):
        string = sf.String( "MenuState", sf.Font.GetDefaultFont(), 30 )
        while True:
            Event = sf.Event()
            while Window.GetEvent(Event):
                if Event.Type == sf.Event.Closed:
                    return GameState
            Window.Clear()
            Window.Draw( string )
            Window.Display()
        return None


BUT, it crashes after I press Close o.O although I don't have a Window.Draw() in the GameState class.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Python binding buggy?
« Reply #12 on: September 16, 2010, 12:47:34 am »
And when you drop the "Window.Draw( string )" call, everything works?

Wolfram

  • Newbie
  • *
  • Posts: 13
    • View Profile
Python binding buggy?
« Reply #13 on: September 17, 2010, 03:27:23 pm »
Nope, it also crashes when I change the state. :-/

Spellbreaker

  • Newbie
  • *
  • Posts: 33
    • ICQ Messenger - 287156171
    • MSN Messenger - spellbreaker@live.de
    • Yahoo Instant Messenger - Spellbreaker1979
    • View Profile
    • http://www.apeironstudios.com
Python binding buggy?
« Reply #14 on: September 23, 2010, 02:02:03 pm »
I can confirm that, I'll try to get more information. Python2.7 & SFML 1.6 on Win7 - 64 Bit

 

anything