1
1
This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/scripts/startup/bl_operators/spreadsheet.py
Campbell Barton c4c1cc7cd3 Cleanup: double quotes for non-enum strings
Also use back-ticks for code-references in comments.
2023-04-18 10:51:32 +10:00

45 lines
1008 B
Python

# SPDX-License-Identifier: GPL-2.0-or-later
from __future__ import annotations
from bpy.types import Operator
class SPREADSHEET_OT_toggle_pin(Operator):
"""Turn on or off pinning"""
bl_idname = "spreadsheet.toggle_pin"
bl_label = "Toggle Pin"
bl_options = {'REGISTER'}
@classmethod
def poll(cls, context):
space = context.space_data
return space and space.type == 'SPREADSHEET'
def execute(self, context):
space = context.space_data
if space.is_pinned:
self.unpin(context)
else:
self.pin(context)
return {'FINISHED'}
def pin(self, context):
space = context.space_data
space.is_pinned = True
def unpin(self, context):
space = context.space_data
space.is_pinned = False
classes = (
SPREADSHEET_OT_toggle_pin,
)
if __name__ == "__main__": # Only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)