Better setting example#386
Merged
nriley merged 15 commits intoTalonCommunity:mainfrom Feb 7, 2026
Merged
Conversation
✅ Deploy Preview for talon-wiki-refactor ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
chdoc
reviewed
Jan 31, 2026
Contributor
chdoc
left a comment
There was a problem hiding this comment.
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. |
Contributor
There was a problem hiding this comment.
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. |
Contributor
Author
There was a problem hiding this comment.
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.
nriley
requested changes
Feb 7, 2026
nriley
requested changes
Feb 7, 2026
nriley
approved these changes
Feb 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #384. I decided to improve the surrounding documentation while I was here. Let me know if you want a different example.