pythonpyopenglpysdl2

Type error for params of sdl_CreateWindow using PySdl2


The following code fragment:

self.width = 640
self.height = 400

self.window = sdl2.SDL_CreateWindow (
    'OpenGL test',
    sdl2.SDL_WINDOWPOS_UNDEFINED,
    sdl2.SDL_WINDOWPOS_UNDEFINED,
    self.width,
    self.height,
    sdl2.SDL_WINDOW_OPENGL | sdl2.SDL_WINDOW_RESIZABLE
)

gives this error on Windows:

enter image description here

Seems there's something wrong with this parameter:

sdl2.SDL_WINDOW_OPENGL | sdl2.SDL_WINDOW_RESIZABLE

Using:

Strange thing is this used to work on Python 2.7.

Anyone knows what could be the problem?


Solution

  • It's the (beep) unicode thing. Correct code:

    self.width = 640
    self.height = 400
    
    self.window = sdl2.SDL_CreateWindow (
        b'OpenGL test',     #!!!!!!! Note the b !!!!!!!
        sdl2.SDL_WINDOWPOS_UNDEFINED,
        sdl2.SDL_WINDOWPOS_UNDEFINED,
        self.width,
        self.height,
        sdl2.SDL_WINDOW_OPENGL | sdl2.SDL_WINDOW_RESIZABLE
    )
    

    And the error message showed the wrong line, which doesn't help.