Blender V4.3
bpy_utils_previews.cc File Reference
#include <Python.h>
#include <structmember.h>
#include "BLI_utildefines.h"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "bpy_rna.hh"
#include "bpy_utils_previews.hh"
#include "../generic/py_capi_utils.hh"
#include "MEM_guardedalloc.h"
#include "IMB_thumbs.hh"
#include "BKE_preview_image.hh"

Go to the source code of this file.

Macros

#define STR_SOURCE_TYPES   "'IMAGE', 'MOVIE', 'BLEND', 'FONT'"
 

Functions

 PyDoc_STRVAR (bpy_utils_previews_new_doc, ".. method:: new(name)\n" "\n" " Generate a new empty preview.\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: str\n" " :return: The Preview matching given name, or a new empty one.\n" " :rtype: :class:`bpy.types.ImagePreview`\n" " :raises KeyError: if ``name`` already exists.")
 
static PyObject * bpy_utils_previews_new (PyObject *, PyObject *args)
 
 PyDoc_STRVAR (bpy_utils_previews_load_doc, ".. method:: load(name, filepath, filetype, force_reload=False)\n" "\n" " Generate a new preview from given file path.\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: str\n" " :arg filepath: The file path to generate the preview from.\n" " :type filepath: str | bytes\n" " :arg filetype: The type of file, needed to generate the preview in [" STR_SOURCE_TYPES "].\n" " :type filetype: str\n" " :arg force_reload: If True, force running thumbnail manager even if preview already " "exists in cache.\n" " :type force_reload: bool\n" " :return: The Preview matching given name, or a new empty one.\n" " :rtype: :class:`bpy.types.ImagePreview`\n" " :raises KeyError: if ``name`` already exists.")
 
static PyObject * bpy_utils_previews_load (PyObject *, PyObject *args)
 
 PyDoc_STRVAR (bpy_utils_previews_release_doc, ".. method:: release(name)\n" "\n" " Release (free) a previously created preview.\n" "\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: str\n")
 
static PyObject * bpy_utils_previews_release (PyObject *, PyObject *args)
 
 PyDoc_STRVAR (bpy_utils_previews_doc, "This object contains basic static methods to handle cached (non-ID) previews in Blender\n" "(low-level API, not exposed to final users).")
 
PyObject * BPY_utils_previews_module ()
 

Variables

static PyMethodDef bpy_utils_previews_methods []
 
static PyModuleDef bpy_utils_previews_module
 

Detailed Description

This file defines a singleton py object accessed via 'bpy.utils.previews', which exposes low-level API for custom previews/icons. It is replaced in final API by an higher-level python wrapper, that handles previews by addon, and automatically release them on deletion.

Definition in file bpy_utils_previews.cc.

Macro Definition Documentation

◆ STR_SOURCE_TYPES

#define STR_SOURCE_TYPES   "'IMAGE', 'MOVIE', 'BLEND', 'FONT'"

Definition at line 33 of file bpy_utils_previews.cc.

Function Documentation

◆ bpy_utils_previews_load()

◆ BPY_utils_previews_module()

PyObject * BPY_utils_previews_module ( )

Definition at line 182 of file bpy_utils_previews.cc.

References bpy_utils_previews_module.

Referenced by BPy_init_modules().

◆ bpy_utils_previews_new()

static PyObject * bpy_utils_previews_new ( PyObject * ,
PyObject * args )
static

◆ bpy_utils_previews_release()

static PyObject * bpy_utils_previews_release ( PyObject * ,
PyObject * args )
static

Definition at line 141 of file bpy_utils_previews.cc.

References BKE_previewimg_cached_release().

◆ PyDoc_STRVAR() [1/4]

PyDoc_STRVAR ( bpy_utils_previews_doc ,
"This object contains basic static methods to handle cached (non-ID) previews in Blender\n" "(low-level API, not exposed to final users)."  )

◆ PyDoc_STRVAR() [2/4]

PyDoc_STRVAR ( bpy_utils_previews_load_doc ,
".. method:: load(name, filepath, filetype, force_reload=False)\n" "\n" " Generate a new preview from given file path.\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: str\n" " :arg filepath: The file path to generate the preview from.\n" " :type filepath: str | bytes\n" " :arg filetype: The type of file,
needed to generate the preview in .\n" " :type filetype:str\n" " :arg force_reload:If True[" STR_SOURCE_TYPES "],
force running thumbnail manager even if preview already " "exists in cache.\n" " :type force_reload:bool\n" " :return:The Preview matching given name,
or a new empty one.\n" " :rtype::class:`bpy.types.ImagePreview`\n" " :raises KeyError:if ``name`` already exists."  )

◆ PyDoc_STRVAR() [3/4]

PyDoc_STRVAR ( bpy_utils_previews_new_doc ,
".. method:: new(name)\n" "\n" " Generate a new empty preview.\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: str\n" " :return: The Preview matching given name,
or a new empty one.\n" " :rtype::class:`bpy.types.ImagePreview`\n" " :raises KeyError:if ``name`` already exists."  )

◆ PyDoc_STRVAR() [4/4]

PyDoc_STRVAR ( bpy_utils_previews_release_doc ,
".. method:: release(name)\n" "\n" " Release (free) a previously created preview.\n" "\n" "\n" " :arg name: The name (unique id) identifying the preview.\n" " :type name: str\n"  )

Variable Documentation

◆ bpy_utils_previews_methods

PyMethodDef bpy_utils_previews_methods[]
static
Initial value:
= {
{"new", (PyCFunction)bpy_utils_previews_new, METH_VARARGS, bpy_utils_previews_new_doc},
{"load", (PyCFunction)bpy_utils_previews_load, METH_VARARGS, bpy_utils_previews_load_doc},
{"release",
METH_VARARGS,
bpy_utils_previews_release_doc},
{nullptr, nullptr, 0, nullptr},
}
static PyObject * bpy_utils_previews_load(PyObject *, PyObject *args)
static PyObject * bpy_utils_previews_release(PyObject *, PyObject *args)
static PyObject * bpy_utils_previews_new(PyObject *, PyObject *args)

Definition at line 154 of file bpy_utils_previews.cc.

◆ bpy_utils_previews_module

PyModuleDef bpy_utils_previews_module
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"bpy._utils_previews",
bpy_utils_previews_doc,
0,
nullptr,
nullptr,
nullptr,
nullptr,
}
static PyMethodDef bpy_utils_previews_methods[]

Definition at line 170 of file bpy_utils_previews.cc.

Referenced by BPY_utils_previews_module().