def _on_keypress(event, dlg=dlg): # rebind to make sure this dlg is used from horizons.engine import pychan_util if event.getKey().getValue() == fife.Key.ESCAPE: # convention says use cancel action btn = dlg.findChild(name="cancelButton") callback = pychan_util.get_button_event(btn) if btn else None if callback: callback() else: # escape should hide the dialog default pychan.internal.get_manager().breakFromMainLoop(onPressEscape) dlg.hide() elif event.getKey().getValue() == fife.Key.ENTER: # convention says use ok action btn = dlg.findChild(name="okButton") callback = pychan_util.get_button_event(btn) if btn else None if callback: callback()
def _on_keypress(event, dlg=dlg): # rebind to make sure this dlg is used from horizons.engine import pychan_util if event.getKey().getValue() == fife.Key.ESCAPE: # convention says use cancel action btn = dlg.findChild(name=CancelButton.DEFAULT_NAME) callback = pychan_util.get_button_event(btn) if btn else None if callback: pychan.tools.applyOnlySuitable(callback, event=event, widget=btn) else: # escape should hide the dialog default pychan.internal.get_manager().breakFromMainLoop(returnValue=False) dlg.hide() elif event.getKey().getValue() == fife.Key.ENTER: # convention says use ok action btn = dlg.findChild(name=OkButton.DEFAULT_NAME) callback = pychan_util.get_button_event(btn) if btn else None if callback: pychan.tools.applyOnlySuitable(callback, event=event, widget=btn)
def _on_keypress(event, dlg=dlg): # rebind to make sure this dlg is used from horizons.engine import pychan_util if event.getKey().getValue() == fife.Key.ESCAPE: # convention says use cancel action btn = dlg.findChild(name=CancelButton.DEFAULT_NAME) callback = pychan_util.get_button_event(btn) if btn else None if callback: pychan.tools.applyOnlySuitable(callback, event=event, widget=btn) else: # escape should hide the dialog default horizons.globals.fife.pychanmanager.breakFromMainLoop(returnValue=False) dlg.hide() elif event.getKey().getValue() == fife.Key.ENTER: # convention says use ok action btn = dlg.findChild(name=OkButton.DEFAULT_NAME) callback = pychan_util.get_button_event(btn) if btn else None if callback: pychan.tools.applyOnlySuitable(callback, event=event, widget=btn)