The lib module contains most of the components and libraries that make OpenLP work.

class openlp.core.lib.ImageSource[source]

Bases: object

This enumeration class represents different image sources. An image sources states where an image is used. This enumeration class is need in the context of the :class:~openlp.core.lib.imagemanager`.

This states that an image is being used by the image plugin.
This says, that the image is used by a theme.
This states that an image is being used by a command plugin.
CommandPlugins = 3
ImagePlugin = 1
Theme = 2
class openlp.core.lib.MediaType[source]

Bases: object

An enumeration class for types of media.

Audio = 1
Video = 2
class openlp.core.lib.ServiceItemAction[source]

Bases: object

Provides an enumeration for the required action moving between service items by left/right arrow keys

Next = 3
Previous = 1
PreviousLastSlide = 2
class openlp.core.lib.ServiceItemContext[source]

Bases: object

The context in which a Service Item is being generated

Live = 1
Preview = 0
Service = 2

Build a QIcon instance from an existing QIcon, a resource location, or a physical file location. If the icon is a QIcon instance, that icon is simply returned. If not, it builds a QIcon instance from the resource or file name.

Parameters:icon – The icon to build. This can be a QIcon, a resource string in the form :/resource/file.png, or a file location like /path/to/file.png. However, the recommended way is to specify a resource string.
Returns:The build icon.
openlp.core.lib.check_item_selected(list_widget, message)[source]

Check if a list item is selected so an action may be performed on it

  • list_widget – The list to check for selected items
  • message – The message to give the user if no item is selected
openlp.core.lib.clean_tags(text, remove_chords=False)[source]

Remove Tags from text for display

  • text – Text to be cleaned
  • remove_chords – Clean ChordPro tags
openlp.core.lib.compare_chord_lyric(chord, lyric)[source]

Compare the width of chord and lyrics. If chord width is greater than the lyric width the diff is returned.

  • chord
  • lyric


Returns a string that represents a join of a list of strings with a localized separator. Localized separation will be done via the translate() function by the translators.

Parameters:string_list – List of unicode strings
Returns:Formatted string
openlp.core.lib.create_thumb(image_path, thumb_path, return_icon=True, size=None)[source]

Create a thumbnail from the given image path and depending on return_icon it returns an icon from this thumb.

  • image_path – The image file to create the icon from.
  • thumb_path – The filename to save the thumbnail to.
  • return_icon – States if an icon should be build and returned from the thumb. Defaults to True.
  • size – Allows to state a own size (QtCore.QSize) to use. Defaults to None, which means that a default height of 88 is used.

The final icon.


Expand the chords in the line and align them using whitespaces. NOTE: There is equivalent javascript code in chords.js, in the updateSlide function. Make sure to update both!

Returns:The line with expanded html-chords

Expand ChordPro tags

openlp.core.lib.expand_chords_for_printing(text, line_split)[source]

Expand ChordPro tags

  • text
  • line_split
openlp.core.lib.expand_tags(text, expand_chord_tags=False, for_printing=False)[source]

Expand tags HTML for display

Parameters:text – The text to be expanded.
openlp.core.lib.find_formatting_tags(text, active_formatting_tags)[source]

Look for formatting tags in lyrics and adds/removes them to/from the given list. Returns the update list.

  • text
  • active_formatting_tags


Open a file and return its content as unicode string. If the supplied file name is not a file then the function returns False. If there is an error loading the file or the content can’t be decoded then the function will return None.

Parameters:text_file – The name of the file.
Returns:The file as a single string
openlp.core.lib.image_to_byte(image, base_64=True)[source]

Resize an image to fit on the current screen for the web and returns it as a byte stream.

  • image – The image to converted.
  • base_64 – If True returns the image as Base64 bytes, otherwise the image is returned as a byte array. To preserve original intention, this defaults to True
openlp.core.lib.resize_image(image_path, width, height, background='#000000')[source]

Resize an image to fit on the current screen.


  • image_path – The path to the image to resize.
  • width – The new image width.
  • height – The new image height.
  • background – The background colour. Defaults to black.

Convert a string version of a boolean into a real boolean.

Parameters:string_value – The string value to examine and convert to a boolean type.
Returns:The correct boolean value
openlp.core.lib.validate_thumb(file_path, thumb_path)[source]

Validates whether an file’s thumb still exists and if is up to date. Note, you must not call this function, before checking the existence of the file.

  • file_path – The path to the file. The file must exist!
  • thumb_path – The path to the thumb.

True, False if the image has changed since the thumb was created.