How to use a non-absolute path in pygame for tmx?

I created a small map and was able to open it in pygame, I had to rename the names and paths of the tmx and tsx files, everything worked out for me, but I tried to use a non-absolute path, that is, so that it starts from the working directory, I understand that it is “. …” in tsx files. But nothing worked for me, as soon as I did not change the path
my path looks like this:

main.py
background.py
map →
field.tmx
Forest.tsx
gentle forest (48x48 resize) v01.png
Tree1.png
Tree1.tsx

from pathlib import Path
from pytmx.util_pygame import load_pygame

class Background:
    def __init__(self, filename, x=0, y=0):
        self.map = Path('map', filename)
        self.x = x
        self.y = y

    def draw(self, camera, screen):
        map_data = load_pygame(self.map)
        for layer in map_data:
            for tile in layer.tiles():
                x_pixel = tile[0] * 48 + self.x
                y_pixel = tile[1] * 48 + self.y
                screen.blit(tile[2], (-camera.rect[0] + x_pixel, -camera.rect[1] + y_pixel))



How can I correctly specify the path in the files and possibly in the background.py file so that everything works correctly?

Do your map files open correctly in Tiled after you made your changes? That’s a good way to check that the file references are correct, as PyTMX will follow them the same way as Tiled does - your initial load_pygame needs a path relative to the present working directory, but any references within the files are calculated relative to the referencing file.

Have you printed out self.map as an absolute path to make sure it’s pointing exactly where you expect?

Oh, I almost exploded while I was delving into my convolutions, it turns out everything worked fine just my last way, the fact is that I had layers for objects, I drew walls from wood like that and because of this I had an error, and so everything worked, then I ran into the problem that a large map 250x250 tiles were not displayed, I made it only in the middle, I painted it completely all over, but I could not see a single tile, maybe it was some kind of bug, or something else, as soon as I made 150x150 I immediately saw my map in the game