2
$\begingroup$

Is it possible to get the disable version of an icon? I mean, like when we set the layout.enabled = False?

(I need a property to look (only look) as disable, but being able to use it. But I would like it to have the disable look to inform the user that the changes are not taking into account.

Is it possible to get that greyed out version of a Blender icon?

Thank you so much.

$\endgroup$
2
  • $\begingroup$ Are you able to get the normal icon? Can you show a script that works for getting the normal icon? Then we can dig deeper to get the disabled version as well. What have you tried? $\endgroup$ Jul 27, 2023 at 6:11
  • $\begingroup$ Hello there. I wasn't able to get the icon (and with the "icon" I guess I mean their ImagePreview). I think getting their ImagePreview may be the key, since with it we would ble to modify the original icon and kinda create a new image from them (like modifying their original alpha, or anything else) and then add those modified versions to an image preview. But I'm not sure if we are able to get their image preview from their name/icon_id. $\endgroup$
    – Ommadawn
    Jul 27, 2023 at 14:47

1 Answer 1

0
$\begingroup$

Not answering to your question directly, maybe there's a way to somehow disable the icon but not the widget it is from.

But if I am not wrong, Blender usually uses a couple of icons for these cases. And maybe you or future readers could use them.

If you use the Icon Viewer addon shipped with Blender, you can see lots of icons are actually two : one for the active and one for the inactive state.

A few examples:

enter image description here

enter image description here

enter image description here

In which case, it can be as simple as creating a boolproperty, let the button set its icon from it, and toggle the bool property when clicked.

Example:

import bpy
from bpy.types import Panel

bpy.types.Scene.my_toggle_property = bpy.props.BoolProperty(default=False)

class TEXT_PT_test(Panel):
    bl_space_type = 'TEXT_EDITOR'
    bl_region_type = 'UI'
    bl_category = "Text"
    bl_label = "Test"

    def draw(self, context):
        layout = self.layout
        scene = context.scene

        hide_icon = "HIDE_OFF" if scene.my_toggle_property else "HIDE_ON"
        layout.prop(scene, "my_toggle_property", icon=hide_icon, text="")

def register():
    bpy.utils.register_class(TEXT_PT_test)

def unregister():
    bpy.utils.unregister_class(TEXT_PT_test)

if __name__ == "__main__":
    register()

enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .