Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Prompt "Save Needed" window


I found two ways that I can close KLayout using python code, namely:


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?



  • 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).


  • Hi Matthias,

    I get the following error when I run your suggested command:

    Attribute cm_exit not found (tried lookup as a child widget)

    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.


  • Hi Chris,

    sorry, I mistyped the command:



  • Hi Matthias,

    Yes, it seems more stable!

    Thank you,

Sign In or Register to comment.