MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   Easier access to plugin prefs (https://www.mobileread.com/forums/showthread.php?t=291201)

slowsmile 10-12-2017 09:31 PM

Easier access to plugin prefs
 
Would it be possible to have a button in the Sigil toolbar which, when clicked, allows selection and display -- via dialog + Sigil tab -- of the selected plugin prefs .json file for editing. Apps like Sublime already have this facility for setting their own prefs.

This change would make it much easier for Sigil users to access and set plugin prefs(where applicable). Is this possible?

KevinH 10-12-2017 09:44 PM

The plugin code should be separate from the Sigil codebase to the extent possible. So I recommend plugin developers build a simple gui with pyqt or the built in python gui to handle editing their own prefs. We could create a canned generic module that should work the same for any plugin.

I do not think this role should be done by Sigil itself.

slowsmile 10-12-2017 09:56 PM

duplicate

slowsmile 10-12-2017 10:02 PM

duplicate

slowsmile 10-12-2017 10:09 PM

Thanks Kevin. I'll look into writing a plugin for this when I'm up to speed on PyQT. Can it be done in Tkinter or is tk usage now discouraged for plugins?

KevinH 10-12-2017 10:31 PM

Both tkinter and pyqt are supported and should continue to be for the forseeable future.

DiapDealer 10-12-2017 10:35 PM

I've no plans to remove tkinter at this time.

Many of my plugins include gui code (both tkinter and pyqt) to allow the user to edit the plugin's preferences if you're looking for examples.

slowsmile 10-13-2017 02:01 AM

Thanks for that, and I will have a peek at DiapDealer's pyqt examples for sure. I already have Winpython 3.4(with PyQT5 and Qt Designer) installed on my computer.

Doitsu 10-13-2017 03:52 AM

Quote:

Originally Posted by slowsmile (Post 3592985)
Would it be possible to have a button in the Sigil toolbar which, when clicked, allows selection and display -- via dialog + Sigil tab -- of the selected plugin prefs .json file for editing.

Ideally, plugin preferences should be updated via a GUI, unless they're advanced settings that rarely need to be changed.

BTW, users can easily access the plugin_prefs folder via:

Edit > Preferences > Open Preferences Location > plugins_prefs

Windows users can also access a specific preferences folder via the Windows Run dialog box. For example:
  1. Presss WIN+R.
  2. Copy and paste %LOCALAPPDATA%\sigil-ebook\sigil\plugins_prefs\OpenDocHTMLImport and hit Return.
This'll display the preferences folder for your OpenDocHTMLImport plugin.

AlanHK 10-19-2017 12:02 PM

Quote:

Originally Posted by Doitsu (Post 3593123)
Ideally, plugin preferences should be updated via a GUI, unless they're advanced settings that rarely need to be changed.

No even then. If you edit the json, changes will be lost if you upgrade the plugin; the new json just overwrites it.

DiapDealer 10-19-2017 12:14 PM

Quote:

Originally Posted by AlanHK (Post 3596792)
No even then. If you edit the json, changes will be lost if you upgrade the plugin; the new json just overwrites it.

No it doesn't. The plugin framework only creates the json file if one isn't already present. If individual settings within the json are being changed/reset when a plugin is updated, then that's on the plugin dev. My plugins' preferences will certainly persist through a plugin update--no matter how the json file gets edited. If they don't, then I need to know.

slowsmile 10-19-2017 08:47 PM

As DiapDealer says, the json file is not deleted when you update a plugin -- it is preserved in a separate plugin_prefs directory. If you want to reset plugin prefs to its default or initial settings then all you have to do is just delete the json file or delete its directory from plugin_prefs.

AlanHK 10-20-2017 01:38 AM

Quote:

Originally Posted by DiapDealer (Post 3596802)
No it doesn't. The plugin framework only creates the json file if one isn't already present.

I lost my settings when I updated the Kindlegen plugin.
Had to re-edit the json to change the default thumbnail size.
Unless I screwed up removing the older version first.

Doitsu 10-20-2017 02:43 AM

Quote:

Originally Posted by AlanHK (Post 3597119)
I lost my settings when I updated the Kindlegen plugin.

Older KindleGen versions used an .ini file whose settings were indeed lost when I switched to json-based preferences.

Quote:

Originally Posted by AlanHK (Post 3597119)
Had to re-edit the json to change the default thumbnail size.

The default thumbnail size was never a preference setting; changing it always required modifying plugin.py.

AlanHK 10-22-2017 02:42 PM

Quote:

Originally Posted by Doitsu (Post 3597130)
The default thumbnail size was never a preference setting; changing it always required modifying plugin.py.

Sorry; yes it was in plugin.py, not the json.


All times are GMT -4. The time now is 08:24 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.