How allow a plugin to save a startup setting

Hello, I am developing a plugin. One attribute my plugin has is an output directory. I want to save that value somewhere so that if you exit chimerax, come back in, and reload my plugin the output directory value will default to what it was during the last run, I've read a bit about session data and preference data and I don't think they get at what I want. I might be able to make my app save a data file in the installed plugin directory (and read it on startup) but maybe there will be things like permissions issues trying to do something like this. Any suggestions on how to do what I want to do?

Hi Barry, I think you do want to use a “Settings” object as referred to in the “Remember-able options” section of https://www.cgl.ucsf.edu/chimerax/docs/devel/tutorials/tutorial_tool_qt.html... . This could be part of a graphical use interface as described there, in which case you would use an InputFolderOption to get/show the value. But Settings can be used in non-graphical contexts as well. For instance, the Model Panel keeps track of how recently you’ve used the Model Panel (and therefore whether it will abbreviate the column header names) by using a Settings object with a ‘last_use’ attribute. Here’s a streamlined version of that code: from chimerax.core.settings import Settings class ModelPanelSettings(Settings): AUTO_SAVE = { ‘last_use’: None } settings = ModelPanelSettings(session, “Model Panel”) last = settings.last_use from time import time now = settings.last_use = time() short_titles = last != None and now - last < 777700 # about 3 months Settings are stored in a persistent user-writable area. --Eric Eric Pettersen UCSF Computer Graphics Lab
On Aug 28, 2023, at 1:06 PM, BARRY E DEZONIA via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hello,
I am developing a plugin. One attribute my plugin has is an output directory. I want to save that value somewhere so that if you exit chimerax, come back in, and reload my plugin the output directory value will default to what it was during the last run,
I've read a bit about session data and preference data and I don't think they get at what I want. I might be able to make my app save a data file in the installed plugin directory (and read it on startup) but maybe there will be things like permissions issues trying to do something like this.
Any suggestions on how to do what I want to do? _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu> To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu <mailto:chimerax-users-leave@cgl.ucsf.edu> Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
participants (2)
-
BARRY E DEZONIA
-
Eric Pettersen