Cleanup: argument wrapping for Python scripts

- Wrap the closing parenthesis onto it's own line
  which makes assignments to the return value
  read better.
- Reduce right-shift with multi-line function calls.
This commit is contained in:
Campbell Barton
2025-01-14 12:46:40 +11:00
parent 6430974868
commit be0c9174aa
45 changed files with 343 additions and 181 deletions

View File

@@ -467,7 +467,8 @@ class ARMATURE_OT_copy_bone_color_to_selected(Operator):
bone_type: EnumProperty(
name="Type",
items=_bone_type_enum)
items=_bone_type_enum,
)
@classmethod
def poll(cls, context):
@@ -528,7 +529,8 @@ class ARMATURE_OT_copy_bone_color_to_selected(Operator):
"Bone colors were synced; "
"for {:d} bones this will not be visible due to pose bone color overrides".format(
num_pose_color_overrides,
))
),
)
return {'FINISHED'}

View File

@@ -95,7 +95,8 @@ class ASSET_OT_open_containing_blend_file(Operator):
# This could become a built-in query, for now this is good enough.
if asset.full_library_path.endswith(".asset.blend"):
cls.poll_message_set(
"Selected asset is contained in a file managed by the asset system, manual edits should be avoided")
"Selected asset is contained in a file managed by the asset system, manual edits should be avoided",
)
return False
return True

View File

@@ -37,7 +37,8 @@ class SelectionSet(PropertyGroup):
is_selected: BoolProperty(
name="Include this selection set when copying to the clipboard. "
"If none are specified, all sets will be copied.",
override={'LIBRARY_OVERRIDABLE'})
override={'LIBRARY_OVERRIDABLE'},
)
# Operators ##############################################################
@@ -46,9 +47,11 @@ class _PoseModeOnlyMixin:
"""Operator only available for objects of type armature in pose mode."""
@classmethod
def poll(cls, context):
return (context.object and
context.object.type == 'ARMATURE' and
context.mode == 'POSE')
return (
context.object and
context.object.type == 'ARMATURE' and
context.mode == 'POSE'
)
class _NeedSelSetMixin(_PoseModeOnlyMixin):
@@ -178,8 +181,7 @@ class POSE_OT_selection_set_assign(_PoseModeOnlyMixin, Operator):
arm = context.object
if not (arm.active_selection_set < len(arm.selection_sets)):
bpy.ops.wm.call_menu("INVOKE_DEFAULT",
name="POSE_MT_selection_set_create")
bpy.ops.wm.call_menu("INVOKE_DEFAULT", name="POSE_MT_selection_set_create")
else:
bpy.ops.pose.selection_set_assign('EXEC_DEFAULT')

View File

@@ -27,12 +27,20 @@ def CLIP_set_viewport_background(context, clip, clip_user):
def check_camera_has_distortion(tracking_camera):
if tracking_camera.distortion_model == 'POLYNOMIAL':
return not all(k == 0 for k in (tracking_camera.k1,
tracking_camera.k2,
tracking_camera.k3))
return not all(
k == 0 for k in (
tracking_camera.k1,
tracking_camera.k2,
tracking_camera.k3,
)
)
elif tracking_camera.distortion_model == 'DIVISION':
return not all(k == 0 for k in (tracking_camera.division_k1,
tracking_camera.division_k2))
return not all(
k == 0 for k in (
tracking_camera.division_k1,
tracking_camera.division_k2,
)
)
return False
def set_background(cam, clip, user):
@@ -926,12 +934,14 @@ class CLIP_OT_setup_tracking_scene(Operator):
def _createSampleObject(self, collection):
vertices = self._getPlaneVertices(1.0, -1.0) + \
self._getPlaneVertices(1.0, 1.0)
faces = (0, 1, 2, 3,
4, 7, 6, 5,
0, 4, 5, 1,
1, 5, 6, 2,
2, 6, 7, 3,
3, 7, 4, 0)
faces = (
0, 1, 2, 3,
4, 7, 6, 5,
0, 4, 5, 1,
1, 5, 6, 2,
2, 6, 7, 3,
3, 7, 4, 0,
)
return self._createMesh(collection, "Cube", vertices, faces)

View File

@@ -179,8 +179,10 @@ class NODE_OT_connect_to_output(Operator, NodeEditorBase):
if mat.node_tree == bpy.context.space_data.node_tree or not hasattr(mat.node_tree, "nodes"):
continue
# Get viewer node.
output_node = get_group_output_node(mat.node_tree,
output_node_idname=self.shader_output_idname)
output_node = get_group_output_node(
mat.node_tree,
output_node_idname=self.shader_output_idname,
)
if output_node is not None:
self.search_connected_viewer_sockets(output_node, self.other_viewer_sockets_users)
return socket in self.other_viewer_sockets_users
@@ -216,7 +218,8 @@ class NODE_OT_connect_to_output(Operator, NodeEditorBase):
viewer_socket = self.ensure_viewer_socket(
tree, socket_type,
connect_socket=node.outputs[active_node_socket_id]
if path_index == 0 else None)
if path_index == 0 else None,
)
if viewer_socket in self.delete_sockets:
self.delete_sockets.remove(viewer_socket)
@@ -301,15 +304,18 @@ class NODE_OT_connect_to_output(Operator, NodeEditorBase):
socket_type = find_base_socket_type(node_output)
if output_node_socket_index is None:
output_node_socket_index = self.ensure_viewer_socket(
base_node_tree, socket_type, connect_socket=None)
base_node_tree, socket_type, connect_socket=None,
)
# For shader node trees, we connect to a material output.
elif space.tree_type == 'ShaderNodeTree':
self.init_shader_variables(space, space.shader_type)
# Get or create material_output node.
output_node = get_group_output_node(base_node_tree,
output_node_idname=self.shader_output_idname)
output_node = get_group_output_node(
base_node_tree,
output_node_idname=self.shader_output_idname,
)
if not output_node:
output_node = base_node_tree.nodes.new(self.shader_output_idname)
output_node.location = get_output_location(base_node_tree)

