-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.py
More file actions
38 lines (30 loc) · 1.03 KB
/
window.py
File metadata and controls
38 lines (30 loc) · 1.03 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
import socket
import json
class Window:
def __init__(self, title="Jasmine API Window", size=(640, 480)):
self.title = title
self.size = size
self.children = []
def show(self):
print(f"Showing window: {self.title}")
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client.connect('/tmp/amethyine-wm-quartz.sock')
message_data = {
"type": "create_window",
"title": self.title,
"size": [self.size[0], self.size[1]],
"children": self.children
}
message_bytes = (json.dumps(message_data) + "\n").encode('utf-8')
client.sendall(message_bytes)
response = client.recv(1024)
print("Compositor says:", response.decode())
def append(self, widget):
self.children.append(widget)
def run(self):
while True:
self._draw()
# insert timing and input handling here
def _draw(self):
for widget in self.children:
widget.draw()