pyloid 0.26.2__py3-none-any.whl → 0.26.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyloid/__init__.py +4 -7
- pyloid/autostart.py +131 -68
- pyloid/base_ipc/base.py +395 -0
- pyloid/{js_api → base_ipc}/event_api.py +1 -1
- pyloid/browser_window.py +3768 -3006
- pyloid/custom/titlebar.py +153 -90
- pyloid/filewatcher.py +191 -161
- pyloid/ipc.py +142 -0
- pyloid/monitor.py +1117 -920
- pyloid/pyloid.py +3396 -2671
- pyloid/rpc.py +734 -527
- pyloid/serve.py +306 -215
- pyloid/store.py +253 -175
- pyloid/thread_pool.py +643 -496
- pyloid/timer.py +424 -305
- pyloid/tray.py +61 -45
- pyloid/url_interceptor.py +37 -20
- pyloid/utils.py +243 -193
- {pyloid-0.26.2.dist-info → pyloid-0.26.4.dist-info}/METADATA +1 -1
- pyloid-0.26.4.dist-info/RECORD +23 -0
- pyloid/api.py +0 -104
- pyloid/js_api/base.py +0 -259
- pyloid-0.26.2.dist-info/RECORD +0 -23
- /pyloid/{js_api → base_ipc}/window_api.py +0 -0
- {pyloid-0.26.2.dist-info → pyloid-0.26.4.dist-info}/LICENSE +0 -0
- {pyloid-0.26.2.dist-info → pyloid-0.26.4.dist-info}/WHEEL +0 -0
pyloid/api.py
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
from PySide6.QtCore import QObject, Slot
|
|
2
|
-
from typing import TYPE_CHECKING
|
|
3
|
-
|
|
4
|
-
if TYPE_CHECKING:
|
|
5
|
-
from pyloid.pyloid import Pyloid
|
|
6
|
-
from pyloid.browser_window import BrowserWindow
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class PyloidAPI(QObject):
|
|
10
|
-
"""
|
|
11
|
-
PyloidAPI class is derived from PySide6's QObject.
|
|
12
|
-
It enables communication between JavaScript and Python.
|
|
13
|
-
|
|
14
|
-
Usage Example
|
|
15
|
-
-------------
|
|
16
|
-
(Python)
|
|
17
|
-
```python
|
|
18
|
-
from pyloid import Pyloid, PyloidAPI, Bridge
|
|
19
|
-
|
|
20
|
-
app = Pyloid("Pyloid-App")
|
|
21
|
-
|
|
22
|
-
class CustomAPI(PyloidAPI):
|
|
23
|
-
@Bridge(str, result=str)
|
|
24
|
-
def echo(self, message):
|
|
25
|
-
return f"Message received in Python: {message}"
|
|
26
|
-
|
|
27
|
-
# Create main window
|
|
28
|
-
window = app.create_window(
|
|
29
|
-
title="Pyloid Browser",
|
|
30
|
-
js_apis=[CustomAPI()],
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
window.load_file("index.html")
|
|
34
|
-
|
|
35
|
-
window.show()
|
|
36
|
-
window.focus()
|
|
37
|
-
|
|
38
|
-
app.run()
|
|
39
|
-
```
|
|
40
|
-
---
|
|
41
|
-
(JavaScript)
|
|
42
|
-
```javascript
|
|
43
|
-
document.addEventListener('pyloidReady', async function () {
|
|
44
|
-
let result = await window.pyloid.CustomAPI.echo('Hello, Pyloid!');
|
|
45
|
-
console.log(result);
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
def __init__(self):
|
|
52
|
-
super().__init__()
|
|
53
|
-
self.window_id: str = None
|
|
54
|
-
self.window: "BrowserWindow" = None
|
|
55
|
-
self.app: "Pyloid" = None
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def Bridge(*args, **kwargs):
|
|
59
|
-
"""
|
|
60
|
-
Bridge function creates a slot that can be called from JavaScript.
|
|
61
|
-
|
|
62
|
-
Parameters
|
|
63
|
-
----------
|
|
64
|
-
*args : tuple
|
|
65
|
-
Variable length argument list.
|
|
66
|
-
**kwargs : dict
|
|
67
|
-
Arbitrary keyword arguments.
|
|
68
|
-
|
|
69
|
-
Usage Example
|
|
70
|
-
-------------
|
|
71
|
-
(Python)
|
|
72
|
-
```python
|
|
73
|
-
from pyloid import Pyloid, PyloidAPI, Bridge
|
|
74
|
-
|
|
75
|
-
app = Pyloid("Pyloid-App")
|
|
76
|
-
|
|
77
|
-
class CustomAPI(PyloidAPI):
|
|
78
|
-
@Bridge(str, result=str)
|
|
79
|
-
def echo(self, message):
|
|
80
|
-
return f"Message received in Python: {message}"
|
|
81
|
-
|
|
82
|
-
# Create main window
|
|
83
|
-
window = app.create_window(
|
|
84
|
-
title="Pyloid Browser",
|
|
85
|
-
js_apis=[CustomAPI()],
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
window.load_file("index.html")
|
|
89
|
-
|
|
90
|
-
window.show()
|
|
91
|
-
window.focus()
|
|
92
|
-
|
|
93
|
-
app.run()
|
|
94
|
-
```
|
|
95
|
-
---
|
|
96
|
-
(JavaScript)
|
|
97
|
-
```javascript
|
|
98
|
-
document.addEventListener('pyloidReady', async function () {
|
|
99
|
-
let result = await window.pyloid.CustomAPI.echo('Hello, Pyloid!');
|
|
100
|
-
console.log(result);
|
|
101
|
-
});
|
|
102
|
-
```
|
|
103
|
-
"""
|
|
104
|
-
return Slot(*args, **kwargs)
|
pyloid/js_api/base.py
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING, Optional
|
|
2
|
-
|
|
3
|
-
from ..api import PyloidAPI, Bridge
|
|
4
|
-
from PySide6.QtCore import QByteArray, QBuffer, QIODeviceBase
|
|
5
|
-
import base64
|
|
6
|
-
from ..utils import get_platform, is_production, get_production_path
|
|
7
|
-
|
|
8
|
-
if TYPE_CHECKING:
|
|
9
|
-
from ..pyloid import _Pyloid
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class BaseAPI(PyloidAPI):
|
|
13
|
-
def __init__(
|
|
14
|
-
self, window_id: str, data: dict, app: "_Pyloid", server_url: Optional[str] = None
|
|
15
|
-
):
|
|
16
|
-
super().__init__()
|
|
17
|
-
self.window_id: str = window_id
|
|
18
|
-
self.data: dict = data
|
|
19
|
-
self.app: "_Pyloid" = app
|
|
20
|
-
self.server_url: Optional[str] = server_url
|
|
21
|
-
|
|
22
|
-
@Bridge(result=dict)
|
|
23
|
-
def getData(self):
|
|
24
|
-
"""Returns the shared data of the application."""
|
|
25
|
-
return self.data
|
|
26
|
-
|
|
27
|
-
@Bridge()
|
|
28
|
-
def startSystemDrag(self):
|
|
29
|
-
"""Starts the system drag."""
|
|
30
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
31
|
-
if window:
|
|
32
|
-
window._window.web_view.start_system_drag()
|
|
33
|
-
|
|
34
|
-
@Bridge(result=str)
|
|
35
|
-
def getWindowId(self):
|
|
36
|
-
"""Returns the current window ID."""
|
|
37
|
-
return self.window_id
|
|
38
|
-
|
|
39
|
-
@Bridge(result=dict)
|
|
40
|
-
def getWindowProperties(self):
|
|
41
|
-
"""Returns the properties of the window."""
|
|
42
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
43
|
-
window_properties = window._window.get_window_properties()
|
|
44
|
-
return window_properties
|
|
45
|
-
|
|
46
|
-
@Bridge()
|
|
47
|
-
def close(self):
|
|
48
|
-
"""Closes the window."""
|
|
49
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
50
|
-
if window:
|
|
51
|
-
window._window.close()
|
|
52
|
-
|
|
53
|
-
@Bridge()
|
|
54
|
-
def hide(self):
|
|
55
|
-
"""Hides the window."""
|
|
56
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
57
|
-
if window:
|
|
58
|
-
window._window.hide()
|
|
59
|
-
|
|
60
|
-
@Bridge()
|
|
61
|
-
def show(self):
|
|
62
|
-
"""Shows and focuses the window."""
|
|
63
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
64
|
-
if window:
|
|
65
|
-
window._window.show()
|
|
66
|
-
|
|
67
|
-
@Bridge()
|
|
68
|
-
def focus(self):
|
|
69
|
-
"""Focuses the window."""
|
|
70
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
71
|
-
if window:
|
|
72
|
-
window._window.focus()
|
|
73
|
-
|
|
74
|
-
@Bridge()
|
|
75
|
-
def showAndFocus(self):
|
|
76
|
-
"""Shows and focuses the window."""
|
|
77
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
78
|
-
if window:
|
|
79
|
-
window._window.show_and_focus()
|
|
80
|
-
|
|
81
|
-
@Bridge()
|
|
82
|
-
def fullscreen(self):
|
|
83
|
-
"""Enters fullscreen mode."""
|
|
84
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
85
|
-
if window:
|
|
86
|
-
window._window.fullscreen()
|
|
87
|
-
|
|
88
|
-
@Bridge()
|
|
89
|
-
def toggleFullscreen(self):
|
|
90
|
-
"""Toggles fullscreen mode for the window."""
|
|
91
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
92
|
-
if window:
|
|
93
|
-
window._window.toggle_fullscreen()
|
|
94
|
-
|
|
95
|
-
@Bridge()
|
|
96
|
-
def minimize(self):
|
|
97
|
-
"""Minimizes the window."""
|
|
98
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
99
|
-
if window:
|
|
100
|
-
window._window.minimize()
|
|
101
|
-
|
|
102
|
-
@Bridge()
|
|
103
|
-
def maximize(self):
|
|
104
|
-
"""Maximizes the window."""
|
|
105
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
106
|
-
if window:
|
|
107
|
-
window._window.maximize()
|
|
108
|
-
|
|
109
|
-
@Bridge()
|
|
110
|
-
def unmaximize(self):
|
|
111
|
-
"""Restores the window to its normal state."""
|
|
112
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
113
|
-
if window:
|
|
114
|
-
window._window.unmaximize()
|
|
115
|
-
|
|
116
|
-
@Bridge()
|
|
117
|
-
def toggleMaximize(self):
|
|
118
|
-
"""Toggles the maximized state of the window."""
|
|
119
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
120
|
-
if window:
|
|
121
|
-
window._window.toggle_maximize()
|
|
122
|
-
|
|
123
|
-
@Bridge(result=bool)
|
|
124
|
-
def isFullscreen(self):
|
|
125
|
-
"""Returns True if the window is fullscreen."""
|
|
126
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
127
|
-
return window._window.is_fullscreen()
|
|
128
|
-
|
|
129
|
-
@Bridge(result=bool)
|
|
130
|
-
def isMaximized(self):
|
|
131
|
-
"""Returns True if the window is maximized."""
|
|
132
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
133
|
-
return window._window.is_maximized()
|
|
134
|
-
|
|
135
|
-
@Bridge(str)
|
|
136
|
-
def setTitle(self, title: str):
|
|
137
|
-
"""Sets the title of the window."""
|
|
138
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
139
|
-
if window:
|
|
140
|
-
window._window.set_title(title)
|
|
141
|
-
|
|
142
|
-
@Bridge(int, int)
|
|
143
|
-
def setSize(self, width: int, height: int):
|
|
144
|
-
"""Sets the size of the window."""
|
|
145
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
146
|
-
if window:
|
|
147
|
-
window._window.set_size(width, height)
|
|
148
|
-
|
|
149
|
-
@Bridge(int, int)
|
|
150
|
-
def setPosition(self, x: int, y: int):
|
|
151
|
-
"""Sets the position of the window."""
|
|
152
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
153
|
-
if window:
|
|
154
|
-
window._window.set_position(x, y)
|
|
155
|
-
|
|
156
|
-
@Bridge(bool)
|
|
157
|
-
def setFrame(self, frame: bool):
|
|
158
|
-
"""Sets the frame of the window."""
|
|
159
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
160
|
-
if window:
|
|
161
|
-
window._window.set_frame(frame)
|
|
162
|
-
|
|
163
|
-
@Bridge(result=bool)
|
|
164
|
-
def getFrame(self):
|
|
165
|
-
"""Returns whether the window has a frame."""
|
|
166
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
167
|
-
return window._window.frame if window else False
|
|
168
|
-
|
|
169
|
-
@Bridge(result=str)
|
|
170
|
-
def getTitle(self):
|
|
171
|
-
"""Returns the title of the window."""
|
|
172
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
173
|
-
return window._window.title if window else ""
|
|
174
|
-
|
|
175
|
-
@Bridge(result=dict)
|
|
176
|
-
def getSize(self):
|
|
177
|
-
"""Returns the size of the window."""
|
|
178
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
179
|
-
size = window.get_size()
|
|
180
|
-
return size if window else {"width": 0, "height": 0}
|
|
181
|
-
|
|
182
|
-
@Bridge(result=dict)
|
|
183
|
-
def getPosition(self):
|
|
184
|
-
"""Returns the position of the window."""
|
|
185
|
-
window = self.app.get_window_by_id(self.window_id)
|
|
186
|
-
pos = window.get_position()
|
|
187
|
-
return pos if window else {"x": 0, "y": 0}
|
|
188
|
-
|
|
189
|
-
###############################################################
|
|
190
|
-
# Clipboard
|
|
191
|
-
###############################################################
|
|
192
|
-
|
|
193
|
-
@Bridge(str)
|
|
194
|
-
def setClipboardText(self, text: str):
|
|
195
|
-
"""Sets the text to the clipboard."""
|
|
196
|
-
self.app.set_clipboard_text(text)
|
|
197
|
-
|
|
198
|
-
@Bridge(result=str)
|
|
199
|
-
def getClipboardText(self):
|
|
200
|
-
"""Gets the text from the clipboard."""
|
|
201
|
-
return self.app.get_clipboard_text()
|
|
202
|
-
|
|
203
|
-
@Bridge(str, str)
|
|
204
|
-
def setClipboardImage(self, image_path: str, format: str):
|
|
205
|
-
"""Sets the image to the clipboard."""
|
|
206
|
-
self.app.set_clipboard_image(image_path, format)
|
|
207
|
-
|
|
208
|
-
@Bridge(result=str)
|
|
209
|
-
def getClipboardImage(self):
|
|
210
|
-
"""Returns the clipboard image as a Base64 encoded data URL."""
|
|
211
|
-
image = self.app.get_clipboard_image() # Assuming it returns QImage
|
|
212
|
-
if image and not image.isNull():
|
|
213
|
-
# Convert QImage to byte array
|
|
214
|
-
byte_array = QByteArray()
|
|
215
|
-
buffer = QBuffer(byte_array)
|
|
216
|
-
buffer.open(QIODeviceBase.WriteOnly)
|
|
217
|
-
image.save(buffer, "PNG") # Save in PNG format
|
|
218
|
-
|
|
219
|
-
# Encode to Base64
|
|
220
|
-
base64_data = byte_array.toBase64().data().decode()
|
|
221
|
-
return f"data:image/png;base64,{base64_data}"
|
|
222
|
-
return ""
|
|
223
|
-
|
|
224
|
-
###########################################################################################
|
|
225
|
-
# Quit
|
|
226
|
-
###########################################################################################
|
|
227
|
-
@Bridge()
|
|
228
|
-
def quit(self):
|
|
229
|
-
"""Quits the application."""
|
|
230
|
-
self.app.quit()
|
|
231
|
-
|
|
232
|
-
###########################################################################################
|
|
233
|
-
# Utils
|
|
234
|
-
###########################################################################################
|
|
235
|
-
@Bridge(result=str)
|
|
236
|
-
def getPlatform(self):
|
|
237
|
-
"""Returns the platform of the application.
|
|
238
|
-
|
|
239
|
-
Returns
|
|
240
|
-
-------
|
|
241
|
-
str
|
|
242
|
-
The platform of the application (windows, linux, macos)
|
|
243
|
-
"""
|
|
244
|
-
return get_platform()
|
|
245
|
-
|
|
246
|
-
@Bridge(result=bool)
|
|
247
|
-
def isProduction(self):
|
|
248
|
-
"""Returns True if the application is in production mode."""
|
|
249
|
-
return is_production()
|
|
250
|
-
|
|
251
|
-
@Bridge(str, result=str)
|
|
252
|
-
def getProductionPath(self, path: str):
|
|
253
|
-
"""Returns the production path of the application."""
|
|
254
|
-
return get_production_path(path)
|
|
255
|
-
|
|
256
|
-
@Bridge(result=str)
|
|
257
|
-
def getServerUrl(self):
|
|
258
|
-
"""Returns the RPC URL of the application."""
|
|
259
|
-
return self.server_url
|
pyloid-0.26.2.dist-info/RECORD
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
pyloid/__init__.py,sha256=YKwMCSOds1QVi9N7EGfY0Z7BEjJn8j6HGqRblZlZClA,235
|
|
2
|
-
pyloid/api.py,sha256=A61Kmddh8BlpT3LfA6NbPQNzFmD95vQ4WKX53oKsGYU,2419
|
|
3
|
-
pyloid/autostart.py,sha256=K7DQYl4LHItvPp0bt1V9WwaaZmVSTeGvadkcwG-KKrI,3899
|
|
4
|
-
pyloid/browser_window.py,sha256=nw-N-v7znESskjyFy2L8vEa0e8v4I7482cM9a6ru6O4,103227
|
|
5
|
-
pyloid/custom/titlebar.py,sha256=itzK9pJbZMQ7BKca9kdbuHMffurrw15UijR6OU03Xsk,3894
|
|
6
|
-
pyloid/filewatcher.py,sha256=3M5zWVUf1OhlkWJcDFC8ZA9agO4Q-U8WdgGpy6kaVz0,4601
|
|
7
|
-
pyloid/js_api/base.py,sha256=VmoFIxwPj9inkMFYEspJvbn3iqiftxbg5Kja-6z-BzQ,8600
|
|
8
|
-
pyloid/js_api/event_api.py,sha256=w0z1DcmwcmseqfcoZWgsQmFC2iBCgTMVJubTaHeXI1c,957
|
|
9
|
-
pyloid/js_api/window_api.py,sha256=-isphU3m2wGB5U0yZrSuK_4XiBz2mG45HsjYTUq7Fxs,7348
|
|
10
|
-
pyloid/monitor.py,sha256=1mXvHm5deohnNlTLcRx4sT4x-stnOIb0dUQnnxN50Uo,28295
|
|
11
|
-
pyloid/pyloid.py,sha256=hUCKR92MhRzceSocMtOLEdRHQn0e1jly71u0Di1wFl4,84274
|
|
12
|
-
pyloid/rpc.py,sha256=6UzQc-CDA72VYeF3Xy-7AbBculE-T0MIokR39jVdlcg,21726
|
|
13
|
-
pyloid/serve.py,sha256=ZXUZ5_-BDbOGOpdKSjMtV_k6o0Q60SU5D0F6GBgkQbk,7891
|
|
14
|
-
pyloid/store.py,sha256=8PnBxtkUgbF8Lxh-iYlEuhbLE76bGBF8t5KV5u5NzoQ,4831
|
|
15
|
-
pyloid/thread_pool.py,sha256=fKOBb8jMfZn_7crA_fJCno8dObBRZE31EIWaNQ759aw,14616
|
|
16
|
-
pyloid/timer.py,sha256=RqMsChFUd93cxMVgkHWiIKrci0QDTBgJSTULnAtYT8M,8712
|
|
17
|
-
pyloid/tray.py,sha256=D12opVEc2wc2T4tK9epaN1oOdeziScsIVNM2uCN7C-A,1710
|
|
18
|
-
pyloid/url_interceptor.py,sha256=DanXAGwwLlpn9cEiVRTdsX49udlIfYzBzaM-QRRpdkY,830
|
|
19
|
-
pyloid/utils.py,sha256=J6owgVE1YDOEfcOPmoP9m9Q6nbYDyNEo9uqPsJs5p5g,6644
|
|
20
|
-
pyloid-0.26.2.dist-info/LICENSE,sha256=F96EzotgWhhpnQTW2TcdoqrMDir1jyEo6H915tGQ-QE,11524
|
|
21
|
-
pyloid-0.26.2.dist-info/METADATA,sha256=hw6HAPE9kZufUMiA0ehsKQUlMGSy9RdhCDNNJi9ReoI,2298
|
|
22
|
-
pyloid-0.26.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
23
|
-
pyloid-0.26.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|