I didn't test it very hard, but it seems to work for me.
Not something I expect to use, personally--I'm more likely to use a keyboard shortcut.
FFF allows for similar change of button type, but doesn't require restart. I have this function:
Code:
def set_popup_mode(self):
if prefs['button_instantpopup']:
self.popup_type = QToolButton.InstantPopup
else:
self.popup_type = QToolButton.MenuButtonPopup
for bar in self.gui.bars_manager.bars:
w = bar.widgetForAction(self.qaction)
if w is not None:
w.setPopupMode(self.popup_type)
w.update()
return
...and call it from initialization_complete(), library_changed() and ConfigWidget save_settings() after saving settings.