View File

@@ -14,9 +14,11 @@ from bpy.app.translations import contexts as i18n_contexts
def _lang_module_get(sc):
return __import__("console_" + sc.language,
# for python 3.3, maybe a bug???
level=0)
return __import__(
"console_" + sc.language,
# for python 3.3, maybe a bug???
level=0,
)
class ConsoleExec(Operator):

View File

@@ -195,7 +195,8 @@ class SCENE_OT_freestyle_module_open(Operator):
make_internal: BoolProperty(
name="Make internal",
description="Make module file internal after loading",
default=True)
default=True,
)
@classmethod
def poll(cls, context):

View File

@@ -627,8 +627,9 @@ def get_shadeless_node(dest_node_tree):
# -----------------------------------------------------------------------------
# Operator
class IMAGE_OT_import_as_mesh_planes(AddObjectHelper, ImportHelper, MaterialProperties_MixIn,
TextureProperties_MixIn, Operator):
class IMAGE_OT_import_as_mesh_planes(
AddObjectHelper, ImportHelper, MaterialProperties_MixIn, TextureProperties_MixIn, Operator,
):
"""Create mesh plane(s) from image files with the appropriate aspect ratio"""
bl_idname = "image.import_as_mesh_planes"

View File

@@ -25,8 +25,10 @@ def node_editor_poll(cls, context):
def node_space_type_poll(cls, context, types):
if context.space_data.tree_type not in types:
tree_types_str = ", ".join(t.split('NodeTree')[0].lower() for t in sorted(types))
poll_message = tip_("Current node tree type not supported.\n"
"Should be one of {:s}.").format(tree_types_str)
poll_message = tip_(
"Current node tree type not supported.\n"
"Should be one of {:s}."
).format(tree_types_str)
cls.poll_message_set(poll_message)
return False
return True

View File

@@ -432,14 +432,18 @@ class ShapeTransfer(Operator):
n1loc_to = v1_to + target_normals[i1] * edlen_to
n2loc_to = v2_to + target_normals[i2] * edlen_to
pt = barycentric_transform(orig_shape_coords[i1],
v2, v1, n1loc,
v2_to, v1_to, n1loc_to)
pt = barycentric_transform(
orig_shape_coords[i1],
v2, v1, n1loc,
v2_to, v1_to, n1loc_to,
)
median_coords[i1].append(pt)
pt = barycentric_transform(orig_shape_coords[i2],
v1, v2, n2loc,
v1_to, v2_to, n2loc_to)
pt = barycentric_transform(
orig_shape_coords[i2],
v1, v2, n2loc,
v1_to, v2_to, n2loc_to,
)
median_coords[i2].append(pt)
# apply the offsets to the new shape

View File

@@ -756,7 +756,8 @@ class RemovePresetKeyconfig(AddPresetBase, Operator):
return {'CANCELLED'}
return context.window_manager.invoke_confirm(
self, event, title="Remove Keymap Configuration", confirm_text="Delete")
self, event, title="Remove Keymap Configuration", confirm_text="Delete",
)
class AddPresetOperator(AddPresetBase, Operator):

View File

