-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpixeval_extension_host.py
More file actions
161 lines (117 loc) · 3.54 KB
/
Copy pathpixeval_extension_host.py
File metadata and controls
161 lines (117 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
from __future__ import annotations
from collections.abc import Sequence
import pixeval_extensions.abi as abi
from pixeval_extensions import (
BoolSettingsExtension,
ExtensionsHostBase,
IntSettingsExtension,
StringSettingsExtension,
Symbol,
read_icon,
)
class DemoBoolSetting(BoolSettingsExtension):
def __init__(self) -> None:
self.value = self.default_value
super().__init__()
@property
def icon(self) -> Symbol:
return Symbol.ToggleRight
@property
def label(self) -> str:
return "Python Demo Enabled"
@property
def description(self) -> str:
return "Turns the Python demo setting on or off."
@property
def token(self) -> str:
return "python.demo.enabled"
@property
def default_value(self) -> bool:
return True
def on_value_changed(self, value: bool) -> None:
self.value = value
class DemoIntSetting(IntSettingsExtension):
def __init__(self) -> None:
self.value = self.default_value
super().__init__()
@property
def icon(self) -> Symbol:
return Symbol.NumberSymbol
@property
def label(self) -> str:
return "Python Demo Level"
@property
def description(self) -> str:
return "Integer setting sample from the Python SDK."
@property
def token(self) -> str:
return "python.demo.level"
@property
def placeholder(self) -> str | None:
return "0 - 10"
@property
def default_value(self) -> int:
return 3
@property
def min_value(self) -> int:
return 0
@property
def max_value(self) -> int:
return 10
def on_value_changed(self, value: int) -> None:
self.value = value
class DemoStringSetting(StringSettingsExtension):
def __init__(self) -> None:
self.value = self.default_value
super().__init__()
@property
def icon(self) -> Symbol:
return Symbol.Text
@property
def label(self) -> str:
return "Python Demo Nickname"
@property
def description(self) -> str:
return "String setting sample from the Python SDK."
@property
def token(self) -> str:
return "python.demo.nickname"
@property
def placeholder(self) -> str | None:
return "Enter a nickname"
@property
def default_value(self) -> str:
return "Pixeval Python Demo"
def on_value_changed(self, value: str) -> None:
self.value = value
class DemoHost(ExtensionsHostBase):
def __init__(self) -> None:
self._extensions = [DemoBoolSetting(), DemoIntSetting(), DemoStringSetting()]
super().__init__()
@property
def extension_name(self) -> str:
return "Pixeval Python SDK Demo"
@property
def author_name(self) -> str:
return "Pixeval.Extensions Python SDK"
@property
def extension_link(self) -> str:
return "https://github.com/Pixeval/Pixeval.Extensions"
@property
def help_link(self) -> str:
return "https://github.com/Pixeval/Pixeval.Extensions/tree/master/src/python"
@property
def description(self) -> str:
return "A Python extension implemented through the native Pixeval Python bootstrap."
@property
def version(self) -> str:
return "0.1.0"
@property
def extensions(self) -> Sequence[abi.ComObject]:
return self._extensions
@property
def icon(self) -> bytes | None:
return read_icon(r"D:\logo.png")
_HOST = DemoHost()
def get_extensions_host() -> int:
return _HOST.export()