I'm in Part design-sketcher, from macro how to click the close button
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
I'm in Part design-sketcher, from macro how to click the close button
While in part design-sketcher I want to add a close button to a macro, this would be the close button in sketcher-comboview-tasks. Is there a way to signal the close button is pressed?
Thanks
Thanks
Re: I'm in Part design-sketcher, from macro how to click the close button
This is a bit vague without any context, but generally you can register a FilterEvent to an existing widget.
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: I'm in Part design-sketcher, from macro how to click the close button
Part-o-magic Leave command can do it. see https://github.com/DeepSOIC/Part-o-magi ... ter.py#L64
Re: I'm in Part design-sketcher, from macro how to click the close button
DeepSOIC, thank you, that worked great.
I added this to set focus on the tree when returning to part design (in case anyone is looking) :
Thanks all
I added this to set focus on the tree when returning to part design (in case anyone is looking) :
Code: Select all
mw = FreeCADGui.getMainWindow()
dw= mw.findChildren(QtGui.QDockWidget)
for i in dw:
if i.objectName() == "Combo View":
tab = i.findChild(QtGui.QTabWidget)
tab.setCurrentIndex(0)
Re: I'm in Part design-sketcher, from macro how to click the close button
You can greatly simplify :
Code: Select all
FreeCADGui.getMainWindow().findChild(QtGui.QDockWidget, "Combo View").findChild(QtGui.QTabWidget).setCurrentIndex(0)
Re: I'm in Part design-sketcher, from macro how to click the close button
@openBrain, thanks, I was thinking about that. I didn't have the findChild in my mental toolbox, got it now.
Re: I'm in Part design-sketcher, from macro how to click the close button
@openBrain, I tried that line of code and it does not want to work. I researched the functions and I can't see why. It's no big deal cause I have code that works but there is something not right.
If I run from the console:
I have this in my macro:
If I run from the console:
Code: Select all
>>> FreeCADGui.getMainWindow().findChild(QtGui.QDockWidget, "Combo View").findChild(QtGui.QTabWidget).setCurrentIndex(0)
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'QtGui' is not defined
Code: Select all
import FreeCAD
import FreeCADGui
import time
from pivy import coin
import FreeCAD as App, FreeCADGui
from PySide import QtGui,QtCore
Re: I'm in Part design-sketcher, from macro how to click the close button
Before running the line in the console, you have to enter :
Honestly I didn't check the line and post it directly.
Code: Select all
from PySide import QtGui
Re: I'm in Part design-sketcher, from macro how to click the close button
The line correctly ends here (no error) but I don't see any effect...
Re: I'm in Part design-sketcher, from macro how to click the close button
Using the list of imports and executing this line I get no error and FreeCAD switches the tab in ComboView from Tasks to Model. The Sketch stays in edit mode in Sketcher.openBrain wrote: ↑Tue Nov 12, 2019 6:03 pmCode: Select all
FreeCADGui.getMainWindow().findChild(QtGui.QDockWidget, "Combo View").findChild(QtGui.QTabWidget).setCurrentIndex(0)
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.