0
$\begingroup$

I want to change the area type of a temporary window i.e (Blender File Browser) to VIEW_3D.
The following code pops up a file browser, but doesn't change the area type.

import bpy
from bpy.types import Operator
from bpy_extras.io_utils import ImportHelper

class Browser(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "wm.browser"
    bl_label = "Open Browser"

    def execute(self, context):
        bpy.ops.wm.proxyfilebrowser('INVOKE_DEFAULT')
        
        bpy.context.window_manager.windows[-1].screen.areas[0].type= "VIEW_3D"
        return {'FINISHED'}


class FileOperator(Operator, ImportHelper):
    bl_idname = "wm.proxyfilebrowser"
    bl_label = "File browser"
    bl_description = "......"


    def execute(self, context):
        display = "filepath= " + self.filepath
        return {"FINISHED"}

def register():
    bpy.utils.register_class(Browser)
    bpy.utils.register_class(FileOperator)


def unregister():
    bpy.utils.unregister_class(Browser)
    bpy.utils.unregister_class(FileOperator)


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.wm.browser()


When I execute the same code in console C.window_manager.windows[-1].screen.areas[0].type = "VIEW_3D", it changes the area of the file viewer to VIEW_3D.

$\endgroup$
2
  • $\begingroup$ Related: blender.stackexchange.com/a/175818/31447 $\endgroup$
    – brockmann
    Dec 20 '20 at 18:49
  • $\begingroup$ @brockmann yes, it is related but, the window of file browser cannot be minimized, That is it always stays at top of blender window. Which is why I want to use Blender File view instead of blender user pref or image viewer $\endgroup$
    – Me BMan
    Dec 20 '20 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.