Skip to content

Commit

Permalink
Merge pull request #5026 from nortikin/fix_5025_Open_Sverchok_and_Ble…
Browse files Browse the repository at this point in the history
…nder_Console_with_operators_in_menu

Lets try to see these buttons in general mode. Any case they can be hidden in a developer mode.
  • Loading branch information
satabol authored Oct 20, 2023
2 parents efb63b8 + ac97f84 commit cb09c9b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion ui/sv_examples_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pathlib import Path

import bpy
from bpy.types import Operator

import sverchok
from sverchok.utils.sv_json_import import JSONImporter
Expand All @@ -22,6 +23,23 @@ def node_examples_pulldown(self, context):
row.scale_x = 1.3
row.menu("SV_MT_layouts_examples", icon="RNA")

def node_settings_pulldown(self, context):
if context.space_data.tree_type == 'SverchCustomTreeType':
layout = self.layout
row = layout.row(align=True)
row.scale_x = 1.3
row.operator(
"preferences.addon_show", icon="SETTINGS" #, text="Settings"
).module = __package__.split('.')[0]
row.operator("switcher.console", icon="CONSOLE", text="")

class SW_OT_Console(Operator):
"""Show/hide console"""
bl_label = "Open Blender system console"
bl_idname = "switcher.console"
def execute(self, context):
bpy.ops.wm.console_toggle()
return {'FINISHED'}

class SV_MT_LayoutsExamples(bpy.types.Menu):
"""Node tree examples"""
Expand Down Expand Up @@ -96,15 +114,17 @@ def execute(self, context):
return {'FINISHED'}


classes = [SV_MT_LayoutsExamples, SvNodeTreeImporterSilent]
classes = [SW_OT_Console, SV_MT_LayoutsExamples, SvNodeTreeImporterSilent]


def register():
submenu_classes = (make_submenu_classes(path, category_name) for path, category_name in example_categories_names())
_ = [bpy.utils.register_class(cls) for cls in chain(classes, submenu_classes)]
bpy.types.NODE_HT_header.append(node_examples_pulldown)
bpy.types.NODE_HT_header.append(node_settings_pulldown)


def unregister():
bpy.types.NODE_HT_header.remove(node_settings_pulldown)
bpy.types.NODE_HT_header.remove(node_examples_pulldown)
_ = [bpy.utils.unregister_class(cls) for cls in reversed(classes)]

0 comments on commit cb09c9b

Please sign in to comment.