[Solved] Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: [Solved] Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
I know which one you mean. I can vaguely remember that it was not in the topic's title. What a big help!
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
@wmayerwmayer wrote: ↑Sun Aug 20, 2017 9:11 pm FYI, in Qt any sub-class of QObject can re-implement the (in C++ virtual) method eventFilter() and can be installed to any other QObject-dervied instance to observe or filter the events it gets.
In C++ the class name of the About dialog including name spaces is called Gui::Dialog::AboutDialog and the class name of a QObject can be determined by its meta object. So, the event filter only looks for About dialogs and as event it uses the polish event which is called before the dialog is shown.
The name of the method of the dialog that is invoked when pressing the Copy button is called on_copyButton_clicked() and is marked as a slot function (for more information refer to the Qt docs to see what a slot function exactly is) and this allows it to allow to call it over its meta object.
By calling on_copyButton_clicked all the needed information is copied to the clipboard and the dialog can be closed again. Thus, a close event is posted to the dialog class.
The four lines at the end are needed to install the event filter to the global application object, invoke the Std_About command which internally creates the About dialog and removing the event filter again.
can this function be accessible without the GUI enabled (aka 'headless')?
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
Re: [Solved] Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
I have created a macro and have placed in my globals toolbar.
I can run the macro from the macro dialog by selecting and executing it.
However, if I run it from the toolbar I get an error message:
I can run other macros in the same way without problems. Any ideas?
I can run the macro from the macro dialog by selecting and executing it.
However, if I run it from the toolbar I get an error message:
Code: Select all
Traceback (most recent call last):
File "/Users/cb/panhard/coupe/sanssoupapes/copyToClipboard.FCMacro", line 2, in <module>
from PySide import QtOpenGL
<class 'ImportError'>: cannot import name 'QtOpenGL' from 'PySide' (/Users/cb/Desktop/FreeCAD.app/Contents/Resources/Ext/PySide/__init__.py)
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: [Solved] Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
You may have to add the file QtOpenGL.py inside FreeCAD's Ext\PySide directory with the content:
Code: Select all
from PySide2.QtOpenGL import *
Re: [Solved] Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
Any progress on this?
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
Re: [Solved] Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
Sorry for being late: It works! Thank you.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
@wmayer how can I get this same output but using freecad --console ?wmayer wrote: ↑Sun Aug 20, 2017 2:00 pmCode: Select all
from PySide import QtCore from PySide import QtGui class AboutInfo(QtCore.QObject): def eventFilter(self, obj, ev): if obj.metaObject().className() == "Gui::Dialog::AboutDialog": if ev.type() == ev.ChildPolished: print(obj.metaObject().className()) mo = obj.metaObject() index = mo.indexOfMethod("on_copyButton_clicked()") if index > 0: mo.invokeMethod(obj, "on_copyButton_clicked") QtGui.qApp.postEvent(obj, QtGui.QCloseEvent()) return False ai=AboutInfo() QtGui.qApp.installEventFilter(ai) Gui.runCommand("Std_About") QtGui.qApp.removeEventFilter(ai)
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
Re: [Solved] Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
Not at all. Or how do you think to open the About dialog in CLI mode?@wmayer how can I get this same output but using freecad --console ?
Re: Help firing AboutDialog::on_copyButton_clicked() wanted by n00b
Oh Man !!! This is what I was looking for. I added "Std_About" to the woodworking workbench because I didn't know how to grab the info content. Can I use your code? for example to add some info that the details has been already copied or something like that.wmayer wrote: ↑Sun Aug 20, 2017 2:00 pmCode: Select all
from PySide import QtCore from PySide import QtGui class AboutInfo(QtCore.QObject): def eventFilter(self, obj, ev): if obj.metaObject().className() == "Gui::Dialog::AboutDialog": if ev.type() == ev.ChildPolished: print(obj.metaObject().className()) mo = obj.metaObject() index = mo.indexOfMethod("on_copyButton_clicked()") if index > 0: mo.invokeMethod(obj, "on_copyButton_clicked") QtGui.qApp.postEvent(obj, QtGui.QCloseEvent()) return False ai=AboutInfo() QtGui.qApp.installEventFilter(ai) Gui.runCommand("Std_About") QtGui.qApp.removeEventFilter(ai)
Thanks
Darek
github.com/dprojects
workbench for woodworking is available at: github.com/dprojects/Woodworking