I now have the file browser, and I've found out how to load the texture into the node but not from the file browser. I have to type the file path in manually, and I had to put it in a different class that was activated with a bool... so, how can I activate the file browser instead?
code
import bpy
import os
from bpy.types import (Menu, PropertyGroup)
from bpy.props import (BoolProperty, FloatProperty, EnumProperty, StringProperty)
from bpy_extras.io_utils import ImportHelper
def update_texture(self, context):
path = self.screen_texture.value
img = bpy.data.images.load(filepath = path)
nt = bpy.data.materials['Screen'].node_tree
n = nt.nodes["screen_texture"].image = img
class IgnitProperties(bpy.types.PropertyGroup):
screen_path = StringProperty(
name="Browse Image:",
description="Loads the texture for the screen",
maxlen= 1024,
subtype='FILE_PATH',
update=update_texture
)
class IdentifierFileSelector(bpy.types.Operator, ImportHelper):
bl_label = "File Browser"
bl_idname = "macbook_controller.identifier_file_selector"
def execute(self, context):
fdir = self.properties.filepath
# Screen Texture
return{'FINISHED'}
class IGLayoutDemoPanel(bpy.types.Panel):
"""Creates a Panel in the scene context of the properties editor"""
bl_label = "MacBook Controller"
bl_idname = "macbook_controller.macbook_controller"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
layout = self.layout
scene = context.scene
# Screen Texture
layout.label(text = "Screen Texture:")
layout.prop(scene.ignit_panel, "screen_path", text="")
.img
, or you could call a function from there and pass it the filepath. $\endgroup$