It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
I found two ways that I can close KLayout using python code, namely:
pya.Application.instance().main_window().close()
pya.Application.instance().exit(#)
but, ideally, I would like to prompt the "Save Needed" window, so I can check if the changes have been saved, before closing it.
Is there any way to prompt this window via python?
Chris
Comments
Hi Chris,
I think "pya.Application.instance().cm_exit()" will do the job. The "cm_..." functions are the actual functions bound to the respective menu entries ("File/Exit" in this case).
Matthias
Hi Matthias,
I get the following error when I run your suggested command:
I observed that sometimes, if there are unsaved changes, it prompts the "Save Needed" window when I run the pya.Application.instance().main_window().close() comand, but I haven't figured out when exactly it does it yet..
For example there are times where I create an empty layout, and then I'm trying to close KLayout with that command, without making any other changes, and that window pops up and times it doesn't.
As an other example, when I place an instance most of the times it pops up as it should, but there are times which it closes without the window being prompted.
Chris
Hi Chris,
sorry, I mistyped the command:
Matthias
Hi Matthias,
Yes, it seems more stable!
Thank you,
Chris