Gui Commands with the QActionGroup widget

Need help, or want to share a macro? Post here!
hamish
Posts: 72
Joined: Wed Nov 12, 2014 7:08 am

Gui Commands with the QActionGroup widget

Postby hamish » Fri Feb 20, 2015 8:19 am

Hi,

I am looking into adding welding symbols to the drawing dimension workbench.
Since there are alot of welding symbols, I was thinking of QActionGroup widget like the drawing workbench uses for the "Drawing_NewPage" command.
I looked code for "Drawing_NewPage" command, which is in c++, and have gotten stuck.

Any ideas on how to create QActionGroup widget for a command using Python?
Can the `Action * PythonCommand::createAction' be overloaded in Python, or something like that ...
Looking at the FreeCAD source for gui/Command.cpp, seems to indicate no (well I am no c++ expert...)

Regards,
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Gui Commands with the QActionGroup widget

Postby yorik » Fri Feb 20, 2015 3:41 pm

I don't think that is easily possible at the moment... It is of course possible to mimmick how it works in c++ with pyside (find the toolbar and add an actiongroup to it), but, if you plan to add python commands to the existing Drawing WB, I think I would do the same as in PartDesign: simply create your python commands in different files, and import them in InitGui.py. Then, we can modify the C++ workbench to add these commands to a QActionGroup.

If you don't want to create full FreeCAD commands, but just create some qactions, then I would create an additional, pure pyside toolbar, same as I did for the Draft snapping tools (that toolbar is created and managed in Draft/DraftSnap.py, line 1162 show() and line 1068 makeSnapToolBar(). There you can do all the stuff you want, independently of the other toolbars, and not use FreeCAD's command registering stuff.
wmayer
Site Admin
Posts: 14611
Joined: Thu Feb 19, 2009 10:32 am

Re: Gui Commands with the QActionGroup widget

Postby wmayer » Sat Feb 21, 2015 4:53 pm

Any ideas on how to create QActionGroup widget for a command using Python?
Doing this the same way as in Drawing but from Python is currently not possible. But it won't be that difficult to support this. All what we need is a C++ class PythonGroupCommand that works similarly to CmdDrawingNewPage.
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Gui Commands with the QActionGroup widget

Postby yorik » Mon Feb 23, 2015 1:29 am

We could also extend the Gui::PythonWorkbench appendMenu() function, to be able to do something like this:

Code: Select all

appendMenu( [menuItem, subMenuItem], [cmd1, cm2, [groupCmd3, groupCmd4], cmd5] )
hamish
Posts: 72
Joined: Wed Nov 12, 2014 7:08 am

Re: Gui Commands with the QActionGroup widget

Postby hamish » Mon Feb 23, 2015 6:00 am

A PythonGroupCommand would be fantastic.
If the enhancement is added, I would definitely use it.
wmayer
Site Admin
Posts: 14611
Joined: Thu Feb 19, 2009 10:32 am

Re: Gui Commands with the QActionGroup widget

Postby wmayer » Mon Feb 23, 2015 3:20 pm

hamish wrote:A PythonGroupCommand would be fantastic.
If the enhancement is added, I would definitely use it.
Adding this after the 0.15 release is out would this be OK?
hamish
Posts: 72
Joined: Wed Nov 12, 2014 7:08 am

Re: Gui Commands with the QActionGroup widget

Postby hamish » Tue Feb 24, 2015 6:29 am

Hi wmayer,

The PythonGroupCommand request is not urgent.
So yes, from my side it is okay if the enhancement is added after the 0.15 release is out.

Best regards to you and yorik
wmayer
Site Admin
Posts: 14611
Joined: Thu Feb 19, 2009 10:32 am

Re: Gui Commands with the QActionGroup widget

Postby wmayer » Sat Jun 27, 2015 3:51 pm