Skip to content

Commit 77c73b5

Browse files
committed
buttons schema and implementation
1 parent 27ba174 commit 77c73b5

File tree

21 files changed

+204
-29
lines changed

21 files changed

+204
-29
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[DESIGN]
22
max-args=10
33
max-positional-arguments=10
4-
max-attributes=16
4+
max-attributes=17
55
max-parents=14
66
max-public-methods=22
77
max-branches=13

local/configs/package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ time_command: true
88

99
requirements:
1010
- aiofiles
11-
- vcorelib>=3.6.3
11+
- vcorelib>=3.6.4
1212
- svgen>=0.8.0
1313
- websockets
1414
- psutil

runtimepy/channel/environment/command/processor.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from runtimepy.mixins.environment import ChannelEnvironmentMixin
2121
from runtimepy.primitives.bool import Bool
2222
from runtimepy.primitives.field import BitField
23+
from runtimepy.ui.button import ActionButton
2324

2425
CommandHook = Callable[[Namespace, Optional[FieldOrChannel]], None]
2526

@@ -33,7 +34,11 @@ class ChannelCommandProcessor(ChannelEnvironmentMixin):
3334
"""A command processing interface for channel environments."""
3435

3536
def __init__(
36-
self, env: ChannelEnvironment, logger: LoggerType, **kwargs
37+
self,
38+
env: ChannelEnvironment,
39+
logger: LoggerType,
40+
buttons: list[ActionButton] = None,
41+
**kwargs,
3742
) -> None:
3843
"""Initialize this instance."""
3944

@@ -49,6 +54,11 @@ def __init__(
4954

5055
self.parser.initialize()
5156

57+
# Action buttons.
58+
if buttons is None:
59+
buttons = []
60+
self.buttons: list[ActionButton] = buttons
61+
5262
def register_custom_commands(
5363
self, *custom_commands: CustomCommand
5464
) -> None:

runtimepy/data/css/bootstrap_extra.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ select:hover {
110110
background-image: linear-gradient(to bottom, var(--bs-tertiary-bg), rgba(var(--bs-tertiary-bg-rgb), 0), var(--bs-tertiary-bg));
111111
}
112112

113+
.bg-gradient-tertiary-left-right {
114+
background-image: linear-gradient(to right, var(--bs-tertiary-bg), rgba(var(--bs-tertiary-bg-rgb), 0), var(--bs-tertiary-bg));
115+
}
116+
113117
.border-start-info-subtle {
114118
border-left: var(--bs-border-width) var(--bs-border-style) var(--bs-info-border-subtle);
115119
}

runtimepy/data/dummy_load.yaml

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,42 @@
11
---
2+
# UDP JSON clients.
3+
clients:
4+
- factory: udp_json
5+
name: udp_json_client
6+
defer: true
7+
kwargs:
8+
remote_addr: [localhost, "$udp_json"]
9+
views:
10+
- [metrics, metrics]
11+
- [transmit, tx]
12+
- [receive, rx]
13+
buttons: &buttons
14+
- icon: tux
15+
key: test
16+
payload: {}
17+
- icon: tux
18+
key: test
19+
text: asdf
20+
payload: {}
21+
- icon: tux
22+
key: test
23+
payload: {}
24+
outline: false
25+
- icon: tux
26+
key: test
27+
text: asdf
28+
payload: {}
29+
outline: false
30+
markdown: |
31+
# `udp_json_client`
32+
33+
Connects to `udp_json_server`.
34+
35+
- factory: udp_json
36+
name: udp_json_server
37+
kwargs:
38+
local_addr: [localhost, "$udp_json"]
39+
240
# Add some sample tasks.
341
tasks:
442
# Chaos.
@@ -9,6 +47,7 @@ tasks:
947
a: 1
1048
b: 2
1149
c: 3
50+
buttons: *buttons
1251
views:
1352
- [zero, "\\.0\\."]
1453
- [one, "\\.1\\."]
@@ -49,27 +88,6 @@ tasks:
4988
# Drive interactions with runtime entities that won't otherwise be polled.
5089
- {name: app, factory: SampleApp, period_s: 0.25}
5190

52-
# UDP JSON clients.
53-
clients:
54-
- factory: udp_json
55-
name: udp_json_client
56-
defer: true
57-
kwargs:
58-
remote_addr: [localhost, "$udp_json"]
59-
views:
60-
- [metrics, metrics]
61-
- [transmit, tx]
62-
- [receive, rx]
63-
markdown: |
64-
# `udp_json_client`
65-
66-
Connects to `udp_json_server`.
67-
68-
- factory: udp_json
69-
name: udp_json_server
70-
kwargs:
71-
local_addr: [localhost, "$udp_json"]
72-
7391
# Add some sample structs.
7492
structs:
7593
- name: example.struct1
@@ -80,6 +98,8 @@ structs:
8098
b: 2
8199
c: 3
82100

101+
buttons: *buttons
102+
83103
markdown: |
84104
# Docs for `example.struct1`
85105

runtimepy/data/js/classes/WorkerInterface.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class WorkerInterface {
1010

1111
command(data) { this.send({kind : "command", value : data}); }
1212

13-
bus(data) { this.worker.postMessage({bus : data}); }
13+
bus(key, data) { this.worker.postMessage({key : key, bus : data}); }
1414

1515
toWorker(data, param) { return this.send({"worker" : data}, param); }
1616
}

runtimepy/data/js/sample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
console.log(`sample.js included (${tab.name})`);
2-
// tab.worker.bus({a: 1, b: 2, c: 3});
2+
// tab.worker.bus("test", {a: 1, b: 2, c: 3});

runtimepy/data/schemas/Button.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
type: object
3+
additionalProperties: false
4+
required: [key, payload]
5+
properties:
6+
key:
7+
type: string
8+
payload:
9+
type: object
10+
text:
11+
type: string
12+
icon:
13+
type: string
14+
variant:
15+
type: string
16+
outline:
17+
type: boolean

runtimepy/data/schemas/ClientConnectionConfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ includes:
44
- has_name.yaml
55
- has_markdown.yaml
66
- has_views.yaml
7+
- has_buttons.yaml
78

89
properties:
910
defer:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
properties:
3+
buttons:
4+
type: array
5+
items:
6+
$ref: package://runtimepy/schemas/Button.yaml

0 commit comments

Comments
 (0)