Hooks specification

The pibooth application provide a decorator to implement specific hooks. Each hook have to be decorated has follow:

import pibooth

@pibooth.hookimpl
def pibooth_configure(cfg):
    ...

Note

Hooks specification defines all arguments that can be used by the hook implementation. But there is no need to put in the hook signature the arguments that are not used in the code.

pibooth_configure(cfg)[source]

Actions performed after loading of the configuration file or when the plugin is enabled for the first time. The cfg object is an instance of ConfigParser class.

Parameters:

cfg – application configuration

pibooth_reset(cfg, hard)[source]

Restore the configuration.

This hook is called at least one time at pibooth startup with parameter hard=False. All plugins implementing this hook shall ensure that the required folders/files exist (create the default ones if not).

If hard=True, all folders/files have to be restored with their default content.

Parameters:
  • cfg – application configuration

  • hard – do a hard-reset if True

pibooth_startup(cfg, app)[source]

Actions performed at the startup of pibooth or when the plugin is enabled for the first time.

Parameters:
  • cfg – application configuration

  • app – application instance

pibooth_setup_picture_factory(cfg, opt_index, factory)[source]

Hook used to setup the PictureFactory instance.

The opt_index is the selected index of the [PICTURE][captures] configuration option for the current captures sequence. It represents the selected captures number.

A new PictureFactory instance can be returned by this hook, it will be used instead of the default one. The returned object shall have the same public API than pibooth.pictures.factory.PictureFactory.

Parameters:
  • cfg – application configuration

  • opt_index – index for tuple options related to captures number

  • factory – default PictureFactory instance (not configured yet)

pibooth_setup_camera(cfg)[source]

Hook used to setup the camera interface.

A new camera instance (inheriting from pibooth.camera.base.BaseCamera) shall be returned by this hook, it will be used instead of the default one.

Parameters:

cfg – application configuration

pibooth_cleanup(app)[source]

Actions performed at the cleanup of pibooth.

Parameters:

app – application instance

state_failsafe_enter(cfg, app, win)[source]

Actions performed when application enter in FailSafe state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_failsafe_do(cfg, app, win, events)[source]

Actions performed when application is in FailSafe state. This hook is called in a loop until the application can switch to the next state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_failsafe_validate(cfg, app, win, events)[source]

Return the next state name if application can switch to it else return None.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_failsafe_exit(cfg, app, win)[source]

Actions performed when application exit FailSafe state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_wait_enter(cfg, app, win)[source]

Actions performed when application enter in Wait state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_wait_do(cfg, app, win, events)[source]

Actions performed when application is in Wait state. This hook is called in a loop until the application can switch to the next state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_wait_validate(cfg, app, win, events)[source]

Return the next state name if application can switch to it else return None.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_wait_exit(cfg, app, win)[source]

Actions performed when application exit Wait state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_choose_enter(cfg, app, win)[source]

Actions performed when application enter in Choose state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_choose_do(cfg, app, win, events)[source]

Actions performed when application is in Choose state. This hook is called in a loop until the application can switch to the next state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_choose_validate(cfg, app, win, events)[source]

Return the next state name if application can switch to it else return None.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_choose_exit(cfg, app, win)[source]

Actions performed when application exit Choose state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_chosen_enter(cfg, app, win)[source]

Actions performed when application enter in Chosen state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_chosen_do(cfg, app, win, events)[source]

Actions performed when application is in Chosen state. This hook is called in a loop until the application can switch to the next state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_chosen_validate(cfg, app, win, events)[source]

Return the next state name if application can switch to it else return None.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_chosen_exit(cfg, app, win)[source]

Actions performed when application exit Chosen state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_preview_enter(cfg, app, win)[source]

Actions performed when application enter in Preview state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_preview_do(cfg, app, win, events)[source]

Actions performed when application is in Preview state. This hook is called in a loop until the application can switch to the next state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_preview_validate(cfg, app, win, events)[source]

Return the next state name if application can switch to it else return None.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_preview_exit(cfg, app, win)[source]

Actions performed when application exit Preview state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_capture_enter(cfg, app, win)[source]

Actions performed when application enter in Capture state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_capture_do(cfg, app, win, events)[source]

Actions performed when application is in Capture state. This hook is called in a loop until the application can switch to the next state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_capture_validate(cfg, app, win, events)[source]

Return the next state name if application can switch to it else return None.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_capture_exit(cfg, app, win)[source]

Actions performed when application exit Capture state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_processing_enter(cfg, app, win)[source]

Actions performed when application enter in Processing state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_processing_do(cfg, app, win, events)[source]

Actions performed when application is in Processing state. This hook is called in a loop until the application can switch to the next state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_processing_validate(cfg, app, win, events)[source]

Return the next state name if application can switch to it else return None.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_processing_exit(cfg, app, win)[source]

Actions performed when application exit Processing state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_print_enter(cfg, app, win)[source]

Actions performed when application enter in Print state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_print_do(cfg, app, win, events)[source]

Actions performed when application is in Print state. This hook is called in a loop until the application can switch to the next state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_print_validate(cfg, app, win, events)[source]

Return the next state name if application can switch to it else return None.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_print_exit(cfg, app, win)[source]

Actions performed when application exit Print state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_finish_enter(cfg, app, win)[source]

Actions performed when application enter in Finish state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

state_finish_do(cfg, app, win, events)[source]

Actions performed when application is in Finish state. This hook is called in a loop until the application can switch to the next state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_finish_validate(cfg, app, win, events)[source]

Return the next state name if application can switch to it else return None.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance

  • events – pygame events generated since last call

state_finish_exit(cfg, app, win)[source]

Actions performed when application exit Finish state.

Parameters:
  • cfg – application configuration

  • app – application instance

  • win – graphical window instance