@@ -56,7 +56,8 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
'INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={
"release_confirm": False,
})
},
)
elif select_mode[1] and totedge >= 1:
bpy.ops.mesh.extrude_edges_move(
'INVOKE_REGION_WIN',

View File

@@ -233,11 +233,14 @@ def operator_value_is_undo(value):
return False
# return True if its a non window ID type
return (isinstance(id_data, bpy.types.ID) and
(not isinstance(id_data, (bpy.types.WindowManager,
bpy.types.Screen,
bpy.types.Brush,
))))
return (
isinstance(id_data, bpy.types.ID) and
(not isinstance(id_data, (
bpy.types.WindowManager,
bpy.types.Screen,
bpy.types.Brush,
)))
)
def operator_path_is_undo(context, data_path):
@@ -842,10 +845,12 @@ doc_id = StringProperty(
)
data_path_iter = StringProperty(
description="The data path relative to the context, must point to an iterable")
description="The data path relative to the context, must point to an iterable",
)
data_path_item = StringProperty(
description="The data path from each iterable to the value (int or float)")
description="The data path from each iterable to the value (int or float)",
)
class WM_OT_context_collection_boolean_set(Operator):
@@ -1384,8 +1389,9 @@ rna_custom_property_type_items = (
('PYTHON', "Python", "Edit a Python value directly, for unsupported property types"),
)
rna_custom_property_subtype_none_item = ('NONE', n_(
"Plain Data", i18n_contexts.unit), n_("Data values without special behavior"))
rna_custom_property_subtype_none_item = (
'NONE', n_("Plain Data", i18n_contexts.unit), n_("Data values without special behavior")
)
rna_custom_property_subtype_number_items = (
rna_custom_property_subtype_none_item,
@@ -1413,8 +1419,10 @@ rna_custom_property_subtype_vector_items = (
('XYZ', n_("XYZ", i18n_contexts.unit), ""),
)
rna_id_type_items = tuple((item.identifier, item.name, item.description, item.icon, item.value)
for item in bpy.types.ID.bl_rna.properties["id_type"].enum_items)
rna_id_type_items = tuple(
(item.identifier, item.name, item.description, item.icon, item.value)
for item in bpy.types.ID.bl_rna.properties["id_type"].enum_items
)
class WM_OT_properties_edit(Operator):
@@ -3591,8 +3599,12 @@ class WM_MT_region_toggle_pie(Menu):
text = enum_items[region_type].name
attr = cls._region_info[region_type]
value = getattr(space_data, attr)
props = pie.operator("wm.context_toggle", text=text, text_ctxt=i18n_contexts.default,
icon='CHECKBOX_HLT' if value else 'CHECKBOX_DEHLT')
props = pie.operator(
"wm.context_toggle",
text=text,
text_ctxt=i18n_contexts.default,
icon='CHECKBOX_HLT' if value else 'CHECKBOX_DEHLT',
)
props.data_path = "space_data." + attr
def draw(self, context):

View File

@@ -68,7 +68,8 @@ class WORLD_OT_convert_volume_to_mesh(bpy.types.Operator):
volume_output.inputs["Volume"],
world_output,
world_output.inputs["Volume"],
links_to_add)
links_to_add,
)
self._sync_links(volume_tree, links_to_add)
# Add transparent volume for other render engines

View File

@@ -80,7 +80,10 @@ def add_repeat_zone(layout, label):
def add_foreach_geometry_element_zone(layout, label):
props = layout.operator(
"node.add_foreach_geometry_element_zone", text=label, text_ctxt=i18n_contexts.default)
"node.add_foreach_geometry_element_zone",
text=label,
text_ctxt=i18n_contexts.default,
)
props.use_transform = True
return props

View File

@@ -88,8 +88,10 @@ class ConstraintButtonsPanel:
case 'ARMATURE':
col.prop_search(con, "space_subtarget", con.space_object.data, "bones", text="Bone")
case 'MESH', 'LATTICE':
col.prop_search(con, "space_subtarget", con.space_object,
"vertex_groups", text="Vertex Group")
col.prop_search(
con, "space_subtarget", con.space_object,
"vertex_groups", text="Vertex Group",
)
@staticmethod
def target_template(layout, con, subtargets=True):
@@ -669,10 +671,17 @@ class ConstraintButtonsPanel:
if space_object := con.space_object:
match space_object.type:
case 'ARMATURE':
col.prop_search(con, "space_subtarget", con.space_object.data, "bones", text="Bone")
col.prop_search(
con, "space_subtarget",
con.space_object.data, "bones",
text="Bone",
)
case 'MESH', 'LATTICE':
col.prop_search(con, "space_subtarget", con.space_object,
"vertex_groups", text="Vertex Group")
col.prop_search(
con, "space_subtarget",
con.space_object, "vertex_groups",
text="Vertex Group",
)
layout.prop(con, "project_limit", text="Distance")
layout.prop(con, "use_project_opposite")

View File

@@ -391,8 +391,7 @@ class POSE_MT_selection_set_create(Menu):
def draw(self, _context):
layout = self.layout
layout.operator("pose.selection_set_add_and_assign",
text="New Selection Set")
layout.operator("pose.selection_set_add_and_assign", text="New Selection Set")
class POSE_MT_selection_sets_select(Menu):

View File

@@ -268,7 +268,8 @@ class DATA_PT_camera_dof(CameraButtonsPanel, Panel):
row.operator(
"ui.eyedropper_depth",
icon='EYEDROPPER',
text="").prop_data_path = "scene.camera.data.dof.focus_distance"
text="",
).prop_data_path = "scene.camera.data.dof.focus_distance"
class DATA_PT_camera_dof_aperture(CameraButtonsPanel, Panel):

View File

@@ -64,7 +64,8 @@ class DATA_PT_curves_surface(DataButtonsPanel, Panel):
ob.data.surface.data,
"uv_layers",
text="UV Map",
icon='GROUP_UVS')
icon='GROUP_UVS',
)
else:
row = layout.row()
row.prop(ob.data, "surface_uv_map", text="UV Map")
@@ -109,7 +110,8 @@ class CURVES_UL_attributes(UIList):
# Filtering by name
if self.filter_name:
flags = bpy.types.UI_UL_list.filter_items_by_name(
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert)
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert,
)
if not flags:
flags = [self.bitflag_filter_item] * len(attributes)

View File

@@ -431,7 +431,8 @@ class GREASE_PENCIL_UL_attributes(UIList):
# Filtering by name
if self.filter_name:
flags = bpy.types.UI_UL_list.filter_items_by_name(
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert)
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert,
)
if not flags:
flags = [self.bitflag_filter_item] * len(attributes)

View File

