-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
216 lines (193 loc) · 7.47 KB
/
index.py
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import threading
import time
from enum import Enum
import json
import xframes
class ImGuiCol(Enum):
Text = 0
TextDisabled = 1
WindowBg = 2
ChildBg = 3
PopupBg = 4
Border = 5
BorderShadow = 6
FrameBg = 7
FrameBgHovered = 8
FrameBgActive = 9
TitleBg = 10
TitleBgActive = 11
TitleBgCollapsed = 12
MenuBarBg = 13
ScrollbarBg = 14
ScrollbarGrab = 15
ScrollbarGrabHovered = 16
ScrollbarGrabActive = 17
CheckMark = 18
SliderGrab = 19
SliderGrabActive = 20
Button = 21
ButtonHovered = 22
ButtonActive = 23
Header = 24
HeaderHovered = 25
HeaderActive = 26
Separator = 27
SeparatorHovered = 28
SeparatorActive = 29
ResizeGrip = 30
ResizeGripHovered = 31
ResizeGripActive = 32
Tab = 33
TabHovered = 34
TabActive = 35
TabUnfocused = 36
TabUnfocusedActive = 37
PlotLines = 38
PlotLinesHovered = 39
PlotHistogram = 40
PlotHistogramHovered = 41
TableHeaderBg = 42
TableBorderStrong = 43
TableBorderLight = 44
TableRowBg = 45
TableRowBgAlt = 46
TextSelectedBg = 47
DragDropTarget = 48
NavHighlight = 49
NavWindowingHighlight = 50
NavWindowingDimBg = 51
ModalWindowDimBg = 52
COUNT = 53
theme2_colors = {
"darkestGrey": "#141f2c",
"darkerGrey": "#2a2e39",
"darkGrey": "#363b4a",
"lightGrey": "#5a5a5a",
"lighterGrey": "#7A818C",
"evenLighterGrey": "#8491a3",
"black": "#0A0B0D",
"green": "#75f986",
"red": "#ff0062",
"white": "#fff",
}
theme2 = {
"colors": {
str(ImGuiCol.Text.value): [theme2_colors["white"], 1],
str(ImGuiCol.TextDisabled.value): [theme2_colors["lighterGrey"], 1],
str(ImGuiCol.WindowBg.value): [theme2_colors["black"], 1],
str(ImGuiCol.ChildBg.value): [theme2_colors["black"], 1],
str(ImGuiCol.PopupBg.value): [theme2_colors["white"], 1],
str(ImGuiCol.Border.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.BorderShadow.value): [theme2_colors["darkestGrey"], 1],
str(ImGuiCol.FrameBg.value): [theme2_colors["black"], 1],
str(ImGuiCol.FrameBgHovered.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.FrameBgActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TitleBg.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TitleBgActive.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.TitleBgCollapsed.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.MenuBarBg.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.ScrollbarBg.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.ScrollbarGrab.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.ScrollbarGrabHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.ScrollbarGrabActive.value): [theme2_colors["darkestGrey"], 1],
str(ImGuiCol.CheckMark.value): [theme2_colors["darkestGrey"], 1],
str(ImGuiCol.SliderGrab.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.SliderGrabActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.Button.value): [theme2_colors["black"], 1],
str(ImGuiCol.ButtonHovered.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.ButtonActive.value): [theme2_colors["black"], 1],
str(ImGuiCol.Header.value): [theme2_colors["black"], 1],
str(ImGuiCol.HeaderHovered.value): [theme2_colors["black"], 1],
str(ImGuiCol.HeaderActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.Separator.value): [theme2_colors["darkestGrey"], 1],
str(ImGuiCol.SeparatorHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.SeparatorActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.ResizeGrip.value): [theme2_colors["black"], 1],
str(ImGuiCol.ResizeGripHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.ResizeGripActive.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.Tab.value): [theme2_colors["black"], 1],
str(ImGuiCol.TabHovered.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.TabActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TabUnfocused.value): [theme2_colors["black"], 1],
str(ImGuiCol.TabUnfocusedActive.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.PlotLines.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.PlotLinesHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.PlotHistogram.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.PlotHistogramHovered.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TableHeaderBg.value): [theme2_colors["black"], 1],
str(ImGuiCol.TableBorderStrong.value): [theme2_colors["lightGrey"], 1],
str(ImGuiCol.TableBorderLight.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.TableRowBg.value): [theme2_colors["darkGrey"], 1],
str(ImGuiCol.TableRowBgAlt.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.TextSelectedBg.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.DragDropTarget.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.NavHighlight.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.NavWindowingHighlight.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.NavWindowingDimBg.value): [theme2_colors["darkerGrey"], 1],
str(ImGuiCol.ModalWindowDimBg.value): [theme2_colors["darkerGrey"], 1],
}
}
font_defs = {
"defs": [
{"name": "roboto-regular", "sizes": [16, 18, 20, 24, 28, 32, 36, 48]}
]
}
font_defs["defs"] = [
{"name": entry["name"], "size": size}
for entry in font_defs["defs"]
for size in entry["sizes"]
]
def run():
def init():
print("init!")
rootNode = {
"id": 0,
"type": "node",
"root": True
}
textNode = {
"id": 1,
"type": "unformatted-text",
"text": "Hello, world!"
}
xframes.setElement(json.dumps(rootNode))
xframes.setElement(json.dumps(textNode))
xframes.setChildren(0, json.dumps([1]))
def on_text_changed(id, value):
print(f"text changed, widget {id} value {value}")
def on_combo_changed(id, value):
print(f"combo changed, widget {id} value {value}")
def on_numeric_value_changed(id, value):
print(f"numeric value changed, widget {id} value {value}")
def on_boolean_value_changed(id, value):
print(f"boolean value changed, widget {id} value {value}")
def on_multiple_numeric_values_changed(id, values):
print(f"multiple numeric values changed, widget {id} value {values}")
def on_click(id):
print(f"widget {id} clicked")
xframes.init(
"./assets",
json.dumps(font_defs),
json.dumps(theme2),
init,
on_text_changed,
on_combo_changed,
on_numeric_value_changed,
on_boolean_value_changed,
on_multiple_numeric_values_changed,
on_click
)
run()
flag = True
def keep_process_running():
while flag:
time.sleep(1)
# Start the keep-alive process in a separate thread
thread = threading.Thread(target=keep_process_running)
thread.daemon = True # Ensure the thread doesn't block program exit
thread.start()
# Main thread can perform other tasks
print("Main process continues to run...")
# time.sleep(5)
# flag = False # Stop the keep-alive process
thread.join() # Wait for the thread to finish