¿ªÔÆÌåÓý

Locked Re: How to terminate python script


 

To close a window, you keep a reference to that window (i.e. called myFrame) and then do either:

myFrame.setVisible(False)
myFrame.dispose()

_or__

myFrame.dispatchEvent(java.awt.AWTEvent.WindowEvent(myFrame, java.awt.AWTEvent.WindowEvent.WINDOW_CLOSING))

(I haven¡¯t checked that these are exactly Jython syntax; they¡¯re copied from Java and adjusted) The first one is simpler, but doesn¡¯t __quite_ do exactly what the close button does. The second is exactly the same as clicking the button.

Bob

On Aug 14, 2018, at 12:53 PM, Fred Miller via Groups.Io <tractionfan@...> wrote:

I have a python script which runs a nice throttle. It builds a window with necessary buttons, etc. However I am trying to figure a way of closing the window (terminating the script) from within the script but in the same way as clicking on the red title bar close button. I have tried "exit()" but that closes down PanelPro altogether. I have tried "f.dispose()" as in one of the example scripts but since I have my script in a Class, I am apparently not getting the f.dispose() at the right level. within the code. I wanted to execute it from a defined function called from a button click.
--
Bob Jacobsen
rgj1927@...

Join [email protected] to automatically receive all group messages.