@@ -510,7 +510,8 @@ class MESH_UL_attributes(UIList):
# Filtering by name
if self.filter_name:
flags = bpy.types.UI_UL_list.filter_items_by_name(
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert)
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert,
)
if not flags:
flags = [self.bitflag_filter_item] * len(attributes)
@@ -605,8 +606,7 @@ def draw_attribute_warnings(context, layout):
if not colliding_names:
return
layout.label(text=rpt_("Name collisions: ") + ", ".join(set(colliding_names)),
icon='ERROR', translate=False)
layout.label(text=rpt_("Name collisions: ") + ", ".join(set(colliding_names)), icon='ERROR', translate=False)
class ColorAttributesListBase():
@@ -625,7 +625,8 @@ class ColorAttributesListBase():
# Filtering by name
if self.filter_name:
flags = bpy.types.UI_UL_list.filter_items_by_name(
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert)
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert,
)
if not flags:
flags = [self.bitflag_filter_item] * len(attributes)

View File

@@ -67,8 +67,11 @@ class OBJECT_MT_modifier_add(ModifierAddMenu, Menu):
if layout.operator_context == 'EXEC_REGION_WIN':
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("WM_OT_search_single_menu", text="Search...",
icon='VIEWZOOM').menu_idname = "OBJECT_MT_modifier_add"
layout.operator(
"WM_OT_search_single_menu",
text="Search...",
icon='VIEWZOOM',
).menu_idname = "OBJECT_MT_modifier_add"
layout.separator()
layout.operator_context = 'INVOKE_REGION_WIN'

View File

@@ -80,7 +80,8 @@ class POINTCLOUD_UL_attributes(UIList):
# Filtering by name
if self.filter_name:
flags = bpy.types.UI_UL_list.filter_items_by_name(
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert)
self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert,
)
if not flags:
flags = [self.bitflag_filter_item] * len(attributes)

View File

@@ -458,7 +458,8 @@ class GreasePencilMaterialsPanel:
sub.operator(
"grease_pencil.material_isolate",
icon='RESTRICT_VIEW_ON',
text="").affect_visibility = True
text="",
).affect_visibility = True
sub.operator("grease_pencil.material_isolate", icon='LOCKED', text="").affect_visibility = False
if show_full_ui:

View File

@@ -211,11 +211,15 @@ class MASK_PT_point:
if parent.parent in tracking.objects:
ob = tracking.objects[parent.parent]
col.prop_search(parent, "sub_parent", ob,
tracks_list, icon='ANIM_DATA', text="Track", text_ctxt=i18n_contexts.id_movieclip)
col.prop_search(
parent, "sub_parent", ob,
tracks_list, icon='ANIM_DATA', text="Track", text_ctxt=i18n_contexts.id_movieclip,
)
else:
col.prop_search(parent, "sub_parent", tracking,
tracks_list, icon='ANIM_DATA', text="Track", text_ctxt=i18n_contexts.id_movieclip)
col.prop_search(
parent, "sub_parent", tracking,
tracks_list, icon='ANIM_DATA', text="Track", text_ctxt=i18n_contexts.id_movieclip,
)
class MASK_PT_display:

View File

@@ -32,7 +32,8 @@ class GPENCIL_MT_material_context_menu(Menu):
layout.operator(
"grease_pencil.material_copy_to_object",
text="Copy Material to Selected").only_active = True
text="Copy Material to Selected",
).only_active = True
layout.operator(
"grease_pencil.material_copy_to_object",
text="Copy All Materials to Selected",

View File

@@ -437,7 +437,8 @@ def has_geometry_visibility(ob):
'VOLUME',
'POINTCLOUD',
'CURVES',
}) or (ob.instance_type == 'COLLECTION' and ob.instance_collection))
}) or (ob.instance_type == 'COLLECTION' and ob.instance_collection)
)
class OBJECT_PT_shading(ObjectButtonsPanel, Panel):
@@ -487,7 +488,8 @@ class OBJECT_PT_light_linking(ObjectButtonsPanel, Panel):
col.template_ID(
light_linking,
"receiver_collection",
new="object.light_linking_receiver_collection_new")
new="object.light_linking_receiver_collection_new",
)
if not light_linking.receiver_collection:
return
@@ -532,7 +534,8 @@ class OBJECT_PT_shadow_linking(ObjectButtonsPanel, Panel):
col.template_ID(
light_linking,
"blocker_collection",
new="object.light_linking_blocker_collection_new")
new="object.light_linking_blocker_collection_new",
)
if not light_linking.blocker_collection:
return

View File

@@ -184,8 +184,10 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
if ob:
row = layout.row()
row.template_list("PARTICLE_UL_particle_systems", "particle_systems", ob, "particle_systems",
ob.particle_systems, "active_index", rows=3)
row.template_list(
"PARTICLE_UL_particle_systems", "particle_systems", ob, "particle_systems",
ob.particle_systems, "active_index", rows=3,
)
col = row.column(align=True)
col.operator("object.particle_system_add", icon='ADD', text="")
@@ -1132,7 +1134,7 @@ class PARTICLE_PT_physics_fluid_interaction(ParticleButtonsPanel, Panel):
row = layout.row()
row.template_list(
"UI_UL_list", "particle_targets", psys, "targets",
psys, "active_particle_target_index", rows=4,
psys, "active_particle_target_index", rows=4,
)
col = row.column()

View File

