Skip to content

doc/tutorial/helloworld.rst - __file__ is not defined when setting up RESOURCES #287

@rrpegasus

Description

@rrpegasus

What doesn't work?

  1. Resources is now under examples
  2. NameError: name '__file__' is not defined
    when running
    RESOURCES = sdl2.ext.Resources(__file__,"examples/resources")

How To Reproduce

import sys
import sdl2
import sdl2.ext
RESOURCES = sdl2.ext.Resources(__file__,"examples/resources")

Platform (if relevant):

  • OS: Win11 amd64
  • Python Version: 3.12.10
  • SDL2 Version: 0.9.17
  • Using pysdl2-dll: Yes

Additional context
Fix

RESOURCES = sdl2.ext.Resources(sdl2.__file__,"examples/resources")
RESOURCES.get_path("hello.bmp")
'C:\\Users\\jdoe\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_abc123def456g\\LocalCache\\local-packages\\Python312\\site-packages\\sdl2\\examples\\resources\\hello.bmp'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions