Originally shared by Marcus Wolschon I'm writing  asimple OctoPrint plugin.

Originally shared by Marcus Wolschon

I’m writing asimple @OctoPrint plugin.
I did everything as in the documentation
http://docs.octoprint.org/en/master/plugins/gettingstarted.html#settings-galore-how-to-make-parts-of-your-plugin-user-adjustable

However my user-adjustable settings page stays empty.
Can anyone have a look at these few lines of code?

https://github.com/MarcusWolschon/UltimateFilamentSensor/blob/master/Octoprint_Plugin/ultimate_filament_sensor/init.py#L52

You haven’t defined a settings page. The plugin tutorial at one point tells you to create a file templates/helloworld_settings.jinja2 with the settings controls to present to the user. In your repository there isn’t even a templates folder, so there is nothing that the settings dialogue could display on behalf of your plugin. Settings pages aren’t automatically generated based on your define defaults, you have to provide the HTML yourself.

The file structure is also suboptimal, the way you have things setup your plugin won’t be installable from github directly since the plugin’s setup.py and actual package are not on the root but in a sub folder “Octoprint_ Plugin”

You’re looking at the wrong directory.

The repository shall contain more then just the OctoPrint plugin but also the hardware designs and asembly instructions.
The OctoPrint plugin is in a subfolder and it does contain a template directory with a simple settings page.
https://github.com/MarcusWolschon/UltimateFilamentSensor/blob/master/Octoprint_Plugin/templates/ultimate_filament_sensor_settings.jinja2
The page has en entry in Octoprint but it displays empty.

Why shouldn’t it be possible to give a subdirectory for plugin installs?
After all, the plugin install procedure is not GitHub specific. It’s just a folder somwhere on the web.

The documentation doesn’t state what tags I can use to have text-input-fields, selection fields,… . (Labels I can probably do as plain HTML since the don’t have to be linked to any setting.)

I did not look at the wrong directory, you put the templates folder in the wrong directory. Please take another look at the tutorial and especially at the folder structure that is needed, there are snapshots of how things should look like for the very reason that the file structure is relevant.

And you can have your plugin in a subdirectory, but installing it directly from the zip archive that github generates automatically will not be possible this way (not due to how OctoPrint works but due to how python’s setuptools and pip work, which can’t install from some folder on the web but from some tarball or zip from the web, or even a git repo but not a sub folder therein), so you’ll need to provide a different zip, tarball or load your plugin to pypi to allow your users easy installation. If you were planning on distributing a separate archive anyhow or want your users to perform a manual install however, just ignore this.

I see.
Thanks a lot.
I didn’t notice that “templates” was not below setup.py but below the package directory that contains the actual plugin code.

Example:

I don’t want snapshot zip files of some half-finished git-master branch automatically generated.
So I’ll write a trivial shell script that produces zip-files for stable releases to upload as a “release” with a description and changelog. So that should work.

Maybe an error message should be logged if an expected template is not found instead of displaying an empty screen. Is that feasable?

Works great now!
I’ll have to look at some of the other plugins to find out how to format my settings and how to add the information about meassured remaining filament on the spool to the “status” block on the web-interface (and how to display nice graphical warning messages when you want to start a print with not enough filament left) but I guess I’ll figure out a way.