@@ -1021,11 +1021,12 @@ class PHYSICS_PT_particles(PhysicButtonsPanel, Panel):
split.enabled = (
note_flag and
ob.mode == 'OBJECT' and
domain.has_cache_baked_data and
(domain.use_spray_particles or
domain.use_bubble_particles or
domain.use_foam_particles or
domain.use_tracer_particles)
domain.has_cache_baked_data and (
domain.use_spray_particles or
domain.use_bubble_particles or
domain.use_foam_particles or
domain.use_tracer_particles
)
)
bake_incomplete = (domain.cache_frame_pause_particles < domain.cache_frame_end)

View File

@@ -790,7 +790,8 @@ class RENDER_PT_eevee_performance_compositor(RenderButtonsPanel, CompositorPerfo
class RENDER_PT_eevee_performance_compositor_denoise_settings(
RenderButtonsPanel, CompositorDenoisePerformanceButtonsPanel, Panel):
RenderButtonsPanel, CompositorDenoisePerformanceButtonsPanel, Panel,
):
bl_options = {'DEFAULT_CLOSED'}
bl_parent_id = "RENDER_PT_eevee_performance_compositor"
COMPAT_ENGINES = {

View File

@@ -138,7 +138,8 @@ class WORKSPACE_UL_addons_items(UIList):
# Filtering by category and name
if self.filter_name:
flags = self._filter_addons_by_category_name(
self.filter_name, self.bitflag_filter_item, addons, reverse=self.use_filter_invert)
self.filter_name, self.bitflag_filter_item, addons, reverse=self.use_filter_invert,
)
if not flags:
flags = [self.bitflag_filter_item] * len(addons)
# Filer addons without registered modules
@@ -181,7 +182,9 @@ classes = (
bpy.types.WorkSpace.active_addon = bpy.props.IntProperty(
name="Active Add-on", description="Active Add-on in the Workspace Add-ons filter")
name="Active Add-on",
description="Active Add-on in the Workspace Add-ons filter",
)
if __name__ == "__main__": # only for live edit.

View File

@@ -202,9 +202,11 @@ class CLIP_HT_header(Header):
row = layout.row(align=True)
row.prop(dopesheet, "sort_method", text="")
row.prop(dopesheet, "use_invert_sort",
text="", toggle=True,
icon='SORT_DESC' if dopesheet.use_invert_sort else 'SORT_ASC')
row.prop(
dopesheet, "use_invert_sort",
text="", toggle=True,
icon='SORT_DESC' if dopesheet.use_invert_sort else 'SORT_ASC',
)
def _draw_masking(self, context):
layout = self.layout
@@ -557,8 +559,10 @@ class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel):
col.prop(settings, "use_keyframe_selection", text="Keyframe")
col = layout.column(align=True)
col.active = (not settings.use_tripod_solver and
not settings.use_keyframe_selection)
col.active = (
not settings.use_tripod_solver and
not settings.use_keyframe_selection
)
col.prop(tracking_object, "keyframe_a")
col.prop(tracking_object, "keyframe_b")
@@ -1041,8 +1045,7 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel):
else:
row.label(text="Tracks for Location")
row = box.row()
row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks",
stab, "active_track_index", rows=2)
row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks", stab, "active_track_index", rows=2)
sub = row.column(align=True)
@@ -1056,9 +1059,11 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel):
if stab.use_stabilize_rotation:
box.label(text="Tracks for Rotation/Scale")
row = box.row()
row.template_list("UI_UL_list", "stabilization_rotation_tracks",
stab, "rotation_tracks",
stab, "active_rotation_track_index", rows=2)
row.template_list(
"UI_UL_list", "stabilization_rotation_tracks",
stab, "rotation_tracks",
stab, "active_rotation_track_index", rows=2,
)
sub = row.column(align=True)

View File

@@ -942,7 +942,8 @@ class DOPESHEET_PT_grease_pencil_layer_masks(GreasePencilLayersDopeSheetPanel, G
class DOPESHEET_PT_grease_pencil_layer_transform(
GreasePencilLayersDopeSheetPanel,
GreasePencil_LayerTransformPanel,
Panel):
Panel,
):
bl_label = "Transform"
bl_parent_id = "DOPESHEET_PT_grease_pencil_mode"
bl_options = {'DEFAULT_CLOSED'}
@@ -951,7 +952,8 @@ class DOPESHEET_PT_grease_pencil_layer_transform(
class DOPESHEET_PT_grease_pencil_layer_relations(
GreasePencilLayersDopeSheetPanel,
GreasePencil_LayerRelationsPanel,
Panel):
Panel,
):
bl_label = "Relations"
bl_parent_id = "DOPESHEET_PT_grease_pencil_mode"
bl_options = {'DEFAULT_CLOSED'}
@@ -960,7 +962,8 @@ class DOPESHEET_PT_grease_pencil_layer_relations(
class DOPESHEET_PT_grease_pencil_layer_adjustments(
GreasePencilLayersDopeSheetPanel,
GreasePencil_LayerAdjustmentsPanel,
Panel):
Panel,
):
bl_label = "Adjustments"
bl_parent_id = "DOPESHEET_PT_grease_pencil_mode"
bl_options = {'DEFAULT_CLOSED'}
@@ -969,7 +972,8 @@ class DOPESHEET_PT_grease_pencil_layer_adjustments(
class DOPESHEET_PT_grease_pencil_layer_display(
GreasePencilLayersDopeSheetPanel,
GreasePencil_LayerDisplayPanel,
Panel):
Panel,
):
bl_label = "Display"
bl_parent_id = "DOPESHEET_PT_grease_pencil_mode"
bl_options = {'DEFAULT_CLOSED'}

View File

@@ -241,8 +241,10 @@ class FILEBROWSER_PT_bookmarks_volumes(Panel):
if space.system_folders:
row = layout.row()
row.template_list("FILEBROWSER_UL_dir", "system_folders", space, "system_folders",
space, "system_folders_active", item_dyntip_propname="path", rows=1, maxrows=10)
row.template_list(
"FILEBROWSER_UL_dir", "system_folders", space, "system_folders",
space, "system_folders_active", item_dyntip_propname="path", rows=1, maxrows=10,
)
class FILEBROWSER_PT_bookmarks_system(Panel):
@@ -265,8 +267,10 @@ class FILEBROWSER_PT_bookmarks_system(Panel):
if space.system_bookmarks:
row = layout.row()
row.template_list("FILEBROWSER_UL_dir", "system_bookmarks", space, "system_bookmarks",
space, "system_bookmarks_active", item_dyntip_propname="path", rows=1, maxrows=10)
row.template_list(
"FILEBROWSER_UL_dir", "system_bookmarks", space, "system_bookmarks",
space, "system_bookmarks_active", item_dyntip_propname="path", rows=1, maxrows=10,
)
class FILEBROWSER_MT_bookmarks_context_menu(Menu):
@@ -301,9 +305,11 @@ class FILEBROWSER_PT_bookmarks_favorites(FileBrowserPanel, Panel):
if space.bookmarks:
row = layout.row()
num_rows = len(space.bookmarks)
row.template_list("FILEBROWSER_UL_dir", "bookmarks", space, "bookmarks",
space, "bookmarks_active", item_dyntip_propname="path",
rows=(2 if num_rows < 2 else 4), maxrows=10)
row.template_list(
"FILEBROWSER_UL_dir", "bookmarks", space, "bookmarks",
space, "bookmarks_active", item_dyntip_propname="path",
rows=(2 if num_rows < 2 else 4), maxrows=10,
)
col = row.column(align=True)
col.operator("file.bookmark_add", icon='ADD', text="")
@@ -347,8 +353,10 @@ class FILEBROWSER_PT_bookmarks_recents(Panel):
if space.recent_folders:
row = layout.row()
row.template_list("FILEBROWSER_UL_dir", "recent_folders", space, "recent_folders",
space, "recent_folders_active", item_dyntip_propname="path", rows=1, maxrows=10)
row.template_list(
"FILEBROWSER_UL_dir", "recent_folders", space, "recent_folders",
space, "recent_folders_active", item_dyntip_propname="path", rows=1, maxrows=10,
)
col = row.column(align=True)
col.menu("FILEBROWSER_MT_bookmarks_recents_specials_menu", icon='DOWNARROW_HLT', text="")

View File

@@ -1049,7 +1049,8 @@ class IMAGE_PT_snapping(Panel):
"use_snap_translate",
text="Move",
text_ctxt=i18n_contexts.operator_default,
toggle=True)
toggle=True,
)
row.prop(tool_settings, "use_snap_rotate", text="Rotate", text_ctxt=i18n_contexts.operator_default, toggle=True)
row.prop(tool_settings, "use_snap_scale", text="Scale", text_ctxt=i18n_contexts.operator_default, toggle=True)
col.label(text="Rotation Increment")

View File

@@ -366,7 +366,8 @@ class OUTLINER_MT_liboverride(Menu):
layout.operator_menu_enum(
"outliner.liboverride_operation",
"selection_set",
text="Reset").type = 'OVERRIDE_LIBRARY_RESET'
text="Reset",
).type = 'OVERRIDE_LIBRARY_RESET'
layout.operator_menu_enum(
"outliner.liboverride_operation", "selection_set",
text="Clear",

View File

@@ -478,8 +478,10 @@ class SEQUENCER_MT_view(Menu):
if is_sequencer_view:
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("sequencer.view_all")
layout.operator("anim.scene_range_frame",
text="Frame Preview Range" if context.scene.use_preview_range else "Frame Scene Range")
layout.operator(
"anim.scene_range_frame",
text="Frame Preview Range" if context.scene.use_preview_range else "Frame Scene Range",
)
layout.operator("sequencer.view_frame")
layout.prop(st, "use_clamp_view")
@@ -817,20 +819,41 @@ class SEQUENCER_MT_add_effect(Menu):
layout.operator_context = 'INVOKE_REGION_WIN'
col = layout.column()
col.operator("sequencer.effect_strip_add", text="Add",
text_ctxt=i18n_contexts.id_sequence).type = 'ADD'
col.operator("sequencer.effect_strip_add", text="Subtract",
text_ctxt=i18n_contexts.id_sequence).type = 'SUBTRACT'
col.operator("sequencer.effect_strip_add", text="Multiply",
text_ctxt=i18n_contexts.id_sequence).type = 'MULTIPLY'
col.operator("sequencer.effect_strip_add", text="Over Drop",
text_ctxt=i18n_contexts.id_sequence).type = 'OVER_DROP'
col.operator("sequencer.effect_strip_add", text="Alpha Over",
text_ctxt=i18n_contexts.id_sequence).type = 'ALPHA_OVER'
col.operator("sequencer.effect_strip_add", text="Alpha Under",
text_ctxt=i18n_contexts.id_sequence).type = 'ALPHA_UNDER'
col.operator("sequencer.effect_strip_add", text="Color Mix",
text_ctxt=i18n_contexts.id_sequence).type = 'COLORMIX'
col.operator(
"sequencer.effect_strip_add",
text="Add",
text_ctxt=i18n_contexts.id_sequence,
).type = 'ADD'
col.operator(
"sequencer.effect_strip_add",
text="Subtract",
text_ctxt=i18n_contexts.id_sequence,
).type = 'SUBTRACT'
col.operator(
"sequencer.effect_strip_add",
text="Multiply",
text_ctxt=i18n_contexts.id_sequence,
).type = 'MULTIPLY'
col.operator(
"sequencer.effect_strip_add",
text="Over Drop",
text_ctxt=i18n_contexts.id_sequence,
).type = 'OVER_DROP'
col.operator(
"sequencer.effect_strip_add",
text="Alpha Over",
text_ctxt=i18n_contexts.id_sequence,
).type = 'ALPHA_OVER'
col.operator(
"sequencer.effect_strip_add",
text="Alpha Under",
text_ctxt=i18n_contexts.id_sequence,
).type = 'ALPHA_UNDER'
col.operator(
"sequencer.effect_strip_add",
text="Color Mix",
text_ctxt=i18n_contexts.id_sequence,
).type = 'COLORMIX'
col.enabled = selected_sequences_len(context) >= 2
layout.separator()
@@ -1136,13 +1159,25 @@ class SEQUENCER_MT_image_clear(Menu):
def draw(self, _context):
layout = self.layout
layout.operator("sequencer.strip_transform_clear", text="Position",
text_ctxt=i18n_contexts.default).property = 'POSITION'
layout.operator("sequencer.strip_transform_clear", text="Scale",
text_ctxt=i18n_contexts.default).property = 'SCALE'
layout.operator("sequencer.strip_transform_clear", text="Rotation",
text_ctxt=i18n_contexts.default).property = 'ROTATION'
layout.operator("sequencer.strip_transform_clear", text="All Transforms").property = 'ALL'
layout.operator(
"sequencer.strip_transform_clear",
text="Position",
text_ctxt=i18n_contexts.default,
).property = 'POSITION'
layout.operator(
"sequencer.strip_transform_clear",
text="Scale",
text_ctxt=i18n_contexts.default,
).property = 'SCALE'
layout.operator(
"sequencer.strip_transform_clear",
text="Rotation",
text_ctxt=i18n_contexts.default,
).property = 'ROTATION'
layout.operator(
"sequencer.strip_transform_clear",
text="All Transforms",
).property = 'ALL'
class SEQUENCER_MT_image_apply(Menu):

View File

@@ -817,12 +817,10 @@ class ToolSelectPanelHelper:
# Add some spacing since the icon is currently assuming regular small icon size.
if show_tool_icon_always:
layout.label(
text=" " +
iface_(
item.label,
i18n_contexts.operator_default),
text=" " + iface_(item.label, i18n_contexts.operator_default),
icon_value=icon_value,
translate=False)
translate=False,
)
layout.separator()
else:
if not context.space_data.show_region_toolbar:
@@ -847,8 +845,11 @@ class ToolSelectPanelHelper:
row = layout.row(heading="Drag", heading_ctxt=i18n_contexts.editor_view3d)
row.context_pointer_set("tool", tool)
row.popover(panel="TOPBAR_PT_tool_fallback", text=iface_(
label, i18n_contexts.operator_default), translate=False)
row.popover(
panel="TOPBAR_PT_tool_fallback",
text=iface_(label, i18n_contexts.operator_default),
translate=False,
)
return tool

View File

@@ -2036,9 +2036,10 @@ class _defs_weight_paint:
if context is None:
return VIEW3D_PT_tools_active._tools_select
ob = context.active_object
if (ob and ob.type == 'MESH' and
(ob.data.use_paint_mask or
ob.data.use_paint_mask_vertex)):
if (
ob and ob.type == 'MESH' and
(ob.data.use_paint_mask or ob.data.use_paint_mask_vertex)
):
return VIEW3D_PT_tools_active._tools_select
elif context.pose_object:
return VIEW3D_PT_tools_active._tools_select

View File

@@ -57,7 +57,8 @@ class TOPBAR_HT_upper_bar(Header):
window, "view_layer",
scene, "view_layers",
new="scene.view_layer_add",
unlink="scene.view_layer_remove")
unlink="scene.view_layer_remove",
)
class TOPBAR_PT_tool_settings_extra(Panel):
@@ -299,8 +300,9 @@ class TOPBAR_MT_file_defaults(Menu):
if app_template:
layout.label(
text=iface_(bpy.path.display_name(app_template, has_ext=False),
i18n_contexts.id_workspace), translate=False)
text=iface_(bpy.path.display_name(app_template, has_ext=False), i18n_contexts.id_workspace),
translate=False,
)
layout.operator("wm.save_homefile")
if app_template:

View File

