Config Fields¶
- npc.String(label, description='', default='', name=None)¶
A configuration field for one line string input
Changed in version 0.4.0: Added
labelparameter and madedescriptionoptional.- Parameters:
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 thenpc.BasePlugin.settingsdict.
- Returns:
- A field object which will be replaced by the value of the
setting on config initialization
- Return type:
- 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
labelparameter and madedescriptionoptional.Note
Available aliases:
Number- Parameters:
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 thenpc.BasePlugin.settingsdict.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:
- 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
labelparameter and madedescriptionoptional.- Parameters:
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 thenpc.BasePlugin.settingsdict.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:
- npc.Bool(label, description='', default=False, name=None)¶
A configuration field for a boolean checkbox
Changed in version 0.4.0: Added
labelparameter and madedescriptionoptional.Note
Available aliases:
Checkbox- Parameters:
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 thenpc.BasePlugin.settingsdict.
- Returns:
- A field object which will be replaced by the value of the
setting on config initialization
- Return type:
- 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
labelparameter and madedescriptionoptional.- Parameters:
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 thenpc.BasePlugin.settingsdict.
- Returns:
- A field object which will be replaced by the value of the
setting on config initialization
- Return type:
- npc.Dropdown(label, description='', options=[], default='', name=None)¶
A configuration field for a dropdown input
Changed in version 0.4.0: Added
labelparameter and madedescriptionoptional.- Parameters:
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 thenpc.BasePlugin.settingsdict.
- Returns:
- A field object which will be replaced by the value of the
setting on config initialization
- Return type:
- npc.TextView(label, description='', default='', name=None)¶
A configuration field for a multi-line text input
Changed in version 0.4.0: Added
labelparameter and madedescriptionoptional.- Parameters:
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 thenpc.BasePlugin.settingsdict.
- Returns:
- A field object which will be replaced by the value of the
setting on config initialization
- Return type:
- 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
labelparameter and madedescriptionoptional.- Parameters:
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 thenpc.BasePlugin.settingsdict.
- Returns:
- A field object which will be replaced by
the value of the setting on config initialization
- Return type:
- npc.File(label, description='', default='', chooser=FileChooser.FILE, name=None)¶
A configuration field for a file input
Will handle files as
pathlib.Pathobjects instead of strings.Added in version 0.3.0.
Changed in version 0.4.0: Added
labelparameter and madedescriptionoptional.- Parameters:
description (
str, optional) – The description of the setting. Defaults to “”.default (
str|pathlib.Path, optional) – The default value of the setting. Defaults to “”.file_chooser (
npc.types.FileChooser, optional) – The file chooser type. Defaults tonpc.types.FileChooser.FILE.name (
str, optional) – The name of the setting in thenpc.BasePlugin.settingsdict.
- Returns:
- A field object which will be replaced by the value of the
setting on config initialization
- Return type:
- npc.Folder(label, description='', default='', name=None)¶
A configuration field for a folder input
Will handle folders as
pathlib.Pathobjects instead of strings.Added in version 0.3.1: Quick alias for
File()withnpc.types.FileChooser.FOLDERChanged in version 0.4.0: Added
labelparameter and madedescriptionoptional.- Parameters:
description (
str, optional) – The description of the setting. Defaults to “”.default (
str|pathlib.Path, optional) – The default value of the setting. Defaults to “”.name (
str, optional) – The name of the setting in thenpc.BasePlugin.settingsdict.
- Returns:
- A field object which will be replaced by the value of the
setting on config initialization
- Return type:
- 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.Pathobjects instead of strings.Added in version 0.3.1: Quick alias for
File()withnpc.types.FileChooser.IMAGEChanged in version 0.4.0: Added
labelparameter and madedescriptionoptional.- Parameters:
description (
str, optional) – The description of the setting. Defaults to “”.default (
str|pathlib.Path, optional) – The default value of the setting. Defaults to “”.name (
str, optional) – The name of the setting in thenpc.BasePlugin.settingsdict.
- Returns:
- A field object which will be replaced by the value of the
setting on config initialization
- Return type:
- 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_valuefunction.Changed in version 0.4.0: Added
labelparameter and madedescriptionoptional.- Parameters:
default (
typing.Any) – The default value of the setting.type (
npc.types.SettingType) – The type of the setting.description (
str, optional) – The description of the setting.name (
str, optional) – The name of the setting in thenpc.BasePlugin.settingsdict. Does not need to be provided. By default it will use the variable name.to_value (
typing.Callable, optional) – A function to get the value of the setting.from_value (
typing.Callable, optional) – A function to set the value of the setting.**options (
typing.Any) – Additional options for the setting.
- name¶
The name of the setting in the
npc.BasePlugin.settingsdict.- Type:
- default¶
The default value of the setting.
- Type:
- type¶
The type of the setting.
- Type:
- options¶
Additional options for the setting.
- Type:
- 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:
- metasetting()¶
Convert the field to a metasetting
- Returns:
The metasetting generated from the field.
- Return type:
- 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:
- 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: