Create a folder dialog box for an addon (2.91) I'm trying to add a folder dialog box in the add-on I'm working on.
I managed to add a button that opens a folder dialog and setup the path, but I'd like to be able to see that path rather than just printing it in the console.
Something like that :

I'm currently using an operator and I found out that I need to use a Property, here's what I tried :
class project_path(bpy.types.PropertyGroup):
path: bpy.props.StringProperty(subtype=&quot;DIR_PATH&quot;)

and then tried to call it in my Panel with :
class PT_Panel(Panel):
    bl_space_type = &quot;VIEW_3D&quot;
    bl_region_type =&quot;UI&quot;
    bl_label = &quot;Operations&quot;
    bl_category = &quot;Tools&quot;

    def draw(self, context):

        layout = self.layout

        sce = context.scene

        box = layout.box()
        box.label( text = &quot;Project Path&quot;)

        row = box.row()
        row.prop(sce.project_path,&quot;path&quot;,text='Project Path')

But then I got that error :
AttributeError: 'Scene' object has no attribute 'project_path'

Can't find any help on that, I guess I'm not using the correct attribute, but I've tried a bunch of different things without success, am I not supposed to use the class as an attribute ?
I found this question that is relevant, but it's also not explaining where the attribute is taken from.
This is how you get it to work
Import :

from bpy.props import PointerProperty


In your PT_Panel class:

ProjPath = context.scene.proj_path
row.prop(ProjPath, &quot;path&quot;, text='Project Path')


While registering:

classes = [project_path, PT_Panel]

def register():

    for cls in classes :
        bpy.utils.register_class(cls)
        bpy.types.Scene.proj_path= PointerProperty(type= project_path)


def unregister():

    for cls in classes :
        bpy.utils.unregister_class(cls)
        del bpy.types.Scene.proj_path


if __name__ == &quot;__main__&quot;:
    register()


If you want to save it permanently then use AddonPrefrences
And try to improve your naming skills :


Darkfall - https://www.youtube.com/watch?v=i12oOBI3E28
Red-K Production- https://www.youtube.com/watch?v=V1gU50MKulw