Is there something like Layout.template_fileselector? I'm writing an export script and I want the user to be able to export the currently selected object. The real script is finished but now I want to finish my UI. For this I want to display a fileselector like this:



So here is what I got so far:

class MHMDLExporterObject(Panel):
    """
    This exports the current object
    """

    bl_label = "Export My Stuff"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "object"

    # can I let it write into this property?
    dir = StringProperty(name="Export path", default="C:/tmp/",
                                description="Export which objects?",
                                subtype='DIR_PATH')

    def draw(self, context):
        from .constants import OP_exportMHMUIdent
        layout = self.layout
        col = layout.column()
        from .constants import uvResultIdent
        if hasattr(context.object, '["%s"]' % uvResultIdent):
            uvL = col.prop(context.object, '["%s"]' % uvResultIdent, text="UV Layer")
            uvL.enabled = False
        else: #property doesn't exist
            col.label('To preselect an uv-layer to export') 
            col.label('you have to create a Custom Property')
            col.label('with the name %s.' % uvResultIdent)
        from .constants import OP_uvPromtpIdent
        col.operator(OP_uvPromtpIdent, text='Select the uv-layer to export')
        ## here is wher I want to get display a fileselector that writes the
        ## current value in self.dir (see above)
It's not possible to use a path variable from inside the Panel to achieve this effect. The fact that the used path is either used per object or per scene on the other hand offers a great workaround:

In your __init__.py-file you need the following code:

from bpy.props import StringProperty

def register():
    bpy.utils.register_module(__name__)

    # assigns a propery someName to every object. 
    # If you want one var per scene use bpy.types.Scene
    bpy.types.Object.someName = StringProperty(name="Exported Layer", 
        description="The UVLayer that will get exported",
        subtype='DIR_PATH') # so blender notices that as
                            # a directory path

if __name__ == "__main__":
    register()


Now you can use that variable inside yor panel:

from bpy.types import Panel

class MyExporter(Panel):
    """
    This exports the current object
    """

    bl_label = "Mobster Hunter"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "object"

    def draw(self, context):
        layout = self.layout
        col = layout.column()

        # use either context.object or context.scene and 
        # the same name
        col.prop(context.object, 'someName', text='Export directory')