Skip to main content

A higher-level Python API for ElGato's Stream Deck.

Project description

StreamDeckLayoutManager

GPL-v3.0 PyPI - Python Version PyPI - Version

A higher-level Python API for ElGato's Stream Deck.

This module is based off and uses streamdeck-elgato-python from Dean Camera.

Installation

StreamDeckLayoutManager is a pure Python project. It requires at least Python 3.8.

You can install StreamDeckLayoutManager by typing the following in a terminal window:

pip install StreamDeckLayoutManager

Usage

You can use StreamDeckLayoutManager in your own Python scripts like this:

import StreamDeckLayoutManager

streamdeck_manager = StreamDeckLayoutManager.Manager('StreamDeckConfig.toml')
streamdeck_manager.display_page('MyPageName')

In order to receive key press/release information, you need to hook up at least one callback:

streamdeck_manager.set_callback('MyCallbackName', callback_method)

Callback method will receive a List of arguments, as provided by the key configuration, minus the callback name:

def streamdeck_callback(arguments):
    # -- If the key's action is [ 'MyCallbackName', 'test', 42 ]
    # -- then arguments in this case will be [ 'test', 42 ]
    ...

Config file format

Config files are regular toml files. They have a general section named config:

[config]
Brightness = 90
AssetFolder = 'assets'
Font = 'Roboto-Regular.ttf'
FontSize = 11

AssetFolder is relative to the folder where the config file is found.

They also have entries for each page:

[MyPageName]
Key13Image = 'MyIcon.png'
Key13Label = 'My Label'
Key13PressedAction = [ 'MyCallbackName', 'test', 42 ]
Key13ReleasedAction = [ 'MyCallbackName', 'other_test' ]
...

The page contains numbered entries for each key from Key0 to Key14 (if you are using an original stream deck). Each entry lists the image to use, the text to display underneath the image and the callback to call when the key is pressed or when it is released.

Image path is relative to the asset folder provided in the config section.

Callback names such as push_page, pop_page and display_page are reserved and can be used to moved between pages, including creating folders

Key14Image = 'folder.png'
Key14Label = 'MyFolder'
Key14PressedAction = [ 'push_page', 'SamplePage1' ]

This callback will push the current page onto a stack and display the page SamplePage1.

Key14Image = 'back.png'
Key14Label = 'Go Back'
Key14PressedAction = [ 'pop_page' ]

This callback will pop the previous page from a stack and display it again.

Key9Image = 'other.png'
Key9Label = 'NextPage'
Key9PressedAction = [ 'display_page', 'SamplePage2' ]

This callback will simply display it the page SamplePage2. The page stack is unaffected and only the current page is modified.

StreamDeckLayoutManager.Manager class

Manager(config_file_path: str, deck_index: int = 0) -> None

Initialize a new manager for stream deck at index deck_index using the config file at config_file_path.

Manager.shutdown() -> None

Shuts down the manager.

Manager.display_page(page_name: str) -> None

Display page named page_name.

Manager.push_page(page_name: str) -> None

Push current page onto the stack and display page named page_name.

Manager.pop_page() -> None

Pop the previous page off the stack and display it.

Manager.set_key(page_name: str, key_index: int, image_file: Optional[str], label: Optional[str], pressed_callback: Optional[CallbackCall], released_callback: Optional[CallbackCall] = None) -> None

Set the key in page named page_name at index key_index to display image at image_file with label label. When key is pressed then pressed_callback is called, when the key is released then released_callback is called.

Image path is relative to the asset folder provided in the config section.

This can be used to set keys dynamically, as opposed to statically in the config file.

For example:

streamdeck_manager.set_key('MainPage', 12, 'MyImage.png', 'My Label',
                           StreamDeckLayoutManager.CallbackCall(['MyCallbackName', 'test_argument', 2]))
Manager.set_callback(self, callback_name: str, callback: Callable[[StreamDeckLayoutManager.CallbackCall], None]) -> None

Set the callback method for callback callback_name to the method callback.

Manager.number_of_stream_decks -> int

Return the number of stream decks found.

Manager.print_deck_info(self, index: int)

Prints diagnostic information about the stream deck at index index.

License

StreamDeckLayoutManager is distributed under the terms of the GPLv3.0 or later license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamdecklayoutmanager-4.1.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamdecklayoutmanager-4.1.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file streamdecklayoutmanager-4.1.0.tar.gz.

File metadata

File hashes

Hashes for streamdecklayoutmanager-4.1.0.tar.gz
Algorithm Hash digest
SHA256 09627e83399ba66f7c5a4b2cecac58e546e0a813de1a29fbd037beb153372c4c
MD5 778d201beeb570b377d4b5da3938001c
BLAKE2b-256 7b81d4327db1e9f95f5fb110c69ac99271e1d9e2e4647f51a1e0fdc853e64db0

See more details on using hashes here.

File details

Details for the file streamdecklayoutmanager-4.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamdecklayoutmanager-4.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2d4468dac85d1851c030607bb943ac427be42a2d77e6c1f1b6ee5048e43a5d5
MD5 17e4d5ff37fb55836895ce9b415365ff
BLAKE2b-256 213093434170a532a85b967f7b27b69e96c033ce527288a749f9883f70a6e1ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page