Skip to content

Better setting example#386

Merged
nriley merged 15 commits intoTalonCommunity:mainfrom
FireChickenProductivity:better-setting-example
Feb 7, 2026
Merged

Better setting example#386
nriley merged 15 commits intoTalonCommunity:mainfrom
FireChickenProductivity:better-setting-example

Conversation

@FireChickenProductivity
Copy link
Copy Markdown
Contributor

Closes #384. I decided to improve the surrounding documentation while I was here. Let me know if you want a different example.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 31, 2026

Deploy Preview for talon-wiki-refactor ready!

Name Link
🔨 Latest commit 220a014
🔍 Latest deploy log https://app.netlify.com/projects/talon-wiki-refactor/deploys/69877e8b059e290008f39866
😎 Deploy Preview https://deploy-preview-386--talon-wiki-refactor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@FireChickenProductivity FireChickenProductivity marked this pull request as ready for review January 31, 2026 03:51
Copy link
Copy Markdown
Contributor

@chdoc chdoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to be more explicit about what goes wrong if one tries to store setting values in global variables. Otherwise, I think this is a good change.

Settings allow you to control some of the parameters of your Python files by changing their value in a .talon file. This can be used to make a Talon user file set easier to customize for end users, such as exposing the background color of a UI element. It can also be useful to have certain settings change when the context changes, by setting them to different values in different .talon files.

Settings are defined on Modules. Each setting has a name, type, default value, and description. The following example shows how to define a setting in python and get its contextually dependent value.
Settings are defined on Modules by calling a Module's `.setting()` method. Each setting has a name, type, default value, and description. A setting can be accessed from Python by calling `settings.get()` with the setting name as the argument. The following example shows how to define a setting in Python and get its contextually dependent value. If you are using Community and Python is the active programming language, you can use the command `snip module setting` to define a setting. Python code accessing settings should only be invoked through a function registered to be called by Talon or an action because accessing a setting through top level Python code has inconsistent behavior.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Settings are defined on Modules by calling a Module's `.setting()` method. Each setting has a name, type, default value, and description. A setting can be accessed from Python by calling `settings.get()` with the setting name as the argument. The following example shows how to define a setting in Python and get its contextually dependent value. If you are using Community and Python is the active programming language, you can use the command `snip module setting` to define a setting. Python code accessing settings should only be invoked through a function registered to be called by Talon or an action because accessing a setting through top level Python code has inconsistent behavior.
Settings are defined on Modules by calling a Module's `.setting()` method. Each setting has a name, type, default value, and description. A settings value can be obtained from Python by calling `settings.get()` with the setting name as the argument. The following example shows how to define a setting in Python and get its context-dependent value. If you are using Community and Python is the active programming language, you can use the command `snip module setting` to define a setting. Since settings are not yet defined during startup and can change depending on the context (see below), setting values should never be stored in global variables and instead be obtained directly inside the functions that need them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to improve the wording in response to your suggestions, but I wanted to provide more accurate information. Storing setting values in global variables can make sense in some contexts, such as detecting if a setting changed from the last time an action was called.

Copy link
Copy Markdown
Contributor

@chdoc chdoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread docs/Customization/Talon Framework/settings.md Outdated
Comment thread docs/Customization/Talon Framework/settings.md Outdated
Comment thread docs/Customization/Talon Framework/settings.md Outdated
Comment thread docs/Customization/Talon Framework/settings.md Outdated
Comment thread docs/Customization/Talon Framework/settings.md Outdated
Comment thread docs/Customization/Talon Framework/settings.md Outdated
Comment thread docs/Customization/Talon Framework/settings.md Outdated
Comment thread docs/Customization/Talon Framework/settings.md Outdated
Comment thread docs/Customization/Talon Framework/settings.md Outdated
Comment thread docs/Customization/Talon Framework/settings.md Outdated
@nriley nriley merged commit 019226b into TalonCommunity:main Feb 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve settings documentation example: remove top level setting access

3 participants