Type error when calling sdlttf.TTF_OpenFont() with the pysdl2 Python bindings
Question: I have all dependencies correctly installed (SDL2, SDL2_TTF, pysdl2). I've
tried to provide just the filename for the font and I've tried to hard code
the full path. The font is in the same directory as the python file.

    
    
    import sys
    try:
        from sdl2 import *
        import sdl2.ext as sdl2ext
        import sdl2.sdlttf as sdlttf
    except ImportError:
        import traceback
        traceback.print_exc()
        sys.exit(1)
    
    
    def run():
        sdl2ext.init()
        sdlttf.TTF_Init()
        RESOURCES = sdl2ext.Resources(__file__, "")
        # print(RESOURCES.get_path("arial.ttf"))
        font = sdlttf.TTF_OpenFont(RESOURCES.get_path("arial.ttf"), 24)
        window = sdl2ext.Window("SDL_TTF test", size=(800, 600))
        message = sdlttf.TTF_RenderText_Solid(font, "Hello World", (255, 255, 255))
        window.show()
        running = True
        while running:
            events = sdl2ext.get_events()
            for event in events:
                if event.type == SDL_QUIT:
                    running = False
                    break
            window.refresh()
        return 0
    
    if __name__ == "__main__":
        sys.exit(run())
    

Returns:

    
    
    Traceback (most recent call last):
      File "sdl2_test.py", line 32, in <module>
        sys.exit(run())
      File "sdl2_test.py", line 17, in run
        font = sdlttf.TTF_OpenFont(RESOURCES.get_path("arial.ttf"), 24)
    ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
    


Answer: I got it. Since I'm using Python 3 the type is incorrect due to the standard
type used for representing strings in Python 3. I solved it by using
str.encode()

