I made a new panel in the N bar that contains a boolean property for which I put an update function, but after adding a debug line at the top of this function I can tell it's never called when I click my checkbox.

It's the first time I'm doing this so I don't know if I'm doing it right but for me so it seems, everything else is working fine...

To avoid more explanations, here is the structure of the key parts of my code:

import bpy

class MyPanel(bpy.types.Panel):    
    bl_label = "My Panel"
    bl_idname = "OBJECT_PT_my_panel"    
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'

    def draw(self, context):
        my_props = context.scene.my_props
        self.layout.prop(my_props, 'my_bool')

def my_func(self, context):
    # some stuff that's never done
    print("Running update function")

class MyProperties(bpy.types.PropertyGroup):
    my_bool = bpy.props.BoolProperty(update=my_func)

def register():
    bpy.types.Scene.my_props = bpy.props.PointerProperty(type=MyProperties)

if __name__ == "__main__":
  • $\begingroup$ It works for me. $\endgroup$ – Ray Mairlot May 16 '18 at 15:36
  • 1
    $\begingroup$ I added a few extra lines of code so it can be easily copied and pasted without needing any changes for it to run (otherwise everyone who wanted to test it would have to add these extra pieces). $\endgroup$ – Ray Mairlot May 16 '18 at 15:48
  • $\begingroup$ Thank you Ray, and yes actually my function is called, I just discovered I had to open system console to see it, I thought it would appear in the info area... So I'll do some more debugging for now, because I've got another problem with a modal that sometimes keeps running when I deactivate my addon and I can't access it anymore >< $\endgroup$ – antho57400 May 17 '18 at 0:04
  • $\begingroup$ Ok so I'm trying to call the invoke and cancel methods of an operator inside this update function, but, I tried with op.invoke(), I got AttributeError: Calling operator "[its_name].invoke" error, could not be found , then I tried with op() with a lot of sh*t to get it to work, I got TypeError: 'BPyOpsSubMod' object is not callable . I don't understand how I'm supposed to do it, and I tried different solutions I found on this site (there aren't too many)... But maybe I should create a new topic. $\endgroup$ – antho57400 May 17 '18 at 3:01
  • $\begingroup$ Actually it's called (and doesn't work), but to see my debug messages I had to do Window -> Toggle System Console... Sorry I'm new to this ^^' $\endgroup$ – antho57400 May 17 '18 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.