Fred,
toggle quoted message
Show quoted text
Here is my take. import java import javax.swing import jarray import jmri class TestA(jmri.jmrit.automat.AbstractAutomaton) : def doClose(self, event): print("Close") # **** close command here **** self.f.setVisible(False) self.f.dispose() self.stop() def setup(self): print "Setup" self.f = javax.swing.JFrame("TEST",preferredSize = (200,80)) self.f.contentPane.setLayout(javax.swing.BoxLayout(self.f.contentPane,javax.swing.BoxLayout.Y_AXIS)) self.f.setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE) self.f.setLocationRelativeTo(None) relButton = javax.swing.JButton("CLOSE WINDOW") relButton.actionPerformed = self.doClose panel1 = javax.swing.JPanel(preferredSize = (170,30)) panel1.add(relButton) self.f.contentPane.add(panel1) self.f.pack() self.f.show() self.start() return def handle(self): self.waitMsec(10000) print "loop" return True a = TestA() a.setName("TestA Code") a.setup() Since this thread is about terminating a script, I included the stop() call. I also changed the ON CLOSE to do nothing instead of DISPOSE. Otherwise the script keeps running without a window, which might be appropriate in some cases. Since this class is an AbstractAutomaton, I added the handle() method so that stop() does not create an error. Dave Sand On Aug 15, 2018, at 9:14 AM, Fred Miller via Groups.Io <tractionfan@...> wrote: |