Skip to content

Mac + Glumpy + SDL2, sdl2.SDL_CreateWindow title arg TypeError: wrong type #314

Description

@atalkingegg

Hi, I'm trying to get glumpy running under High Sierra (10.13.6), XCode 10.1, macports, yada, yada.
SDL2 2.28.3, glumpy latest git clone version.

Both "window = app.Window()" or "window = app.Window(title='My Glumpy Window')" end up with an error...

...
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/glumpy/app/window/backends/backend_sdl2.py", line 222, in init
self._native_window = sdl2.SDL_CreateWindow(self._title,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ctypes.ArgumentError: argument 1: TypeError: wrong type

I see title=None in the Window class, can't figure out what sets self._title, but replacing self._title with 'Bob' gets the same error, as does None. However, "b'Bob'" works.

The fix: since title is being passed into Windows.init, how about adding...

if title is None:
title_bytes = b""
else:
title_bytes = title.encode('utf-8') if isinstance(title, str) else title

just before the SDL_CreateWindow call, and replace self._title with title_bytes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions