Page 1 of 1

List output of all commands

Posted: Fri Jan 03, 2020 11:19 pm
by mmiscool
Hello,
I have been working on a concept for an alternative ribbon style UI for freecad. If i can get some code to do the following 3 things I think I will be well on my way to implementing the idea.

First I am hoping that there is a simple way of programmatically list all of the commands available in the GUI along with the current status of those commands (available / unavailable, clickable or grayed out). I know this information must be available some where because of the toolbar customization tool.

Second I would need an example of some python code to activate or run an arbitrary command from the list as if the user had clicked the command from the menus.

Third I would like to be able to export PNG images for each of the icons associated to the commands.

Thanks for any help.

Re: List output of all commands

Posted: Sat Jan 04, 2020 10:58 am
by mmiscool
I managed to get a listing of commands by exploring the Gui object.

It seems that the follwing code will give me a listing of the each of the commands as an array
print(Gui.listCommands())

Using the Gui.doCommandGui I can execute the command.
print(Gui.doCommandGui("name of command as astring")



I am still struggling to get the status of commands (enabled/or grayed out) and figuring out the icon file associated with each.

Any help would be appreciated.

Re: List output of all commands

Posted: Sat Jan 04, 2020 1:32 pm
by Kunda1
Is there a public repository you are building this on? Care to share it in the OP ?

Re: List output of all commands

Posted: Sat Jan 04, 2020 10:52 pm
by mmiscool
Not quite yet. This is actually a smaller portion of a larger project.

I do plan on putting some thing out after I get this part of it working. People should be pleasantly surprised by it I think.

And any snippets of code for outputting a listing of GUI commands and there status as to being enabled or disabled would be extremely helpful.

Re: List output of all commands

Posted: Sun Jan 05, 2020 12:48 pm
by mario52
hi

good idea

run the command:

Code: Select all

>>> Gui.runCommand('Draft_Arc',0)
>>> Gui.runCommand('Std_Macro_11',0)
....
for the icon in and image in gui
Qt_Example

for the icon in "FreeCAD" on a button

Code: Select all

        self.image_04 = QtGui.QIcon.fromTheme("edit-delete")                     # icone resource de FreeCAD sur bouton
        self.PB_Quit.setIcon(self.image_04)                                      # icone resource de FreeCAD sur bouton

mario

Re: List output of all commands

Posted: Sun Jan 05, 2020 1:24 pm
by mmiscool
Thanks for the reply there Mario.

I am looking to extract the icon file associated with a command from the command. This way I can export it. Not trying to assign an icon file to a custom command.

Re: List output of all commands

Posted: Sun Jan 05, 2020 1:34 pm
by mario52
hi

see "for the icon in "FreeCAD" on a button" above

example usage Gui.runCommand() Std_DrawStyle

other example use Gui.runCommand() [Macro] Bit of help for super users by openBrain

mario