Hi !
I'm looking for a possibility to react to an abstraction close.
I know I can catch opening with
but how to catch close ?
-
[SOLVED] On abstraction close
Work in progress : FCPD a FreeCAD PureData connexion
-
[iemguts/closebang]
-
@alexandros Yes, I know [closebang] too but I'm looking for a global watchdog as with [r pd].
Work in progress : FCPD a FreeCAD PureData connexion
-
@FFW
doesn't receive anything when closing other patches or abstractions.
Seems like closing is handled on the OS side. You might need to monitor window closing messages on the OS side (I don't know how yet), and communicate towards PD via [netreceive] or [ggee/shell] ....
Maybe you have more luck asking such a question in the mailing-list. -
@lacuna From the OS side you can use xdotool (for linux and possibly OSX but I am sure such tools exist in all OSs) and a simple shell script, something like,
while (xdotool search --name "window name"); do sleep 0.1 done echo 1
Run it with ggee/shell and stick a [sel 1] on the output to get a bang. But if you are using an external [closebang] seems more sensible, assuming it actually bangs on the closing of an abstraction and not just the closing of a patch?
-
@oid @lacuna
I've a python server running on background so I can use python watchdog but as the main program is single-thread it slow down.I think about a PD implementation:
-
catch abstraction opening
-
Dynamically insert a
[iemguts/closebang]
|
[iemguts/canvasname]
|
[send watchdog]
in every abstraction
Work in progress : FCPD a FreeCAD PureData connexion
-
-
while (xdotool search --name "window name"); do
sleep 0.1
done
echo 1Yes, this looks like "pinging" a window.
There might be a way to "catch" the OS' closing message, too?I think about a PD implementation:
sounds like an idea!?
Hard to tell the best way, without being into your specific environment and requirements. More ideas:
A scheduler in your python main loop
Or have a look at [hcs/tkconsole] and [hcs/sys_gui] with a deep dive into TCL / TK:tkwait window
destroy
winfo exists
maybe??
poll open windows:
winfo children .
-
@FFW Since you are using python you can probably use a module to communicate more directly. In linux you can most likely use the ewmh module to communicate directly with the window manager and there are certainly modules covering Windows and OSX and probably a module with some cross platform support.
-
Finally I do it at python side with PyQt5.QtCore.QFileSystemWatcher.
You can see the implementation here:
https://github.com/FlachyJoe/FCPDWorkbench/blob/f87a4e40ec3c4b4eb273c543a4664ad7aba63088/pdembeder.py#L41Thank you for all the ideas !
Work in progress : FCPD a FreeCAD PureData connexion