@@ -1020,7 +1020,8 @@ class VIEW3D_HT_header(Header):
row.popover(
panel="VIEW3D_PT_mask",
icon=VIEW3D_HT_header._texture_mask_icon(tool_settings.image_paint),
text="")
text="",
)
else:
# Transform settings depending on tool header visibility
VIEW3D_HT_header.draw_xform_template(layout, context)
@@ -2588,7 +2589,8 @@ class VIEW3D_MT_grease_pencil_add(Menu):
layout.operator(
"object.grease_pencil_add",
text="Collection Line Art",
icon='OUTLINER_COLLECTION').type = 'LINEART_COLLECTION'
icon='OUTLINER_COLLECTION',
).type = 'LINEART_COLLECTION'
layout.operator("object.grease_pencil_add", text="Object Line Art", icon='OBJECT_DATA').type = 'LINEART_OBJECT'
@@ -4341,8 +4343,11 @@ class BoneOptions:
opt_suffix = "bone."
for opt in options:
props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name,
text_ctxt=i18n_contexts.default)
props = layout.operator(
"wm.context_collection_boolean_set",
text=bone_props[opt].name,
text_ctxt=i18n_contexts.default,
)
props.data_path_iter = data_path_iter
props.data_path_item = opt_suffix + opt
props.type = self.type
@@ -7593,7 +7598,8 @@ class VIEW3D_PT_snapping(Panel):
"use_snap_translate",
text="Move",
text_ctxt=i18n_contexts.operator_default,
toggle=True)
toggle=True,
)
row.prop(tool_settings, "use_snap_rotate", text="Rotate", text_ctxt=i18n_contexts.operator_default, toggle=True)
row.prop(tool_settings, "use_snap_scale", text="Scale", text_ctxt=i18n_contexts.operator_default, toggle=True)
col.label(text="Rotation Increment")
@@ -7627,8 +7633,10 @@ class VIEW3D_PT_proportional_edit(Panel):
layout = self.layout
tool_settings = context.tool_settings
col = layout.column()
col.active = (tool_settings.use_proportional_edit_objects if context.mode == 'OBJECT'
else tool_settings.use_proportional_edit)
col.active = (
tool_settings.use_proportional_edit_objects if context.mode == 'OBJECT' else
tool_settings.use_proportional_edit
)
if context.mode != 'OBJECT':
col.prop(tool_settings, "use_proportional_connected")
@@ -7769,14 +7777,17 @@ class VIEW3D_PT_overlay_grease_pencil_options(Panel):
ob = context.object
layout.label(text={
'PAINT_GREASE_PENCIL': iface_("Draw Grease Pencil"),
'EDIT_GREASE_PENCIL': iface_("Edit Grease Pencil"),
'WEIGHT_GREASE_PENCIL': iface_("Weight Grease Pencil"),
'OBJECT': iface_("Grease Pencil"),
'SCULPT_GREASE_PENCIL': iface_("Sculpt Grease Pencil"),
'VERTEX_GREASE_PENCIL': iface_("Vertex Grease Pencil"),
}[context.mode], translate=False)
layout.label(
text={
'PAINT_GREASE_PENCIL': iface_("Draw Grease Pencil"),
'EDIT_GREASE_PENCIL': iface_("Edit Grease Pencil"),
'WEIGHT_GREASE_PENCIL': iface_("Weight Grease Pencil"),
'OBJECT': iface_("Grease Pencil"),
'SCULPT_GREASE_PENCIL': iface_("Sculpt Grease Pencil"),
'VERTEX_GREASE_PENCIL': iface_("Vertex Grease Pencil"),
}[context.mode],
translate=False
)
layout.prop(overlay, "use_gpencil_onion_skin", text="Onion Skin")
@@ -8052,8 +8063,10 @@ class VIEW3D_MT_grease_pencil_assign_material(Menu):
for slot in ob.material_slots:
mat = slot.material
if mat:
layout.operator("grease_pencil.stroke_material_set", text=mat.name,
icon='LAYER_ACTIVE' if mat == mat_active else 'BLANK1').material = mat.name
layout.operator(
"grease_pencil.stroke_material_set", text=mat.name,
icon='LAYER_ACTIVE' if mat == mat_active else 'BLANK1',
).material = mat.name
class VIEW3D_MT_greasepencil_edit_context_menu(Menu):

View File

@@ -113,7 +113,9 @@ def is_not_gpencil_edit_mode(context):
'EDIT_GPENCIL',
'PAINT_GREASE_PENCIL',
'SCULPT_GREASE_PENCIL',
'WEIGHT_GREASE_PENCIL'})
'WEIGHT_GREASE_PENCIL',
}
)
return not is_gpmode

View File

@@ -24,15 +24,19 @@ class SortedNodeCategory(NodeCategory):
class CompositorNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'CompositorNodeTree')
return (
context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'CompositorNodeTree'
)
class ShaderNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'ShaderNodeTree')
return (
context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'ShaderNodeTree'
)
# Maps node tree type to group node type.

View File

@@ -55,7 +55,8 @@ def add_object_button(self, context):
self.layout.operator(
OBJECT_OT_add_object.bl_idname,
text="Add Object",
icon='PLUGIN')
icon='PLUGIN',
)
# This allows you to right click on a button and link to documentation

View File

@@ -56,8 +56,10 @@ class UIListPanelExample(bpy.types.Panel):
# The second one can usually be left as an empty string.
# It's an additional ID used to distinguish lists in case you
# use the same list several times in a given area.
layout.template_list("MATERIAL_UL_matslots_example", "compact", obj, "material_slots",
obj, "active_material_index", type='COMPACT')
layout.template_list(
"MATERIAL_UL_matslots_example", "compact", obj, "material_slots",
obj, "active_material_index", type='COMPACT',
)
def register():