Skip to content

UBA Context Plugins

Eliran Wong edited this page Mar 7, 2021 · 12 revisions

TWO Types of Plugins

There are two different plugins in UBA, UBA plugins and UBA context plugins.

Read about UBA plugins at https://github.com/eliranwong/UniqueBible/wiki/UBA-Plugins

Below is description on UBA context plugins.

UBA Context Plugins

UBA context plugins are plugins used with right-click context menu.

A valid plugin file should be a python script with file extension ".py".

File Location

All UBA context plugins are placed in folder "plugins_context" inside UniqueBible home directory.

Enable Plugins

You need to enable this feature by checking "enablePlugins" on "Set Config Flags" window.

config.mainWindow

config.mainWindow points to the mainWindow of UBA.

config.pluginContext

The text selected by user before a right-click is assigned to config.pluginContext, with which plugin could process selected text.

config.contextSource

The widget where context menu is called from is pointed by config.contextSource, so developer can distinguish whether it is called from bible window or study window.

An example

A context plugin could be as simple as below, to display selected text in a dialog window.

import config

config.mainWindow.displayMessage(config.pluginContext)

Hide supporting files from context menu

You may have multiple files for a plugin and some of which are shared library files, which you do not want to display on context menu.

You can do this by placing them into a sub-folder. Python files placed inside a sub-folder within the directory "plugins" are not displayed on menu.

An example for reference: https://github.com/eliranwong/UniqueBible/wiki/UBA-Plugins#an-example---multiple-files

A Real Example

From version 22.39, with "enablePlugins" set to True, two context plugins, "Speak Hebrew" and "Speak Greek" are displayed on context menu like this screenshot.

You may check their code at:

https://github.com/eliranwong/UniqueBible/blob/master/plugins_context/Speak%20Hebrew.py

or

https://github.com/eliranwong/UniqueBible/blob/master/plugins_context/Speak%20Greek.py

Clone this wiki locally