SourceClass talon.Context
from talon import Contextclass ContextCreating a Context:
from talon import Context
ctx = Context()
Methods
action_class§
def action_class(self, path: str) -> Callable[[Class], ActionClassProxy]The following example shows how to override an action on a Context. To overwrite an action on a context object named ctx using an action class, write @ctx.action_class(prefix), where prefix is the prefix for the current namespace, such as “user” for the user. namespace.
@ctx.action_class('prefix')
class Actions:
def action_name():
print("Running actions.prefix.action_name()")
action§
def action(self, path: str)@ctx.action('prefix.action_name')
def action_name():
print("Running actions.prefix.action_name()")
capture§
def capture(self, path: str | None = None, *, rule: str | None = None) -> DecoratorTypeTo override a capture on a Context named ctx, write @ctx.capture(capture_name, rule=rule) where capture_name is the name of the capture to override and rule is the new capture rule. Example:
@ctx.capture('number', rule='(one | two)')
def number(m) -> int:
return 1 if m[0] == 'one' else 2
dynamic_list§
def dynamic_list(self, path: str) -> DecoratorType@ctx.dynamic_list('prefix.list_name')
def list_name(phrase: list[str]) -> Union[str, list[str], dict[str, str]]:
return ['word one', 'word two']
Properties
matches§
@property
def matches(self) -> str@matches.setter
def matches(self, matches: str)Describe when to activate this Context. If not specified, Context is always active.
ctx.matches = r"""
os: windows
app.name: Slack
"""
- Type:
str
apps§
@property
def apps(self)@apps.setter
def apps(self, value: Sequence[str])apps:
ctx.apps["chrome"] = r"""
os: windows
app.name: Google Chrome
"""
- Type:
str
selections§
@property
def selections(self) -> dict[str, str]@selections.setter
def selections(self, selections: dict[str, str]) -> Noneselections:
ctx.selections["user.listname"] = """
some text to use for a subset selection
"""
- Type:
dict[str, str]
lists§
@property
def lists(self) -> dict[str, Mapping[str, str]]@lists.setter
def lists(self, lists: dict[str, dict[str, str] | Sequence[str]]) -> Nonelists:
ctx.lists["user.listname"] = ["word", "word2"]
ctx.lists["user.listname"] = {
"pronunciation": "word",
}
- Type:
dict[str, Union[list[str], dict[str, str]]]
settings§
@property
def settings(self)@settings.setter
def settings(self, value: dict[str, SettingValue])settings:
ctx.settings = {
"input_wait": 1.0,
}
- Type:
dict[str, Any]
tags§
@property
def tags(self)@tags.setter
def tags(self, value: Sequence[str])tags:
ctx.tags = ["user.terminal"]
- Type:
frozenset[str]
commands§
@property
def commands(self) -> Mapping[str, CommandImpl]Return the commands defined by this Context
- Type:
dict[str, CommandImpl]
hotkeys§
@property
def hotkeys(self) -> Mapping[str, ScriptImpl]Return the hotkeys defined by this Context
- Type:
dict[str, ScriptImpl]
noises§
@property
def noises(self)