# Open file browser with python

I'm writing a python script wich is going to import custom data in custom file. For now, for choosing the file I've to do this:

But it's not very useful because you have to type the path of file by yourself.

I want to create somthing like this :

How to create quick interface like that. With a file browser button and the path of selected file edit box is linked at the path of file wich you have selected with the little 'file' button.

I'm not asking for a full code. (of course if you have a full code I'll accept it :D) But if you have just an explanation of how to do this and how the 'path of file' button work, it will be very helpfull.

Add a StringProperty to your operator, then set its subtype to either FILE_PATH or DIR_PATH. For example, this bit of code in my addon:

class OHA_QuickLink_Props(bpy.types.PropertyGroup):
root_folder = StringProperty(
name="Root Folder",
description="Only .blend files two levels below this folder will be listed.",
subtype="DIR_PATH",


Blender 2.8x:

class OHA_QuickLink_Props(bpy.types.PropertyGroup):
root_folder : StringProperty(
name="Root Folder",
description="Only .blend files two levels below this folder will be listed.",
subtype="DIR_PATH",