Multiple Task dialogs simultaneously

Need help, or want to share a macro? Post here!
Post Reply
JiriVALASEK
Posts: 48
Joined: Wed Apr 17, 2019 7:42 pm

Multiple Task dialogs simultaneously

Post by JiriVALASEK » 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.

chrisb
Posts: 19731
Joined: Tue Mar 17, 2015 9:14 am

Re: Multiple Task dialogs simultaneously

Post by chrisb » Sat Jun 22, 2019 12:34 am

JiriVALASEK wrote:
Fri Jun 21, 2019 10:24 pm
is it possible to have multiple task dialogs active simultaneously?
No.

User avatar
wandererfan
Posts: 3162
Joined: Tue Nov 06, 2012 5:42 pm

Re: Multiple Task dialogs simultaneously

Post by wandererfan » Sat Jun 22, 2019 1:09 am

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
Site Admin
Posts: 15000
Joined: Thu Feb 19, 2009 10:32 am

Re: Multiple Task dialogs simultaneously

Post by wmayer » Sat Jun 22, 2019 8:23 am

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 » Sat Jun 22, 2019 8:32 am

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 331 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
Site Admin
Posts: 15000
Joined: Thu Feb 19, 2009 10:32 am

Re: Multiple Task dialogs simultaneously

Post by wmayer » 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.

JiriVALASEK
Posts: 48
Joined: Wed Apr 17, 2019 7:42 pm

Re: Multiple Task dialogs simultaneously

Post by JiriVALASEK » Sat Jun 22, 2019 11:04 am

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
Site Admin
Posts: 15000
Joined: Thu Feb 19, 2009 10:32 am

Re: Multiple Task dialogs simultaneously

Post by wmayer » Sat Jun 22, 2019 12:29 pm

Btw. Is there a way to retrieve currently open TaskDialog (through Gui.Control or using another way)?
No, there isn't.

TheMarkster
Posts: 1061
Joined: Thu Apr 05, 2018 1:53 am

Re: Multiple Task dialogs simultaneously

Post by TheMarkster » Wed Jun 26, 2019 12:16 am

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