Events

Provides a signals-like system for sending and listening for ‘events’

Events are kind of like signals, except they may be listened for on a global scale, rather than connected on a per-object basis like signals are. This means that ANY object can emit ANY event, and these events may be listened for by ANY object.

Events should be emitted AFTER the given event has taken place. Often the most appropriate spot is immediately before a return statement.

xl.event.log_event(evty, obj, data)[source]

Sends an event.

Parameters:
  • evty (string) – the type or name of the event.
  • obj (object) – the object sending the event.
  • data (object) – some data about the event, None if not required
xl.event.add_callback(function, evty=None, obj=None, *args, **kwargs)[source]

Adds a callback to an event

You should ALWAYS specify one of the two options on what to listen for. While not forbidden to listen to all events, doing so will cause your callback to be called very frequently, and possibly may cause slowness within the player itself.

Parameters:
  • function (callable) – the function to call when the event happens
  • evty (string) – the type or name of the event to listen for, eg tracks_added, cover_changed. Defaults to any event if not specified.
  • obj (object) – the object to listen to events from, e.g. exaile.collection or xl.covers.MANAGER. Defaults to any object if not specified.
  • destroy_with – (keyword arg only) If specified, this event will be detached when the specified Gtk widget is destroyed

Any additional parameters will be passed to the callback.

Returns:a convenience function that you can call to remove the callback.
xl.event.remove_callback(function, evty=None, obj=None)[source]

Removes a callback. Can remove both ui and non-ui callbacks.

The parameters passed should match those that were passed when adding the callback