pyloid 0.27.0__tar.gz → 0.27.1__tar.gz
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-0.27.0 → pyloid-0.27.1}/PKG-INFO +2 -2
- {pyloid-0.27.0 → pyloid-0.27.1}/README.md +1 -1
- {pyloid-0.27.0 → pyloid-0.27.1}/pyproject.toml +1 -1
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/browser_window.py +9 -9
- pyloid-0.27.1/src/pyloid/ipc.py +164 -0
- pyloid-0.27.0/src/pyloid/ipc.py +0 -142
- {pyloid-0.27.0 → pyloid-0.27.1}/LICENSE +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/__init__.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/autostart.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/base_ipc/base.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/base_ipc/event_api.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/base_ipc/window_api.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/custom/titlebar.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/filewatcher.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/monitor.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/pyloid.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/rpc.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/serve.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/store.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/thread_pool.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/timer.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/tray.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/url_interceptor.py +0 -0
- {pyloid-0.27.0 → pyloid-0.27.1}/src/pyloid/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: pyloid
|
3
|
-
Version: 0.27.
|
3
|
+
Version: 0.27.1
|
4
4
|
Summary:
|
5
5
|
Author: aesthetics-of-record
|
6
6
|
Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
|
@@ -59,7 +59,7 @@ npm create pyloid-app@latest
|
|
59
59
|
|
60
60
|
## Documentation 📚
|
61
61
|
|
62
|
-
[Pyloid Documentation](https://
|
62
|
+
[Pyloid Documentation](https://pyloid.com/)
|
63
63
|
|
64
64
|
## License
|
65
65
|
|
@@ -408,7 +408,7 @@ class _BrowserWindow:
|
|
408
408
|
frame: bool = True,
|
409
409
|
context_menu: bool = False,
|
410
410
|
dev_tools: bool = False,
|
411
|
-
|
411
|
+
transparent: bool = False,
|
412
412
|
IPCs: List[PyloidIPC] = [],
|
413
413
|
):
|
414
414
|
###########################################################################################
|
@@ -750,19 +750,19 @@ class _BrowserWindow:
|
|
750
750
|
console.error('QWebChannel is not defined.');
|
751
751
|
}
|
752
752
|
"""
|
753
|
-
ipcs_init_code =
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
753
|
+
ipcs_init_code = '\n'.join(
|
754
|
+
[
|
755
|
+
f"window['ipc']['{ipc.__class__.__name__}'] = channel.objects['{ipc.__class__.__name__}'];\n"
|
756
|
+
f"console.log('{ipc.__class__.__name__} object initialized:', window['ipc']['{ipc.__class__.__name__}']);"
|
757
|
+
for ipc in self.IPCs
|
758
|
+
if ipc.__class__.__name__ != 'BaseIPC'
|
759
|
+
]
|
760
760
|
)
|
761
761
|
|
762
762
|
base_ipc_init = "window['__PYLOID__'] = channel.objects['__PYLOID__'];\n"
|
763
763
|
|
764
764
|
self.web_view.page().runJavaScript(js_code % (base_ipc_init, ipcs_init_code))
|
765
|
-
|
765
|
+
|
766
766
|
# if splash screen is set, close it when the page is loaded
|
767
767
|
if self.close_on_load and self.splash_screen:
|
768
768
|
self.close_splash_screen()
|
@@ -0,0 +1,164 @@
|
|
1
|
+
from PySide6.QtCore import (
|
2
|
+
QObject,
|
3
|
+
Slot,
|
4
|
+
)
|
5
|
+
from typing import (
|
6
|
+
TYPE_CHECKING,
|
7
|
+
)
|
8
|
+
|
9
|
+
if TYPE_CHECKING:
|
10
|
+
from pyloid.pyloid import (
|
11
|
+
Pyloid,
|
12
|
+
)
|
13
|
+
from pyloid.browser_window import (
|
14
|
+
BrowserWindow,
|
15
|
+
)
|
16
|
+
|
17
|
+
|
18
|
+
class PyloidIPC(QObject):
|
19
|
+
"""
|
20
|
+
PyloidIPC class.
|
21
|
+
It enables communication between JavaScript and Python via IPC.
|
22
|
+
|
23
|
+
Usage Example
|
24
|
+
-------------
|
25
|
+
(Python)
|
26
|
+
```python
|
27
|
+
from pyloid import Pyloid
|
28
|
+
from pyloid.ipc import PyloidIPC, Bridge
|
29
|
+
|
30
|
+
app = Pyloid('Pyloid-App')
|
31
|
+
|
32
|
+
class CustomIPC(PyloidIPC):
|
33
|
+
@Bridge(str, result=str)
|
34
|
+
def echo(self, message):
|
35
|
+
return f'Message received in Python: {message}'
|
36
|
+
|
37
|
+
@Bridge(int, int, result=int)
|
38
|
+
def add(self, a, b):
|
39
|
+
return a + b
|
40
|
+
|
41
|
+
@Bridge(result=str)
|
42
|
+
def create_window(self):
|
43
|
+
win = self.pyloid.create_window(title='Pyloid Browser')
|
44
|
+
win.load_url('https://www.google.com')
|
45
|
+
win.show()
|
46
|
+
win.focus()
|
47
|
+
return win.get_id()
|
48
|
+
|
49
|
+
# Create main window
|
50
|
+
window = app.create_window(
|
51
|
+
title='Pyloid Browser',
|
52
|
+
ipc=[CustomIPC()],
|
53
|
+
)
|
54
|
+
|
55
|
+
window.load_file('index.html')
|
56
|
+
window.show()
|
57
|
+
window.focus()
|
58
|
+
|
59
|
+
app.run()
|
60
|
+
```
|
61
|
+
|
62
|
+
---
|
63
|
+
|
64
|
+
(JavaScript)
|
65
|
+
```javascript
|
66
|
+
import { ipc } from 'pyloid-js';
|
67
|
+
|
68
|
+
let result = await ipc.CustomIPC.echo('Hello, Pyloid!').then((result) => {
|
69
|
+
console.log(result); // "Message received in Python: Hello, Pyloid!"
|
70
|
+
})
|
71
|
+
|
72
|
+
let sum = await ipc.CustomIPC.add(5, 3).then((sum) => {
|
73
|
+
console.log(sum); // 8
|
74
|
+
})
|
75
|
+
|
76
|
+
let window_id = await ipc.CustomIPC.create_window().then((window_id) => {
|
77
|
+
console.log(window_id); // "eae338a3-c8cb-4103-852f-404486beea0d"
|
78
|
+
})
|
79
|
+
```
|
80
|
+
"""
|
81
|
+
|
82
|
+
def __init__(
|
83
|
+
self,
|
84
|
+
):
|
85
|
+
super().__init__()
|
86
|
+
self.window_id: str = None
|
87
|
+
self.window: 'BrowserWindow' = None
|
88
|
+
self.pyloid: 'Pyloid' = None
|
89
|
+
|
90
|
+
|
91
|
+
def Bridge(
|
92
|
+
*args,
|
93
|
+
**kwargs,
|
94
|
+
):
|
95
|
+
"""
|
96
|
+
Bridge function creates a slot that can be IPC from JavaScript.
|
97
|
+
|
98
|
+
Parameters
|
99
|
+
----------
|
100
|
+
*args : tuple
|
101
|
+
Variable length argument list.
|
102
|
+
**kwargs : dict
|
103
|
+
Arbitrary keyword arguments.
|
104
|
+
|
105
|
+
Usage Example
|
106
|
+
-------------
|
107
|
+
(Python)
|
108
|
+
```python
|
109
|
+
from pyloid import Pyloid
|
110
|
+
from pyloid.ipc import PyloidIPC, Bridge
|
111
|
+
|
112
|
+
app = Pyloid('Pyloid-App')
|
113
|
+
|
114
|
+
class CustomIPC(PyloidIPC):
|
115
|
+
@Bridge(str, result=str)
|
116
|
+
def echo(self, message):
|
117
|
+
return f'Message received in Python: {message}'
|
118
|
+
|
119
|
+
@Bridge(int, int, result=int)
|
120
|
+
def add(self, a, b):
|
121
|
+
return a + b
|
122
|
+
|
123
|
+
@Bridge(result=str)
|
124
|
+
def create_window(self):
|
125
|
+
win = self.pyloid.create_window(title='Pyloid Browser')
|
126
|
+
win.load_url('https://www.google.com')
|
127
|
+
win.show()
|
128
|
+
win.focus()
|
129
|
+
return win.get_id()
|
130
|
+
|
131
|
+
# Create main window
|
132
|
+
window = app.create_window(
|
133
|
+
title='Pyloid Browser',
|
134
|
+
ipc=[CustomIPC()],
|
135
|
+
)
|
136
|
+
|
137
|
+
window.load_file('index.html')
|
138
|
+
window.show()
|
139
|
+
window.focus()
|
140
|
+
|
141
|
+
app.run()
|
142
|
+
```
|
143
|
+
---
|
144
|
+
(JavaScript)
|
145
|
+
```javascript
|
146
|
+
import { ipc } from 'pyloid-js';
|
147
|
+
|
148
|
+
let result = await ipc.CustomIPC.echo('Hello, Pyloid!').then((result) => {
|
149
|
+
console.log(result); // "Message received in Python: Hello, Pyloid!"
|
150
|
+
})
|
151
|
+
|
152
|
+
let sum = await ipc.CustomIPC.add(5, 3).then((sum) => {
|
153
|
+
console.log(sum); // 8
|
154
|
+
})
|
155
|
+
|
156
|
+
let window_id = await ipc.CustomIPC.create_window().then((window_id) => {
|
157
|
+
console.log(window_id); // "eae338a3-c8cb-4103-852f-404486beea0d"
|
158
|
+
})
|
159
|
+
```
|
160
|
+
"""
|
161
|
+
return Slot(
|
162
|
+
*args,
|
163
|
+
**kwargs,
|
164
|
+
)
|
pyloid-0.27.0/src/pyloid/ipc.py
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
from PySide6.QtCore import (
|
2
|
-
QObject,
|
3
|
-
Slot,
|
4
|
-
)
|
5
|
-
from typing import (
|
6
|
-
TYPE_CHECKING,
|
7
|
-
)
|
8
|
-
|
9
|
-
if TYPE_CHECKING:
|
10
|
-
from pyloid.pyloid import (
|
11
|
-
Pyloid,
|
12
|
-
)
|
13
|
-
from pyloid.browser_window import (
|
14
|
-
BrowserWindow,
|
15
|
-
)
|
16
|
-
|
17
|
-
|
18
|
-
class PyloidIPC(QObject):
|
19
|
-
"""
|
20
|
-
PyloidIPC class.
|
21
|
-
It enables communication between JavaScript and Python via IPC.
|
22
|
-
|
23
|
-
Usage Example
|
24
|
-
-------------
|
25
|
-
(Python)
|
26
|
-
```python
|
27
|
-
from pyloid import (
|
28
|
-
Pyloid,
|
29
|
-
)
|
30
|
-
from pyloid.ipc import (
|
31
|
-
PyloidIPC,
|
32
|
-
Bridge,
|
33
|
-
)
|
34
|
-
|
35
|
-
app = Pyloid('Pyloid-App')
|
36
|
-
|
37
|
-
|
38
|
-
class CustomIPC(PyloidIPC):
|
39
|
-
@Bridge(
|
40
|
-
str,
|
41
|
-
result=str,
|
42
|
-
)
|
43
|
-
def echo(
|
44
|
-
self,
|
45
|
-
message,
|
46
|
-
):
|
47
|
-
return f'Message received in Python: {message}'
|
48
|
-
|
49
|
-
|
50
|
-
# Create main window
|
51
|
-
window = app.create_window(
|
52
|
-
title='Pyloid Browser',
|
53
|
-
ipc=[CustomIPC()],
|
54
|
-
)
|
55
|
-
|
56
|
-
window.load_file('index.html')
|
57
|
-
|
58
|
-
window.show()
|
59
|
-
window.focus()
|
60
|
-
|
61
|
-
app.run()
|
62
|
-
```
|
63
|
-
---
|
64
|
-
(JavaScript)
|
65
|
-
```javascript
|
66
|
-
let result = await window.pyloid.CustomIPC.echo('Hello, Pyloid!');
|
67
|
-
console.log(result);
|
68
|
-
```
|
69
|
-
"""
|
70
|
-
|
71
|
-
def __init__(
|
72
|
-
self,
|
73
|
-
):
|
74
|
-
super().__init__()
|
75
|
-
self.window_id: str = None
|
76
|
-
self.window: 'BrowserWindow' = None
|
77
|
-
self.pyloid: 'Pyloid' = None
|
78
|
-
|
79
|
-
|
80
|
-
def Bridge(
|
81
|
-
*args,
|
82
|
-
**kwargs,
|
83
|
-
):
|
84
|
-
"""
|
85
|
-
Bridge function creates a slot that can be IPC from JavaScript.
|
86
|
-
|
87
|
-
Parameters
|
88
|
-
----------
|
89
|
-
*args : tuple
|
90
|
-
Variable length argument list.
|
91
|
-
**kwargs : dict
|
92
|
-
Arbitrary keyword arguments.
|
93
|
-
|
94
|
-
Usage Example
|
95
|
-
-------------
|
96
|
-
(Python)
|
97
|
-
```python
|
98
|
-
from pyloid import (
|
99
|
-
Pyloid,
|
100
|
-
PyloidIPC,
|
101
|
-
Bridge,
|
102
|
-
)
|
103
|
-
|
104
|
-
app = Pyloid('Pyloid-App')
|
105
|
-
|
106
|
-
|
107
|
-
class CustomIPC(PyloidIPC):
|
108
|
-
@Bridge(
|
109
|
-
str,
|
110
|
-
result=str,
|
111
|
-
)
|
112
|
-
def echo(
|
113
|
-
self,
|
114
|
-
message,
|
115
|
-
):
|
116
|
-
return f'Message received in Python: {message}'
|
117
|
-
|
118
|
-
|
119
|
-
# Create main window
|
120
|
-
window = app.create_window(
|
121
|
-
title='Pyloid Browser',
|
122
|
-
ipc=[CustomIPC()],
|
123
|
-
)
|
124
|
-
|
125
|
-
window.load_file('index.html')
|
126
|
-
|
127
|
-
window.show()
|
128
|
-
window.focus()
|
129
|
-
|
130
|
-
app.run()
|
131
|
-
```
|
132
|
-
---
|
133
|
-
(JavaScript)
|
134
|
-
```javascript
|
135
|
-
let result = await window.pyloid.CustomIPC.echo('Hello, Pyloid!');
|
136
|
-
console.log(result);
|
137
|
-
```
|
138
|
-
"""
|
139
|
-
return Slot(
|
140
|
-
*args,
|
141
|
-
**kwargs,
|
142
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|