Multiple Task dialogs simultaneously

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
JiriVALASEK
Posts: 48
Joined: Wed Apr 17, 2019 7:42 pm

Multiple Task dialogs simultaneously

Post by JiriVALASEK »

Hi,

is it possible to have multiple task dialogs active simultaneously? I have multiple FeaturePythons and I'd like to open task dialogs for some of them, tinker with some parameters and save them. Nevertheless, when I do

Code: Select all

dg = TaskDialog()
FreeCADGui.Control.showDialog(dg)
for my second FeaturePython, I get

Code: Select all

<class 'RuntimeError'>: Active task dialog found
Thanks a lot.
chrisb
Veteran
Posts: 53933
Joined: Tue Mar 17, 2015 9:14 am

Re: Multiple Task dialogs simultaneously

Post by chrisb »

JiriVALASEK wrote: Fri Jun 21, 2019 10:24 pm is it possible to have multiple task dialogs active simultaneously?
No.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Multiple Task dialogs simultaneously

Post by wandererfan »

JiriVALASEK wrote: Fri Jun 21, 2019 10:24 pm is it possible to have multiple task dialogs active simultaneously?
You can't have multiple task dialogs, but you can show a QDialog from within a task dialog.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Multiple Task dialogs simultaneously

Post by wmayer »

You can have only one TaskDialog at a time but a task dialog can have multiple task boxes. As an example to see how this looks create a sketch in PartDesign and edit it. On the left side you will see several boxes.
JiriVALASEK
Posts: 48
Joined: Wed Apr 17, 2019 7:42 pm

Re: Multiple Task dialogs simultaneously

Post by JiriVALASEK »

wandererfan wrote: Sat Jun 22, 2019 1:09 am You can't have multiple task dialogs, but you can show a QDialog from within a task dialog.
Yes, that's what I need. I wrongly assumed that what I see during sketching (img below) is multiple task dialogs. I haven't noticed there's only one StandartButton.
QDialogs.png
QDialogs.png (19 KiB) Viewed 1660 times
Could you nudge me in a direction how to do that?
Is there a way how to access currently opened task dialog (I can't find anything useful to do so in FreeCAD/src/Gui/Control.h)?

Thanks
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Multiple Task dialogs simultaneously

Post by wmayer »

This is a trivial example:

Code: Select all

from PySide2 import QtWidgets

class TaskDialog():
    def __init__(self):
        self.form=[QtWidgets.QCalendarWidget(),QtWidgets.QCalendarWidget(),QtWidgets.QCalendarWidget()]
        
FreeCADGui.Control.showDialog(TaskDialog())
So, the whole magic is that you define an attribute "form" that is a list of widgets.
JiriVALASEK
Posts: 48
Joined: Wed Apr 17, 2019 7:42 pm

Re: Multiple Task dialogs simultaneously

Post by JiriVALASEK »

wmayer wrote: Sat Jun 22, 2019 10:58 am This is a trivial example:

Code: Select all

from PySide2 import QtWidgets

class TaskDialog():
    def __init__(self):
        self.form=[QtWidgets.QCalendarWidget(),QtWidgets.QCalendarWidget(),QtWidgets.QCalendarWidget()]
        
FreeCADGui.Control.showDialog(TaskDialog())
So, the whole magic is that you define an attribute "form" that is a list of widgets.
I see. Thanks!

Btw. Is there a way to retrieve currently open TaskDialog (through Gui.Control or using another way)?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Multiple Task dialogs simultaneously

Post by wmayer »

Btw. Is there a way to retrieve currently open TaskDialog (through Gui.Control or using another way)?
No, there isn't.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Multiple Task dialogs simultaneously

Post by TheMarkster »

JiriVALASEK wrote: Fri Jun 21, 2019 10:24 pm Hi,

is it possible to have multiple task dialogs active simultaneously? I have multiple FeaturePythons and I'd like to open task dialogs for some of them, tinker with some parameters and save them. Nevertheless, when I do

Code: Select all

dg = TaskDialog()
FreeCADGui.Control.showDialog(dg)
for my second FeaturePython, I get

Code: Select all

<class 'RuntimeError'>: Active task dialog found
Thanks a lot.
What about adding another tab? There is a code example on the wiki for doing it.

https://www.freecadweb.org/wiki/Code_snippets

(I think you need to replace qApp with QApplication in the example.)
Post Reply