forked from blender/blender
Mechanical Blender - Fork
https://mechanicalblender.org
|
||
---|---|---|
.gitea | ||
.github | ||
build_files | ||
doc | ||
extern | ||
intern | ||
locale | ||
mblender | ||
release | ||
scripts | ||
source | ||
tests | ||
tools | ||
.clang-format | ||
.clang-tidy | ||
.editorconfig | ||
.git-blame-ignore-revs | ||
.gitignore | ||
AUTHORS | ||
CMakeLists.txt | ||
COPYING | ||
GNUmakefile | ||
README.md | ||
make.bat | ||
pyproject.toml |
README.md
Mechanical Blender
Allows to show an image loaded using bpy.utils.images on UI.
This branch includes the changes on MB-0014-bpy-images branch
The images loaded using bpy.utils.images can be shown on ui using the template_image_ui layout function.
Example Python Script
import os
import bpy
import bpy.utils.images
img = None
class PreviewsExamplePanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Image Example Panel"
bl_idname = "OBJECT_PT_previews"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
row = self.layout.row()
row.template_image_ui(image_value = img['id'], scale= 1)
def register():
global img
# Set path to an existing file
path = os.path.join(os.path.dirname(bpy.app.binary_path), 'image.png')
img = bpy.utils.images.load('my_image', path)
bpy.utils.register_class(PreviewsExamplePanel)
def unregister():
global img
bpy.utils.unregister_class(PreviewsExamplePanel)
bpy.utils.images.release(img['id'])
if __name__ == "__main__":
register()
More info on project's website