Gui Commands with the QActionGroup widget

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

Gui Commands with the QActionGroup widget

Post by hamish »

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
Founder
Posts: 13527
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Gui Commands with the QActionGroup widget

Post by yorik »

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
Founder
Posts: 20074
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Gui Commands with the QActionGroup widget

Post by wmayer »

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
Founder
Posts: 13527
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Gui Commands with the QActionGroup widget

Post by yorik »

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

Post by hamish »

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

Re: Gui Commands with the QActionGroup widget

Post by wmayer »

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

Post by hamish »

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
Founder
Posts: 20074
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Gui Commands with the QActionGroup widget

Post by wmayer »

User avatar
Kunda1
Veteran
Posts: 13443
Joined: Thu Jan 05, 2017 9:03 pm

Re: Gui Commands with the QActionGroup widget

Post by Kunda1 »

Just a heads up to anyone who came here for welding symbols, they have been implemented in TechDraw workbench. See https://forum.freecadweb.org/viewtopic.php?f=35&t=38560

This thread is now locked.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Locked