[Ticket #5975] Get reference to active task dialog
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
[Ticket #5975] Get reference to active task dialog
Is it possible to get a reference to the active task dialog in Python?
Gui.Control.activeDialog() only returns a boolean indicating whether or not it exists.
Gui.Control.activeDialog() only returns a boolean indicating whether or not it exists.
Last edited by Kunda1 on Sun Aug 28, 2022 2:34 pm, edited 2 times in total.
Reason: Added GH ticket number to thread title
Reason: Added GH ticket number to thread title
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Get reference to active task dialog
This is code from the wiki on adding a new tab to the combo view. Perhaps it will help.
You might need to change qApp to QApplication.
Code: Select all
# create new Tab in ComboView
from PySide import QtGui,QtCore
#from PySide import uic
def getMainWindow():
"returns the main window"
# using QtGui.qApp.activeWindow() isn't very reliable because if another
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
# returned
toplevel = QtGui.qApp.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
def getComboView(mw):
dw=mw.findChildren(QtGui.QDockWidget)
for i in dw:
if str(i.objectName()) == "Combo View":
return i.findChild(QtGui.QTabWidget)
elif str(i.objectName()) == "Python Console":
return i.findChild(QtGui.QTabWidget)
raise Exception ("No tab widget found")
mw = getMainWindow()
tab = getComboView(getMainWindow())
tab2=QtGui.QDialog()
tab.addTab(tab2,"A Special Tab")
#uic.loadUi("/myTaskPanelforTabs.ui",tab2)
tab2.show()
#tab.removeTab(2)
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: Get reference to active task dialog
Yeah, I've got that code. I was just hoping there was a way to directly get a reference to the active task dialog. That's what Control.activeDialog() returns on the C++, side, but it's reduced to a boolean for the Python call.TheMarkster wrote: ↑Fri Aug 09, 2019 6:25 pm This is code from the wiki on adding a new tab to the combo view. Perhaps it will help.
I have a workaround figured out already, so it's not an issue - but it sure seems like a valuable feature to add to Gui::ControlPy
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
Re: Get reference to active task dialog
Feel free to open a ticket for a feature request.
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: Get reference to active task dialog
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
Re: Get reference to active task dialog
@Joel_graff care to add this forum thread link to the ticket (didn't see it there) and also modifying/prepending the thread title with the ticket number associated ? Thanks!Joel_graff wrote: ↑Mon Aug 12, 2019 12:57 pm Done.
https://www.freecadweb.org/tracker/view.php?id=4090
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
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
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: [Ticket #4090] Get reference to active task dialog
Done!
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
Re: [Ticket #4090] Get reference to active task dialog
+1 for this feature request
In the meantime, do you know a workaround to get the name of the active dialog ?
In the meantime, do you know a workaround to get the name of the active dialog ?
Formations - Assistance - Développement : https://freecad-france.com
Re: Get reference to active task dialog
+1 for this
Thanks.
@Joel_graff can you show how you did it?Joel_graff wrote: ↑Fri Aug 09, 2019 7:05 pm
I have a workaround figured out already, so it's not an issue...
Thanks.
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: [Ticket #4090] Get reference to active task dialog
I have no idea how I did it. Or where that code resides anymore. lol
I'll dig around and see if I can figure it out.
I'll dig around and see if I can figure it out.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers