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

Author Topic: LoadFromFile crashes without error.  (Read 8354 times)

0 Members and 3 Guests are viewing this topic.

nbermudez

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
LoadFromFile crashes without error.
« on: January 28, 2013, 10:28:29 pm »
Greetings!

I'm working on a game using PySFML, I'm trying to change the font of a sf.String variable but python.exe stops working without an error message.
Here is what I've written:

font = sf.Font()
font.LoadFromFile('my_downloaded_font.ttf', 50)
self.welcomemsg = sf.String("Welcome, "+self.lastplayer, font)

Thanks for any help.

UPDATE: I almost forget it, I'm using IDLE (python 2.7), Windows 7 and PySFML 1.6

UPDATE: Everything's OK when I do this:

 
font = sf.Font()
font = sf.Font.GetDefaultFont()
#font.LoadFromFile('my_downloaded_font.ttf', 50)
self.welcomemsg = sf.String("Welcome, "+self.lastplayer, font)
« Last Edit: January 28, 2013, 11:20:42 pm by nbermudez »

nbermudez

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: LoadFromFile crashes without error.
« Reply #1 on: January 29, 2013, 10:48:23 pm »
Before someone says it. I know its an old topic about this exact same quest but replies were just like change to version 2.0 which I can't do.
Any real solution to the problem?

shackra

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • http://swt.encyclomundi.org
Re: LoadFromFile crashes without error.
« Reply #2 on: January 31, 2013, 02:28:32 am »
Before someone says it. I know its an old topic about this exact same quest but replies were just like change to version 2.0 which I can't do.
Any real solution to the problem?

You have to instantiate sfml.Font using sfml.Font.load_from_file (bastie leonard bindings, though) or sfml.Font.get_default_font

So:
# incorrect
font = sfml.Font()
font = sfml.Font.get_default_font()

# correct
font = sfml.Font.get_default_font()
 

If you are thinking on using sfml2-python2 (Sonkun bindings, of course), please take a look on the documentation http://python-sfml.org/api/graphics.html#font and http://python-sfml.org/api/graphics.html#text
« Last Edit: January 31, 2013, 02:30:39 am by shackra »

GNU User
Python programmer
Blog

nbermudez

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: LoadFromFile crashes without error.
« Reply #3 on: February 02, 2013, 01:42:05 am »
Quote
font = sfml.Font.get_default_font()
I'm guessing you are using sfml because you did
from PySFML import sf as sfml
. If that is the case I already tried that and it says Font has no attribute 'load_from_file', same thing with get_default_font.

shackra

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • http://swt.encyclomundi.org
Re: LoadFromFile crashes without error.
« Reply #4 on: February 02, 2013, 03:32:24 am »
are you using sfml 1.6 or 2.0?  ???

GNU User
Python programmer
Blog

nbermudez

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: LoadFromFile crashes without error.
« Reply #5 on: February 02, 2013, 04:49:57 pm »
PySFML 1.6
I had some modules already implemented in 1.6 and no time to rewrite it for 2.0  :(

shackra

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • http://swt.encyclomundi.org
Re: LoadFromFile crashes without error.
« Reply #6 on: February 02, 2013, 07:15:00 pm »
PySFML 1.6
I had some modules already implemented in 1.6 and no time to rewrite it for 2.0  :(

Better move your code to 2.0, there is a obvious difference between 1.6 and 2.0's API . Also, 2.0 have several bug fixes...

GNU User
Python programmer
Blog

 

anything