Skip to content

bpy_jupyter.operators

bpy_jupyter.operators

All bpy.types.Operators that ship with this extension.

ATTRIBUTE DESCRIPTION
BL_REGISTER

All bpy.types.Operators that should be registered.


bpy_jupyter.operators.copy_kern_info_to_clipboard

Implements CopyJupyURLToClip.

ATTRIBUTE DESCRIPTION
BL_REGISTER

All the Blender classes, implemented by this module, that should be registered.

CopyKernelInfoToClipboard

Bases: Operator

Copy a value to the system clipboard.

ATTRIBUTE DESCRIPTION
bl_idname

Name of this operator type.

TYPE: str

bl_label

Human-oriented label for this operator.

TYPE: str

value_to_copy

Operator property containing the string to copy.

TYPE: StringProperty('')

execute

execute(context: Context) -> set[OperatorReturnItems]

Copy the path to the running connection file, to the system clipboard.

PARAMETER DESCRIPTION
context

The current bpy context. Not used.

TYPE: Context

Source code in bpy_jupyter/operators/copy_kern_info_to_clipboard.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
@typ_ext.override
def execute(
	self, context: bpy.types.Context
) -> set['rna_enums.OperatorReturnItems']:
	"""Copy the path to the running connection file, to the system clipboard.

	Parameters:
		context: The current `bpy` context.
			_Not used._
	"""
	pyperclipfix.copy(str(self.value_to_copy))  # pyright: ignore[reportUnknownArgumentType]

	self.report(
		{'INFO'},
		'Copied Jupyter Kernel Value to Clipboard',
	)
	return {'FINISHED'}

poll classmethod

poll(context: Context) -> bool

Can run while a Jupyter kernel is running.

PARAMETER DESCRIPTION
context

The current bpy context. Not used.

TYPE: Context

Source code in bpy_jupyter/operators/copy_kern_info_to_clipboard.py
53
54
55
56
57
58
59
60
61
62
@typ_ext.override
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
	"""Can run while a Jupyter kernel is running.

	Parameters:
		context: The current `bpy` context.
			_Not used._
	"""
	return jupyter_kernel.is_kernel_running()

bpy_jupyter.operators.start_jupyter_kernel

Implements StartJupyterKernel.

ATTRIBUTE DESCRIPTION
BL_REGISTER

All the Blender classes, implemented by this module, that should be registered.

StartJupyterKernel

Bases: Operator

Start a notebook kernel, and Jupyter Lab server, from within Blender.

ATTRIBUTE DESCRIPTION
bl_idname

Name of this operator type.

TYPE: str

bl_label

Human-oriented label for this operator.

TYPE: str

execute

execute(context: Context) -> set[OperatorReturnItems]

Start an embedded jupyter kernel, as well as an asyncio event loop to handle kernel clients.

PARAMETER DESCRIPTION
context

The current bpy context. Not used.

TYPE: Context

Source code in bpy_jupyter/operators/start_jupyter_kernel.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@typ_ext.override
def execute(
	self, context: bpy.types.Context
) -> set['rna_enums.OperatorReturnItems']:
	"""Start an embedded jupyter kernel, as well as an `asyncio` event loop to handle kernel clients.

	Parameters:
		context: The current `bpy` context.
			_Not used._
	"""
	path_extension_user = Path(
		bpy.utils.extension_path_user(
			EXT_PACKAGE,
			path='',
			create=True,
		)
	).resolve()

	# (Re)Initialize Jupyter Kernel
	jupyter_kernel.init(
		path_connection_file=Path(
			path_extension_user / '.jupyter-connections' / 'connection.json'
		),
	)

	# Start Jupyter Kernel and asyncio Event Loop
	if jupyter_kernel.IPYKERNEL is not None:
		jupyter_kernel.IPYKERNEL.start()
		async_event_loop.start()

	return {'FINISHED'}

poll classmethod

poll(context: Context) -> bool

Can run while a Jupyter kernel is not running.

PARAMETER DESCRIPTION
context

The current bpy context. Not used.

TYPE: Context

Source code in bpy_jupyter/operators/start_jupyter_kernel.py
50
51
52
53
54
55
56
57
58
59
@typ_ext.override
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
	"""Can run while a Jupyter kernel is not running.

	Parameters:
		context: The current `bpy` context.
			_Not used._
	"""
	return not jupyter_kernel.is_kernel_running()

bpy_jupyter.operators.stop_jupyter_kernel

Implements StopJupyterKernel.

ATTRIBUTE DESCRIPTION
BL_REGISTER

All the Blender classes, implemented by this module, that should be registered.

StopJupyterKernel

Bases: Operator

Stop a notebook kernel and Jupyter Lab server running within Blender.

ATTRIBUTE DESCRIPTION
bl_idname

Name of this operator type.

TYPE: str

bl_label

Human-oriented label for this operator.

TYPE: str

execute

execute(context: Context) -> set[OperatorReturnItems]

Start the embedded jupyter kernel, as well as the asyncio event loop managed by this extension.

PARAMETER DESCRIPTION
context

The current bpy context. Not used.

TYPE: Context

Source code in bpy_jupyter/operators/stop_jupyter_kernel.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@typ_ext.override
def execute(
	self, context: bpy.types.Context
) -> set['rna_enums.OperatorReturnItems']:
	"""Start the embedded jupyter kernel, as well as the `asyncio` event loop managed by this extension.

	Parameters:
		context: The current `bpy` context.
			_Not used._
	"""
	# Stop Jupyter Kernel and asyncio Event Loop
	if jupyter_kernel.IPYKERNEL is not None:
		jupyter_kernel.IPYKERNEL.stop()
		async_event_loop.stop()

	return {'FINISHED'}

poll classmethod

poll(context: Context) -> bool

Can run while a Jupyter kernel is running.

PARAMETER DESCRIPTION
context

The current bpy context. Not used.

TYPE: Context

Source code in bpy_jupyter/operators/stop_jupyter_kernel.py
49
50
51
52
53
54
55
56
57
58
@typ_ext.override
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
	"""Can run while a Jupyter kernel is running.

	Parameters:
		context: The current `bpy` context.
			_Not used._
	"""
	return jupyter_kernel.is_kernel_running()