Skip to content

Commit e698100

Browse files
authored
Merge pull request #10 from gri-gus/feature/1.0.0
1.0.0 Added support for the setTriggerDescription event; Transition to pydantic==2.8.2; Transition to websockets==13.0.1; Added Debug mode; Added base project; Added commands for creating a basic project and building a plugin; The project structure has been changed; Added documentation for event methods and pydantic event models; Added support for Stream Deck application versions 6.3, 6.4, 6.5, 6.6; Added usage example to README.md; Added README.ru.md in Russian; The interfaces of some methods for sending messages have changed, they have become simpler.
2 parents 9d116a9 + 317e8ae commit e698100

File tree

84 files changed

+3083
-983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3083
-983
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include streamdeck_sdk *

README-PYPI.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<p align="center">
2+
<a>
3+
<img src="https://raw.githubusercontent.com/gri-gus/streamdeck-python-sdk/main/assets/images/cover.png" alt="streamdeck-python-sdk">
4+
</a>
5+
</p>
6+
7+
<p align="center">
8+
<a href="https://pypi.org/project/streamdeck-sdk" target="_blank">
9+
<img src="https://img.shields.io/pypi/v/streamdeck-sdk" alt="PyPI">
10+
</a>
11+
<a href="https://pypi.org/project/streamdeck-sdk" target="_blank">
12+
<img src="https://static.pepy.tech/badge/streamdeck-sdk" alt="PyPI">
13+
</a>
14+
<a href="https://opensource.org/licenses/Apache-2.0" target="_blank">
15+
<img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="Apache">
16+
</a>
17+
<a href="https://docs.elgato.com/sdk" target="_blank">
18+
<img src="https://badgen.net/badge/Elgato/doc/blue" alt="Elgato">
19+
</a>
20+
</p>
21+
22+
<p align="center">
23+
<a href="https://github.com/gri-gus/streamdeck-python-sdk" target="_blank">
24+
<img src="https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white" alt="GitHub">
25+
</a>
26+
</p>
27+
28+
# streamdeck-python-sdk
29+
30+
Library for creating Stream Deck plugins in Python.
31+
32+
**Supported operating systems:**
33+
34+
* MacOS: 10.14 or later
35+
* Windows: 10 or later
36+
37+
**Supported Python versions:** 3.8 or later
38+
39+
## Features
40+
41+
* Ease of use. You can quickly create your own plugin without having to understand how websockets and
42+
other technologies work.
43+
* Fully typed, using [pydantic](https://github.com/pydantic/pydantic).
44+
* Includes image to base64 converters for easy installation of icons on keys.
45+
* Includes a decorator for functions and methods to run on a separate thread.
46+
* Exception logging and easy logging configuration.
47+
* Debug mode via `PyCharm` or other debugging tools.
48+
* A complete protocol for interaction with the Stream Deck application has been implemented.
49+
* Quick start of a project via the console command `streamdeck_sdk startproject`.
50+
* Build the project using the `streamdeck_sdk build` console command.
51+
52+
## Examples
53+
54+
[LoremFlickr](https://github.com/gri-gus/loremflickr-streamdeck-plugin) - Plugin for installing images on a button from
55+
the LoremFlickr site. Supports MacOS and Windows.
56+
57+
---
58+
59+
See full description and usage examples on
60+
[GitHub](https://github.com/gri-gus/streamdeck-python-sdk)

README.md

Lines changed: 103 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
</a>
2020
</p>
2121

22+
<p align="center">
23+
<a href="https://github.com/gri-gus/streamdeck-python-sdk/blob/main/README.md" target="_blank">
24+
<img src="https://img.shields.io/badge/lang-en-yellow.svg" alt="lang-ru">
25+
</a>
26+
<a href="https://github.com/gri-gus/streamdeck-python-sdk/blob/main/README.ru.md" target="_blank">
27+
<img src="https://img.shields.io/badge/lang-ru-yellow.svg" alt="lang-ru">
28+
</a>
29+
</p>
30+
2231
# streamdeck-python-sdk
2332

2433
Library for creating Stream Deck plugins in Python.
@@ -30,9 +39,9 @@ Library for creating Stream Deck plugins in Python.
3039
* MacOS: 10.14 or later
3140
* Windows: 10 or later
3241

33-
**Supported Stream Deck application:** 6.0, 6.1, 6.2
42+
**Supported Stream Deck versions:** 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6
3443

35-
**Supported Python:** 3.7 or later
44+
**Supported Python versions:** 3.8 or later
3645

3746
## Installation
3847

@@ -48,18 +57,94 @@ pip install streamdeck_sdk
4857

4958
## Features
5059

51-
* Easy use. You can quickly create your own plugin without having to understand how websockets and other complicated
52-
things work.
60+
* Ease of use. You can quickly create your own plugin without having to understand how websockets and
61+
other technologies work.
5362
* Fully typed, using [pydantic](https://github.com/pydantic/pydantic).
5463
* Includes image to base64 converters for easy installation of icons on keys.
5564
* Includes a decorator for functions and methods to run on a separate thread.
5665
* Exception logging and easy logging configuration.
66+
* Debug mode via `PyCharm` or other debugging tools.
67+
* A complete protocol for interaction with the Stream Deck application has been implemented.
68+
* Quick start of a project via the console command `streamdeck_sdk startproject`.
69+
* Build the project using the `streamdeck_sdk build` console command.
5770

58-
## How to use Documentation if it is not written?
71+
## Quick Start
72+
73+
1. Install Python.
74+
2. Create a project folder and `venv`.
75+
3. Go to the project folder, activate `venv` and install the `streamdeck-sdk` library:
76+
77+
```shell
78+
pip install streamdeck-sdk
79+
```
80+
81+
4. Run the command to start the project:
82+
83+
```shell
84+
streamdeck_sdk startproject
85+
```
86+
87+
After completing this step, the folder `com.bestdeveloper.mytestplugin.sdPlugin` will appear with a test project and
88+
files for build.
89+
90+
5. Build the plugin using the command:
91+
92+
```shell
93+
streamdeck_sdk build -i com.bestdeveloper.mytestplugin.sdPlugin
94+
```
5995

60-
> 🧑‍💻 Documentation under development
96+
6. Install the `releases/{date}/com.bestdeveloper.mytestplugin.streamDeckPlugin` plugin into the Stream Deck
97+
application. Usually installed via double click.
6198

62-
> To get started, take a look at the Examples of plugins below, then move on to this section.
99+
> ⚠️ After installation, you need to wait about 40 seconds. At this time, requirements are installed.
100+
101+
7. Go to the Stream Deck application in the `MyTestCategory` category and set the `My action` action to any button.
102+
8. Check the operation of the `My action` action.
103+
When clicked, the following happens:
104+
1. The github page opens.
105+
2. ✅ appears on the button.
106+
107+
Next, edit the project in accordance with the official documentation [Stream Deck SDK](https://docs.elgato.com/sdk).
108+
> ⚠️ Don't forget to edit the `manifest.json` file and the plugin name.
109+
110+
## Debug mode
111+
112+
1. Follow steps 1-4 from the "Quick Start" section.
113+
2. In the file `com.bestdeveloper.mytestplugin.sdPlugin/code/main.py`
114+
in the StreamDeck parameters, specify `debug=True`, as in the example:
115+
116+
```python
117+
if __name__ == '__main__':
118+
StreamDeck(
119+
actions=[
120+
MyAction(),
121+
],
122+
debug=True,
123+
log_file=settings.LOG_FILE_PATH,
124+
log_level=settings.LOG_LEVEL,
125+
log_backup_count=1,
126+
).run()
127+
```
128+
129+
3. Follow steps 5-7 from the "Quick Start" section.
130+
4. Place a breakpoint where you are interested in `PyCharm`.
131+
For example, on the line:
132+
133+
```python
134+
self.open_url("https://github.com/gri-gus/streamdeck-python-sdk")
135+
```
136+
137+
5. Run the file `com.bestdeveloper.mytestplugin.sdPlugin/code/main.py` in Debug mode in `PyCharm`.
138+
139+
> ⚠️ If you run only the plugin in the Stream Deck application, there will be no reaction to pressing the button.
140+
141+
6. Click the button on Stream Deck. The code execution will stop at the line from point 4.
142+
143+
> ⚠️ Don't forget to set `debug=False` when building the finished plugin.
144+
145+
## Understanding usage
146+
147+
> To get started, check out the sample plugins below, then continue on to this section.
63148
64149
Let's look at an example of how the `self.send_to_property_inspector` method works.
65150

@@ -71,9 +156,7 @@ calling `self.send_to_property_inspector`: [click](https://docs.elgato.com/sdk/p
71156
Here is the resulting object in the Property inspector when
72157
calling `self.send_to_property_inspector`: [click](https://docs.elgato.com/sdk/plugins/events-received#sendtopropertyinspector)
73158

74-
Here is the method source code for
75-
the [self.send_to_property_inspector](https://github.com/gri-gus/streamdeck-python-sdk/blob/27652ed919cb85b94e91258487a2d2aba6087466/src/streamdeck_sdk/mixins.py#L177)
76-
method:
159+
Here is the source code for the method `self.send_to_property_inspector` method:
77160

78161
```python
79162
def send_to_property_inspector(
@@ -90,8 +173,7 @@ def send_to_property_inspector(
90173
self.send(message)
91174
```
92175

93-
As we can see, it accepts function parameters and transfers them to the
94-
object [events_sent_objs.SendToPropertyInspector](https://github.com/gri-gus/streamdeck-python-sdk/blob/27652ed919cb85b94e91258487a2d2aba6087466/src/streamdeck_sdk/sd_objs/events_sent_objs.py#L121 ):
176+
As we can see, it takes function parameters and passes them to the object `events_sent_objs.SendToPropertyInspector`:
95177

96178
```python
97179
class SendToPropertyInspector(BaseModel):
@@ -101,20 +183,18 @@ class SendToPropertyInspector(BaseModel):
101183
event: str = "sendToPropertyInspector"
102184
```
103185

104-
Next in the
105-
method [self.send](https://github.com/gri-gus/streamdeck-python-sdk/blob/27652ed919cb85b94e91258487a2d2aba6087466/src/streamdeck_sdk/mixins.py#L16)
106-
the pydantic object is converted to json and sent to Property Inspector.
186+
Next, in the `self.send` method, the pydantic object is converted to json and sent to the plugin’s Property Inspector.
107187

108188
**What is `payload`?**
109189

110-
It's any `dict` you want. But there is a condition, it must be convertible to json.
190+
This is any `dict` that can be converted to json.
111191

112-
**How Property inspector does receive payload data?**
192+
**How does Property Inspector get data from `payload`?**
113193

114194
To answer this question, you need to look at the source
115-
code [streamdeck-javascript-sdk](https://github.com/elgatosf/streamdeck-javascript-sdk). As I understand, in their sdk
116-
there is a
117-
method [onSendToPropertyInspector](https://github.com/elgatosf/streamdeck-javascript-sdk/blob/7d2ba3ce41620dbb6c2f2a69a158224f6d95ef22/js/property-inspector.js#L20)
195+
code [streamdeck-javascript-sdk](https://github.com/elgatosf/streamdeck-javascript-sdk).
196+
There is a method in the sdk
197+
[onSendToPropertyInspector](https://github.com/elgatosf/streamdeck-javascript-sdk/blob/7d2ba3ce41620dbb6c2f2a69a158224f6d95ef22/js/property-inspector.js#L20)
118198
and most likely it should be used like this:
119199

120200
```js
@@ -124,11 +204,9 @@ $PI.onSendToPropertyInspector("com.ggusev.keyboard.write", jsn => {
124204
});
125205
```
126206

127-
Instead of `"com.ggusev.keyboard.write"` you need to substitute the name of your action.
207+
Instead of `"com.ggusev.keyboard.write"` you need to substitute the name of your `action`.
128208

129209
## Examples
130210

131-
[LoremFlickr](https://github.com/gri-gus/loremflickr-streamdeck-plugin) - Plugin for installing images from LoremFlickr
132-
to button. Supports MacOS and Windows.
133-
134-
---
211+
[LoremFlickr](https://github.com/gri-gus/loremflickr-streamdeck-plugin) - Plugin for installing images on a button from
212+
the LoremFlickr site. Supports MacOS and Windows.

0 commit comments

Comments
 (0)