openBrain wrote: ↑
Sat Jul 18, 2020 7:21 am
TheMarkster wrote: ↑
Fri Jul 17, 2020 9:54 pm
I found a bug in Gui.getCommandShortcut() and Gui.getCommandInfo().
I remarked something else. Eg. if you look at View->Workbenches, the first ones have a shortcut as 'W, x' where x is a digit. These commands and shortcuts aren't listed by your function. I guess it's because this kind of commands is handled differently. May you have a look at this?
In this PR I also added a new command:
Gui.setCommandShortcut() which will enable easily changing the shortcut via python. Usage example:
Indeed this would made it easy to store user configuration in a JSON or XML file, and restore it. Though I think there was already something doable as @triplus succeed in https://github.com/triplus/ShortCuts
I saw somewhere in the source code a mention that some commands can have multiple actions. As an example of this you can load a workbench as:
(presumes Arch workbench is first workbench listed in the workbenches list)
Another example: Gui.runCommand('Std_Workbench',2) would activate the 3rd workbench in the list.
I believe the commands that accept an additional integer parameter are the ones with multiple actions, or perhaps these are handled in a case switch loop or something similar.
If you look in the customize dialog, keyboards tab, view menu, you see only the one workbench command. I think the case will be if you can't see a command in the customize dialog the python command won't see it either. Similarly, I'm finding if you can't set a shortcut in the customize dialog you can't set it in the Gui.setCommandShortcut() function either. Based on initial testing I'm getting about 84.5% success rate when loading all installed workbenches and testing all commands found with Gui.listCommands(). The function will return False if it's unable to set the shortcut.