When creating a custom ribbon UI each control has its own callbacks for getting or setting data, or for handling other events. These callbacks are configured in the Ribbon XML as desribed in the ribbon documentation section of the user guide.
Sometimes you will want to tell Excel to redraw a particular ribbon control. For example, if you have an editBox control and you are using the getText action to populate the control, if the text you want to display changes you can invalidate that editBox control so that Excel will call the getText action again and then your Python function can return the new updated text.
To invalidate a control you need to call the "Invalidate" method on the IRibbonUI object, but first you need to get IRibbonUI object. To do that you need to add an "onLoad" action to your ribbon. This "onLoad" action will be called when the ribbon loads with the IRibbonUI object as an argument.
For example, in your ribbon XML you would add the onLoad action to the customUI element as follows (assuming your code is in a module named your_module.py):
<customUI
xmlns="http://schemas.microsoft.com/office/2009/07/customui"
onLoad="your_module.on_load">
<!-- your ribbon definition here -->
</customUI>
Then in your module ("your_module.py" is used above) you would add the action function "on_load" that takes the IRibbonUI object. You can then save it as a global variable so that you can call the "Invalidate" method later.
_ribbon = None
def on_load(control):
global _ribbon
_ribbon = control
# Later when you want to invalidate a control you would call
_ribbon.Invalidate(control_id)