How to access the contents of the Q menu from python?

Prefs often get corrupted-- I mean ALL the time. My customers and those of many others have corrupted prefs and we need to tell them to rebuild.

Bonjorno7 has a good tool called PowerBackup and it can save out most of what’s in a prefs to a json file which can then be reimported to “clean” the prefs. But, it cannot save out the Q menu because he says there’s no api to access it from python.

Is there a way other than by a dedicated api to access the Q menu contents? Or, even better would be if the devs would just store the prefs as json to begin with, my guess is we’d have less corrupted preferences.

2 Likes

this post needs more attention. for the two points you are talking about
I loose often Q shortcuts because of corrupted userprefs.blend… and no way to deal with it. unless manual save.
an incremental auto save of this should be possible and of course an access from preferences
(same about saving blend files no incremental autosave)
keys management could be improved in a less complex management and linked to this the addons key preferences are a mess…and 0 transparency about what’s happens in userprefs.blend
themes should have a save option
and much more basic things
once Bretch answered me that keys shouldn’t be changed unless to do a complete new map. no comments

Anyone else here care to comment? Is there literally no way to backup Q shortcuts? If not, can someone please create an addon to replace the Q menu which can be backed up? Maybe I’ll do it.

Apparently they are stored with the preferences. See T74650

Yes, I know they are. See my OP. The point is if the Prefs get corrupted, as they often do, there’s no way to back them up. You can back up virtually everything else in Prefs BUT you cannot back up the Q Menu because there is no API to access the data.

trolololo

You CAN backup Q menus.
You simply copy the data from the .prefs file located in the appdata, to wherever.
You can access the file’s location via the preferences.
You copy that file wherever/however.

Then, when it comes to restoring, you just copy all the other preference data to a temp variable, then create/overwrite the .prefs file with the backup prefs file, then reload the data from the temp variable.

BAM, you got only the Q menus exported/imported



I don’t care about any of this, I want to edit the menus in Python, so I can add things to the menus, including entries with a poll.
Right now, I have to create a menu and place it in the UI, then add that menu to the QFav, and do the polling inside that menu.

So, I have to have a menu entry that always show, and can only hide it as far as hiding the buttons inside it, leaving it as either a small empty line, or text message saying there’s nothing there.

Plus, in order to re-arrange the order of the items, I have to open the QF for that mode (because the modes have different instances of QF) then one-by-one, right-click each entry and click Remove from Fav, then Right Click again and go to Add to Fav.
This sends that one entry to the bottom, and then you repeat for the others until you get the order you want.

Maybe you want to create a separate post about what you want?

1 Like

No, it is good here.