def test_closing(self): """Test that validation stops as soon as the event is rejected. """ manifest1 = ClosingContributor1() manifest2 = ClosingContributor2() self.workbench.register(manifest1) self.workbench.register(manifest2) window = FalseWindow(self.workbench) plugin = self.workbench.get_plugin('ecpy.app') ev = CloseEvent() plugin.validate_closing(window, ev) assert not ev.is_accepted() assert not manifest2.called or not manifest1.called manifest1.accept = True manifest2.accept = True plugin.validate_closing(window, ev) assert ev.is_accepted() assert manifest2.called
def test_closing(self): """ Test that validation stops as soon as the event is rejected. """ self.workbench.register(HqcAppManifest()) self.workbench.register(ClosingContributor1()) self.workbench.register(ClosingContributor2()) manifest1 = self.workbench.get_manifest('test.closing') manifest2 = self.workbench.get_manifest('test.closing2') window = Helper(self.workbench) plugin = self.workbench.get_plugin('hqc_meas.app') ev = CloseEvent() plugin.validate_closing(window, ev) assert_false(ev.is_accepted()) assert_false(manifest2.called) manifest1.accept = True manifest2.accept = True plugin.validate_closing(window, ev) assert_true(ev.is_accepted()) assert_true(manifest2.called) self.workbench.unregister(u'test.closing') self.workbench.unregister(u'hqc_meas.app')
def closeEvent(self, event): """ Handle the close event for the window. """ event.accept() if not self._proxy_ref: return proxy = self._proxy_ref() d = proxy.declaration d_event = CloseEvent() d.closing(d_event) if d_event.is_accepted(): deferredCall(finalize_close, d) else: event.ignore()
def closeEvent(self, event): """ Handle the close event for the dialog. """ event.accept() if not self._proxy_ref: return proxy = self._proxy_ref() d = proxy.declaration d_event = CloseEvent() d.closing(d_event) if d_event.is_accepted(): super(QWindowDialog, self).closeEvent(event) else: event.ignore()
def on_close(self, event): """ The event handler for the EVT_CLOSE event. """ d = self.declaration d_event = CloseEvent() d.closing(d_event) if d_event.is_accepted(): event.Skip() # Make sure the frame is not modal when closing, or no other # windows will be unblocked. self.widget.MakeModal(False) wx.CallAfter(finalize_close, d) else: event.Veto()
def validate_closing(self, window: Window, event: CloseEvent) -> None: """Run all closing checks to determine whether or not to close the app.""" for closing in self.closing.contributions.values(): closing.validate(window, event) if not event.is_accepted(): break