abcminiuser / python-elgato-streamdeck

Python library to control the Elgato Stream Deck.
Other
898 stars 134 forks source link

Proposal: Button generator -- already implemented #67

Open naggie opened 3 years ago

naggie commented 3 years ago

Hi @abcminiuser / Dean, thank you for the library -- it's very nice to be able to have such control over a streamdeck. I've previously heard of you via LUFA so I was pleasantly surprised to learn you'd also made this library.

For my own use I've implemented a button generator with the following features:

Here's an example set of (randomly) generated icons:

image

On my streamdeck XL:

image

The library uses pillow to do all this, as well as the icon font version (TTF) of google material fonts, 4.0 which is GPL.

Is this something you'd like me to do a PR for? I was thinking it could be an ImageHelper.

Caveats:

This can be fixed in the PR or post-merge though I trust.

abcminiuser commented 3 years ago

Sure, I think it's something worth adding. Originally I just envisioned this being a simple wrapper over the backend HID transport with no use of any third party image libraries to keep things simple, but then realized that there's no point forcing everyone to re-invent the wheel if it just means using PIL.

As a result, I added the PIL image helpers over the top of the base code, so people can choose to either use it, or develop their own image management code. Your button generator is just an extension over the top of that, and as long as it doesn't prevent people from going their own route if they choose I think it's a great thing to have available in the base library.

I did a much simpler version in my own project a while back, but this looks much better.

It's probably worth some discussion on how to make it generic enough that people could use the same interface to do various other styles. Perhaps a base common button API for label, icon, state indicator etc. with some "styling" classes used to do the actual rendering, so library users could pick the overall styling they want (e.g. "metro-like", "basic").

naggie commented 3 years ago

Sure, I think it's something worth adding.

Great, I shall do a PR as soon as I get an hour spare.

As a result, I added the PIL image helpers over the top of the base code, so people can choose to either use it, or develop their own image management code. Your button generator is just an extension over the top of that, and as long as it doesn't prevent people from going their own route if they choose I think it's a great thing to have available in the base library.

Yes my thoughts too -- just a quick generator that can be used or not.

I did a much simpler version in my own project a while back, but this looks much better.

Cool, that looks good. That's similar to what I've done with mine too.

t's probably worth some discussion on how to make it generic enough that people could use the same interface to do various other styles. Perhaps a base common button API for label, icon, state indicator etc. with some "styling" classes used to do the actual rendering, so library users could pick the overall styling they want (e.g. "metro-like", "basic").

Yes that's worth a thought. I'd suggest exposing this as a particular style but then using the layout functions I made to enable other styles. It's implemented as a function that takes a deck with colour + optional message + icon name. The icon/text/indicator renderer is separated too.

Thanks for checking it out, I'll make a PR soon.

Callan