I made some code that needs to run on a hook (start-up, open doc or app-init all seem viable).
The script works when i test it from a PushButton, But it fails when run from a hookscript.
When run form a hook ( tried all 3 types) it doesn’t seems to find the button itself.
reflections on why this is?
# -*- coding: utf-8 -*-
from pyrevit import forms
from pyrevit.coreutils import ribbon
from logUtils import version_check
from dirUtils import ext_dir
uptodate = version_check()
if uptodate == True:
icon_path = os.path.join(ext_dir(),'Tools.tab','Settings.panel','Update.PushButton','on.png')
if uptodate == False:
icon_path = os.path.join(ext_dir(),'Tools.tab','Settings.panel','Update.PushButton','off.png')
if __name__ == '__main__':
# Set update button
Hi @AlexanderVDB, the error you stated before is due to the get_ubutton not finding the button, and that’s exactly what you found out in your last post.
What I was asking is to run the the first instruction that is inside the get_uibutton function (pay attention at the code of my previous post) to understand if there are some toolbars to look into for your buttons.
If it returns None (and I suspect it will, but I’m still not that knowledgeable of pyrevit internals) that’s because pyrevit tabs are not yet ready during the startup.
Of course, when you reload the tabs/buttons are already there, so you can access them.
If my suppositions are right, this could be a good candidate for a github issue