Config Fields

npc.String(label, description='', default='', name=None)

A configuration field for one line string input

Changed in version 0.4.0: Added label parameter and made description optional.

Parameters:
Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

str

npc.Int(label, description='', default=0, name=None, maximum=9999999, minimum=0, stepsize=1)

A configuration field for a integer input

Changed in version 0.4.0: Added label parameter and made description optional.

Note

Available aliases: Number

Parameters:
  • label (str) – The label of the setting.

  • description (str, optional) – The description of the setting. Defaults to “”.

  • default (str, optional) – The default value of the setting. Defaults to “”.

  • name (str, optional) – The name of the setting in the npc.BasePlugin.settings dict.

  • maximum (int, optional) – The maximum value of the setting. Defaults to 9999999.

  • minimum (int, optional) – The minimum value of the setting. Defaults to 0.

  • stepsize (int, optional) – The step size of the setting. Defaults to 1.

Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

int

npc.Number(label, description='', default=0, name=None, maximum=9999999, minimum=0, stepsize=1)

This is a test

npc.Float(label, description='', default=0.0, name=None, maximum=9999999.0, minimum=0.0, stepsize=0.1)

A configuration field for a float input

Changed in version 0.4.0: Added label parameter and made description optional.

Parameters:
  • label (str) – The label of the setting.

  • description (str, optional) – The description of the setting. Defaults to “”.

  • default (str, optional) – The default value of the setting. Defaults to “”.

  • name (str, optional) – The name of the setting in the npc.BasePlugin.settings dict.

  • maximum (float, optional) – The maximum value of the setting. Defaults to 9999999.0.

  • minimum (float, optional) – The minimum value of the setting. Defaults to 0.0.

  • stepsize (float, optional) – The step size of the setting. Defaults to 0.1.

Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

float

npc.Bool(label, description='', default=False, name=None)

A configuration field for a boolean checkbox

Changed in version 0.4.0: Added label parameter and made description optional.

Note

Available aliases: Checkbox

Parameters:
Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

bool

npc.Checkbox(label, description='', default=False, name=None)

Alias of npc.Bool()

npc.Radio(label, description='', options=[], default='', name=None)

A configuration field for a radio input

Changed in version 0.4.0: Added label parameter and made description optional.

Parameters:
Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

str

npc.Dropdown(label, description='', options=[], default='', name=None)

A configuration field for a dropdown input

Changed in version 0.4.0: Added label parameter and made description optional.

Parameters:
Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

str

npc.TextView(label, description='', default='', name=None)

A configuration field for a multi-line text input

Changed in version 0.4.0: Added label parameter and made description optional.

Note

Available aliases: Text, TextArea

Parameters:
Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

str

npc.Text(label, description='', default='', name=None)

Alias of npc.TextView()

npc.TextArea(label, description='', default='', name=None)

Alias of npc.TextView()

npc.ListString(label, description='', default=[], name=None)

A configuration field for managable list of strings input

Changed in version 0.4.0: Added label parameter and made description optional.

Parameters:
Returns:

A field object which will be replaced by

the value of the setting on config initialization

Return type:

list of str

npc.File(label, description='', default='', chooser=FileChooser.FILE, name=None)

A configuration field for a file input

Will handle files as pathlib.Path objects instead of strings.

Added in version 0.3.0.

Changed in version 0.4.0: Added label parameter and made description optional.

Parameters:
Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

pathlib.Path

npc.Folder(label, description='', default='', name=None)

A configuration field for a folder input

Will handle folders as pathlib.Path objects instead of strings.

Added in version 0.3.1: Quick alias for File() with npc.types.FileChooser.FOLDER

Changed in version 0.4.0: Added label parameter and made description optional.

Parameters:
Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

pathlib.Path

npc.Directory(label, description='', default='', name=None)

Alias of npc.Folder()

npc.Image(label, description='', default='', name=None)

A configuration field for an image input

Will handle images as pathlib.Path objects instead of strings.

Added in version 0.3.1: Quick alias for File() with npc.types.FileChooser.IMAGE

Changed in version 0.4.0: Added label parameter and made description optional.

Parameters:
Returns:

A field object which will be replaced by the value of the

setting on config initialization

Return type:

pathlib.Path

class npc.config.Field(label, default, type, description='', name=None, to_value=None, from_value=None, **options)

Base class for a configuration field

This class is used to define a configuration field for a plugin.

Changed in version 0.3.1: Removed plugin as a parameter for the from_value function.

Changed in version 0.4.0: Added label parameter and made description optional.

Parameters:
name

The name of the setting in the npc.BasePlugin.settings dict.

Type:

str

label

The label of the setting.

Type:

str

description

The description of the setting.

Type:

str

default

The default value of the setting.

Type:

typing.Any

type

The type of the setting.

Type:

npc.types.SettingType

options

Additional options for the setting.

Type:

typing.Any

to_value_func

A function to get the value of the setting.

Type:

typing.Callable, optional

from_value_func

A function to set the value of the setting.

Type:

typing.Callable, optional

property metasettings_description: str

Label for the settings dialog window

The metasettings do not have separate labels and descriptions. Thus we just combine them with a newline.

Added in version 0.4.0: Added property combining label and description

Returns:

The label of the setting.

Return type:

str

metasetting()

Convert the field to a metasetting

Returns:

The metasetting generated from the field.

Return type:

npc.types.MetaSetting

to_value(plugin)

Get the value of the setting

Parameters:

plugin (npc.BasePlugin) – The plugin instance that the setting is attached to.

Returns:

The value of the setting.

Return type:

typing.Any

from_value(value)

Set the value of the setting

Changed in version 0.3.1: Removed plugin as a parameter.

Parameters:

value (typing.Any) – The value to set the setting to.

Returns:

The value of the setting.

Return type:

typing.Any