pyloid 0.20.2__py3-none-any.whl → 0.20.2.dev2__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 +7 -7
- pyloid/api.py +104 -104
- pyloid/autostart.py +101 -101
- pyloid/browser_window.py +1956 -1915
- pyloid/builder/__init__.py +80 -80
- pyloid/builder/build_config.schema.json +72 -72
- pyloid/builder/spec.py +266 -247
- pyloid/custom/titlebar.py +116 -116
- pyloid/filewatcher.py +163 -163
- pyloid/js_api/event_api.py +24 -24
- pyloid/js_api/window_api.py +255 -255
- pyloid/monitor.py +921 -921
- pyloid/pyloid.py +1404 -1404
- pyloid/thread_pool.py +500 -500
- pyloid/timer.py +307 -307
- pyloid/tray.py +48 -48
- pyloid/utils.py +122 -122
- {pyloid-0.20.2.dist-info → pyloid-0.20.2.dev2.dist-info}/LICENSE +201 -201
- {pyloid-0.20.2.dist-info → pyloid-0.20.2.dev2.dist-info}/METADATA +1 -1
- pyloid-0.20.2.dev2.dist-info/RECORD +21 -0
- pyloid-0.20.2.dist-info/RECORD +0 -21
- {pyloid-0.20.2.dist-info → pyloid-0.20.2.dev2.dist-info}/WHEEL +0 -0
pyloid/tray.py
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
from enum import Enum
|
2
|
-
from PySide6.QtWidgets import QSystemTrayIcon
|
3
|
-
|
4
|
-
|
5
|
-
class TrayEvent(Enum):
|
6
|
-
"""
|
7
|
-
TrayEvent is an enumeration class representing events related to the system tray icon.
|
8
|
-
|
9
|
-
Enumeration Members
|
10
|
-
-------------------
|
11
|
-
DoubleClick : Event that occurs when the tray icon is double-clicked
|
12
|
-
MiddleClick : Event that occurs when the tray icon is clicked with the middle button
|
13
|
-
RightClick : Event that occurs when the tray icon is right-clicked (context menu)
|
14
|
-
LeftClick : Event that occurs when the tray icon is left-clicked
|
15
|
-
Unknown : Unknown event
|
16
|
-
|
17
|
-
Usage Example
|
18
|
-
-------------
|
19
|
-
```python
|
20
|
-
from pyloid import Pyloid, TrayEvent
|
21
|
-
|
22
|
-
app = Pyloid(app_name="Pyloid-App")
|
23
|
-
|
24
|
-
app.set_tray_icon("icons/icon.ico")
|
25
|
-
|
26
|
-
app.set_tray_actions(
|
27
|
-
{
|
28
|
-
TrayEvent.DoubleClick: lambda: print("Tray icon was double-clicked."),
|
29
|
-
TrayEvent.MiddleClick: lambda: print("Tray icon was middle-clicked."),
|
30
|
-
TrayEvent.RightClick: lambda: print("Tray icon was right-clicked."),
|
31
|
-
TrayEvent.LeftClick: lambda: print("Tray icon was left-clicked."),
|
32
|
-
}
|
33
|
-
)
|
34
|
-
```
|
35
|
-
"""
|
36
|
-
DoubleClick = QSystemTrayIcon.ActivationReason.DoubleClick
|
37
|
-
MiddleClick = QSystemTrayIcon.ActivationReason.MiddleClick
|
38
|
-
RightClick = QSystemTrayIcon.ActivationReason.Context
|
39
|
-
LeftClick = QSystemTrayIcon.ActivationReason.Trigger
|
40
|
-
Unknown = QSystemTrayIcon.ActivationReason.Unknown
|
41
|
-
|
42
|
-
def __eq__(self, other):
|
43
|
-
if isinstance(other, QSystemTrayIcon.ActivationReason):
|
44
|
-
return self.value == other
|
45
|
-
return super().__eq__(other)
|
46
|
-
|
47
|
-
def __hash__(self):
|
48
|
-
return hash(self.value)
|
1
|
+
from enum import Enum
|
2
|
+
from PySide6.QtWidgets import QSystemTrayIcon
|
3
|
+
|
4
|
+
|
5
|
+
class TrayEvent(Enum):
|
6
|
+
"""
|
7
|
+
TrayEvent is an enumeration class representing events related to the system tray icon.
|
8
|
+
|
9
|
+
Enumeration Members
|
10
|
+
-------------------
|
11
|
+
DoubleClick : Event that occurs when the tray icon is double-clicked
|
12
|
+
MiddleClick : Event that occurs when the tray icon is clicked with the middle button
|
13
|
+
RightClick : Event that occurs when the tray icon is right-clicked (context menu)
|
14
|
+
LeftClick : Event that occurs when the tray icon is left-clicked
|
15
|
+
Unknown : Unknown event
|
16
|
+
|
17
|
+
Usage Example
|
18
|
+
-------------
|
19
|
+
```python
|
20
|
+
from pyloid import Pyloid, TrayEvent
|
21
|
+
|
22
|
+
app = Pyloid(app_name="Pyloid-App")
|
23
|
+
|
24
|
+
app.set_tray_icon("icons/icon.ico")
|
25
|
+
|
26
|
+
app.set_tray_actions(
|
27
|
+
{
|
28
|
+
TrayEvent.DoubleClick: lambda: print("Tray icon was double-clicked."),
|
29
|
+
TrayEvent.MiddleClick: lambda: print("Tray icon was middle-clicked."),
|
30
|
+
TrayEvent.RightClick: lambda: print("Tray icon was right-clicked."),
|
31
|
+
TrayEvent.LeftClick: lambda: print("Tray icon was left-clicked."),
|
32
|
+
}
|
33
|
+
)
|
34
|
+
```
|
35
|
+
"""
|
36
|
+
DoubleClick = QSystemTrayIcon.ActivationReason.DoubleClick
|
37
|
+
MiddleClick = QSystemTrayIcon.ActivationReason.MiddleClick
|
38
|
+
RightClick = QSystemTrayIcon.ActivationReason.Context
|
39
|
+
LeftClick = QSystemTrayIcon.ActivationReason.Trigger
|
40
|
+
Unknown = QSystemTrayIcon.ActivationReason.Unknown
|
41
|
+
|
42
|
+
def __eq__(self, other):
|
43
|
+
if isinstance(other, QSystemTrayIcon.ActivationReason):
|
44
|
+
return self.value == other
|
45
|
+
return super().__eq__(other)
|
46
|
+
|
47
|
+
def __hash__(self):
|
48
|
+
return hash(self.value)
|
pyloid/utils.py
CHANGED
@@ -1,122 +1,122 @@
|
|
1
|
-
import sys
|
2
|
-
import os
|
3
|
-
import platform
|
4
|
-
from typing import Optional
|
5
|
-
|
6
|
-
|
7
|
-
def get_production_path(path: Optional[str] = None) -> Optional[str]:
|
8
|
-
"""
|
9
|
-
Returns the path to the resource files in a production environment.
|
10
|
-
If running as a regular Python script, returns None.
|
11
|
-
|
12
|
-
Returns
|
13
|
-
-------
|
14
|
-
str | None
|
15
|
-
The path to the resource files if in a production environment,
|
16
|
-
otherwise None.
|
17
|
-
|
18
|
-
Examples
|
19
|
-
--------
|
20
|
-
>>> from pyloid.utils import get_production_path
|
21
|
-
>>> path = get_production_path("assets/icon.ico")
|
22
|
-
>>> if path:
|
23
|
-
>>> print(f"Production path: {path}")
|
24
|
-
>>> else:
|
25
|
-
>>> print("Not in a production environment.")
|
26
|
-
"""
|
27
|
-
if is_production():
|
28
|
-
if hasattr(sys, '_MEIPASS'):
|
29
|
-
# PyInstaller
|
30
|
-
base_path = sys._MEIPASS
|
31
|
-
else:
|
32
|
-
# Nuitka
|
33
|
-
base_path = os.path.dirname(sys.executable)
|
34
|
-
|
35
|
-
if base_path is None:
|
36
|
-
# 환경변수가 없는 경우 실행 파일 디렉토리 사용
|
37
|
-
base_path = os.path.dirname(os.path.abspath(sys.argv[0]))
|
38
|
-
|
39
|
-
|
40
|
-
return os.path.join(base_path, path) if path else base_path
|
41
|
-
else:
|
42
|
-
return None
|
43
|
-
|
44
|
-
|
45
|
-
def is_production() -> bool:
|
46
|
-
"""
|
47
|
-
Checks if the current environment is a production environment.
|
48
|
-
|
49
|
-
Returns
|
50
|
-
-------
|
51
|
-
bool
|
52
|
-
True if in a production environment, False otherwise.
|
53
|
-
|
54
|
-
Examples
|
55
|
-
--------
|
56
|
-
>>> from pyloid.utils import is_production
|
57
|
-
>>> if is_production():
|
58
|
-
>>> print("Running in production environment.")
|
59
|
-
>>> else:
|
60
|
-
>>> print("Not in production environment.")
|
61
|
-
"""
|
62
|
-
# Nuitka 환경 확인을 추가
|
63
|
-
if '__compiled__' in globals():
|
64
|
-
return True
|
65
|
-
# PyInstaller 환경 확인
|
66
|
-
return getattr(sys, 'frozen', False)
|
67
|
-
|
68
|
-
|
69
|
-
def get_platform() -> str:
|
70
|
-
"""
|
71
|
-
Returns the name of the current system's platform.
|
72
|
-
|
73
|
-
This function uses `platform.system()` to return the name of the current operating system.
|
74
|
-
|
75
|
-
Returns
|
76
|
-
-------
|
77
|
-
"windows" | "macos" | "linux"
|
78
|
-
- "windows" for Windows systems
|
79
|
-
- "macos" for macOS systems
|
80
|
-
- "linux" for Linux systems
|
81
|
-
|
82
|
-
Examples
|
83
|
-
--------
|
84
|
-
>>> from pyloid.utils import get_platform
|
85
|
-
>>> platform_name = get_platform()
|
86
|
-
>>> print(platform_name)
|
87
|
-
windows
|
88
|
-
"""
|
89
|
-
os_name = platform.system().lower()
|
90
|
-
os_type = {
|
91
|
-
'darwin': 'macos',
|
92
|
-
'linux': 'linux',
|
93
|
-
'windows': 'windows'
|
94
|
-
}.get(os_name)
|
95
|
-
if os_type is None:
|
96
|
-
raise ValueError(f"Unsupported platform: {os_name}")
|
97
|
-
|
98
|
-
return os_type
|
99
|
-
|
100
|
-
def get_absolute_path(path: str) -> str:
|
101
|
-
"""
|
102
|
-
Returns the absolute path of the given relative path.
|
103
|
-
|
104
|
-
Parameters
|
105
|
-
----------
|
106
|
-
path : str
|
107
|
-
The relative path to get the absolute path of.
|
108
|
-
|
109
|
-
Returns
|
110
|
-
-------
|
111
|
-
str
|
112
|
-
The absolute path of the given relative path.
|
113
|
-
|
114
|
-
Examples
|
115
|
-
--------
|
116
|
-
>>> from pyloid.utils import get_absolute_path
|
117
|
-
>>> absolute_path = get_absolute_path("assets/icon.ico")
|
118
|
-
>>> print(absolute_path)
|
119
|
-
C:/Users/aaaap/Documents/pyloid/pyloid/assets/icon.ico
|
120
|
-
"""
|
121
|
-
return os.path.normpath(os.path.abspath(path))
|
122
|
-
|
1
|
+
import sys
|
2
|
+
import os
|
3
|
+
import platform
|
4
|
+
from typing import Optional
|
5
|
+
|
6
|
+
|
7
|
+
def get_production_path(path: Optional[str] = None) -> Optional[str]:
|
8
|
+
"""
|
9
|
+
Returns the path to the resource files in a production environment.
|
10
|
+
If running as a regular Python script, returns None.
|
11
|
+
|
12
|
+
Returns
|
13
|
+
-------
|
14
|
+
str | None
|
15
|
+
The path to the resource files if in a production environment,
|
16
|
+
otherwise None.
|
17
|
+
|
18
|
+
Examples
|
19
|
+
--------
|
20
|
+
>>> from pyloid.utils import get_production_path
|
21
|
+
>>> path = get_production_path("assets/icon.ico")
|
22
|
+
>>> if path:
|
23
|
+
>>> print(f"Production path: {path}")
|
24
|
+
>>> else:
|
25
|
+
>>> print("Not in a production environment.")
|
26
|
+
"""
|
27
|
+
if is_production():
|
28
|
+
if hasattr(sys, '_MEIPASS'):
|
29
|
+
# PyInstaller
|
30
|
+
base_path = sys._MEIPASS
|
31
|
+
else:
|
32
|
+
# Nuitka
|
33
|
+
base_path = os.path.dirname(sys.executable)
|
34
|
+
|
35
|
+
if base_path is None:
|
36
|
+
# 환경변수가 없는 경우 실행 파일 디렉토리 사용
|
37
|
+
base_path = os.path.dirname(os.path.abspath(sys.argv[0]))
|
38
|
+
|
39
|
+
|
40
|
+
return os.path.join(base_path, path) if path else base_path
|
41
|
+
else:
|
42
|
+
return None
|
43
|
+
|
44
|
+
|
45
|
+
def is_production() -> bool:
|
46
|
+
"""
|
47
|
+
Checks if the current environment is a production environment.
|
48
|
+
|
49
|
+
Returns
|
50
|
+
-------
|
51
|
+
bool
|
52
|
+
True if in a production environment, False otherwise.
|
53
|
+
|
54
|
+
Examples
|
55
|
+
--------
|
56
|
+
>>> from pyloid.utils import is_production
|
57
|
+
>>> if is_production():
|
58
|
+
>>> print("Running in production environment.")
|
59
|
+
>>> else:
|
60
|
+
>>> print("Not in production environment.")
|
61
|
+
"""
|
62
|
+
# Nuitka 환경 확인을 추가
|
63
|
+
if '__compiled__' in globals():
|
64
|
+
return True
|
65
|
+
# PyInstaller 환경 확인
|
66
|
+
return getattr(sys, 'frozen', False)
|
67
|
+
|
68
|
+
|
69
|
+
def get_platform() -> str:
|
70
|
+
"""
|
71
|
+
Returns the name of the current system's platform.
|
72
|
+
|
73
|
+
This function uses `platform.system()` to return the name of the current operating system.
|
74
|
+
|
75
|
+
Returns
|
76
|
+
-------
|
77
|
+
"windows" | "macos" | "linux"
|
78
|
+
- "windows" for Windows systems
|
79
|
+
- "macos" for macOS systems
|
80
|
+
- "linux" for Linux systems
|
81
|
+
|
82
|
+
Examples
|
83
|
+
--------
|
84
|
+
>>> from pyloid.utils import get_platform
|
85
|
+
>>> platform_name = get_platform()
|
86
|
+
>>> print(platform_name)
|
87
|
+
windows
|
88
|
+
"""
|
89
|
+
os_name = platform.system().lower()
|
90
|
+
os_type = {
|
91
|
+
'darwin': 'macos',
|
92
|
+
'linux': 'linux',
|
93
|
+
'windows': 'windows'
|
94
|
+
}.get(os_name)
|
95
|
+
if os_type is None:
|
96
|
+
raise ValueError(f"Unsupported platform: {os_name}")
|
97
|
+
|
98
|
+
return os_type
|
99
|
+
|
100
|
+
def get_absolute_path(path: str) -> str:
|
101
|
+
"""
|
102
|
+
Returns the absolute path of the given relative path.
|
103
|
+
|
104
|
+
Parameters
|
105
|
+
----------
|
106
|
+
path : str
|
107
|
+
The relative path to get the absolute path of.
|
108
|
+
|
109
|
+
Returns
|
110
|
+
-------
|
111
|
+
str
|
112
|
+
The absolute path of the given relative path.
|
113
|
+
|
114
|
+
Examples
|
115
|
+
--------
|
116
|
+
>>> from pyloid.utils import get_absolute_path
|
117
|
+
>>> absolute_path = get_absolute_path("assets/icon.ico")
|
118
|
+
>>> print(absolute_path)
|
119
|
+
C:/Users/aaaap/Documents/pyloid/pyloid/assets/icon.ico
|
120
|
+
"""
|
121
|
+
return os.path.normpath(os.path.abspath(path))
|
122
|
+
|