pyloid 0.24.5__py3-none-any.whl → 0.24.7__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/browser_window.py CHANGED
@@ -40,7 +40,7 @@ from PySide6.QtWidgets import QSplashScreen, QLabel
40
40
  from typing import TYPE_CHECKING, Any
41
41
  from PySide6.QtWebEngineCore import (
42
42
  QWebEngineSettings,
43
- QWebEngineDesktopMediaRequest,
43
+ # QWebEngineDesktopMediaRequest, # 6.8.3 부터
44
44
  )
45
45
  import threading
46
46
 
@@ -55,7 +55,7 @@ class CustomWebPage(QWebEnginePage):
55
55
  def __init__(self, profile=None):
56
56
  super().__init__(profile)
57
57
  self.featurePermissionRequested.connect(self._handlePermissionRequest)
58
- self.desktopMediaRequested.connect(self._handleDesktopMediaRequest)
58
+ # self.desktopMediaRequested.connect(self._handleDesktopMediaRequest)
59
59
  self._permission_handlers = {}
60
60
  self._desktop_media_handler = None
61
61
  self._url_handlers = {} # URL 핸들러 저장을 위한 딕셔너리 추가
@@ -78,27 +78,27 @@ class CustomWebPage(QWebEnginePage):
78
78
  """Register a handler for a specific permission"""
79
79
  self._permission_handlers[feature] = handler
80
80
 
81
- def _handleDesktopMediaRequest(self, request: QWebEngineDesktopMediaRequest):
82
- return
83
- print("Desktop media request received:", request)
81
+ # def _handleDesktopMediaRequest(self, request: QWebEngineDesktopMediaRequest):
82
+ # return
83
+ # print("Desktop media request received:", request)
84
84
 
85
- # 사용 가능한 화면 목록 확인
86
- screens_model = request.screensModel()
87
- print("\n=== Available Screens ===")
88
- for i in range(screens_model.rowCount()):
89
- screen_index = screens_model.index(i)
90
- screen_name = screens_model.data(screen_index)
91
- print(f"Screen {i}: {screen_name}")
85
+ # # 사용 가능한 화면 목록 확인
86
+ # screens_model = request.screensModel()
87
+ # print("\n=== Available Screens ===")
88
+ # for i in range(screens_model.rowCount()):
89
+ # screen_index = screens_model.index(i)
90
+ # screen_name = screens_model.data(screen_index)
91
+ # print(f"Screen {i}: {screen_name}")
92
92
 
93
- # 사용 가능한 창 목록 확인
94
- windows_model = request.windowsModel()
95
- print("\n=== Available Windows ===")
96
- for i in range(windows_model.rowCount()):
97
- window_index = windows_model.index(i)
98
- window_name = windows_model.data(window_index)
99
- print(f"Window {i}: {window_name}")
93
+ # # 사용 가능한 창 목록 확인
94
+ # windows_model = request.windowsModel()
95
+ # print("\n=== Available Windows ===")
96
+ # for i in range(windows_model.rowCount()):
97
+ # window_index = windows_model.index(i)
98
+ # window_name = windows_model.data(window_index)
99
+ # print(f"Window {i}: {window_name}")
100
100
 
101
- request.selectWindow(windows_model.index(3))
101
+ # request.selectWindow(windows_model.index(3))
102
102
 
103
103
  # # interceptor ( navigation request )
104
104
  # def acceptNavigationRequest(self, url, navigation_type, is_main_frame):
@@ -317,6 +317,7 @@ class _BrowserWindow:
317
317
  dev_tools: bool = False,
318
318
  # js_apis: List[PyloidAPI] = [],
319
319
  rpc: Optional[PyloidRPC] = None,
320
+ transparent: bool = False,
320
321
  ):
321
322
  ###########################################################################################
322
323
  self.id = str(uuid.uuid4()) # Generate unique ID
@@ -344,6 +345,7 @@ class _BrowserWindow:
344
345
  self.x = x
345
346
  self.y = y
346
347
  self.frame = frame
348
+ self.transparent = transparent
347
349
  self.context_menu = context_menu
348
350
  self.dev_tools = dev_tools
349
351
 
@@ -413,6 +415,20 @@ class _BrowserWindow:
413
415
 
414
416
  self._window.show()
415
417
 
418
+ def _apply_transparency(self):
419
+ """Applies transparency settings based on self.transparent and self.frame."""
420
+ if self.transparent:
421
+ # It's generally better if FramelessWindowHint is set for full transparency,
422
+ # but WA_TranslucentBackground can still have effects otherwise.
423
+ self._window.setAttribute(Qt.WA_TranslucentBackground, True)
424
+ self.web_view.setAttribute(Qt.WA_TranslucentBackground, True)
425
+ self.web_view.page().setBackgroundColor(Qt.transparent)
426
+ else:
427
+ self._window.setAttribute(Qt.WA_TranslucentBackground, False)
428
+ self.web_view.setAttribute(Qt.WA_TranslucentBackground, False)
429
+ # Reset background color for web_view page, QColor() or a specific color like Qt.white
430
+ self.web_view.page().setBackgroundColor(Qt.white)
431
+
416
432
  def _load(self):
417
433
  self.set_title(self.title)
418
434
 
@@ -491,9 +507,11 @@ class _BrowserWindow:
491
507
  # Remove title bar and borders (if needed)
492
508
  if not self.frame:
493
509
  self._window.setWindowFlags(Qt.FramelessWindowHint)
494
- self._window.setAttribute(Qt.WA_TranslucentBackground)
495
- self.web_view.setAttribute(Qt.WA_TranslucentBackground)
496
- self.web_view.page().setBackgroundColor(Qt.transparent)
510
+ else:
511
+ # Ensure standard window flags if frame is True, otherwise flags might be missing
512
+ self._window.setWindowFlags(Qt.Window)
513
+
514
+ self._apply_transparency()
497
515
 
498
516
  # Disable default context menu
499
517
  if not self.context_menu:
@@ -817,12 +835,43 @@ class _BrowserWindow:
817
835
  self._window.setWindowFlags(Qt.Window)
818
836
  else:
819
837
  self._window.setWindowFlags(Qt.FramelessWindowHint)
820
- self._window.setAttribute(Qt.WA_TranslucentBackground)
821
- self.web_view.setAttribute(Qt.WA_TranslucentBackground)
822
- self.web_view.page().setBackgroundColor(Qt.transparent)
838
+
839
+ self._apply_transparency()
840
+
823
841
  if was_visible:
824
842
  self._window.show()
825
843
 
844
+ def set_transparent(self, transparent: bool):
845
+ """
846
+ Sets the transparency of the window.
847
+
848
+ Parameters
849
+ ----------
850
+ transparent : bool
851
+ If True, the window background will be transparent.
852
+ If False, it will be opaque.
853
+
854
+ Examples
855
+ --------
856
+ >>> window.set_transparent(True)
857
+ """
858
+ self.transparent = transparent
859
+ self._apply_transparency()
860
+
861
+ if self._window.isVisible():
862
+ self._window.show()
863
+
864
+ def get_transparent(self) -> bool:
865
+ """
866
+ Returns the transparency state of the window.
867
+
868
+ Returns
869
+ -------
870
+ bool
871
+ True if the window is set to be transparent, False otherwise.
872
+ """
873
+ return self.transparent
874
+
826
875
  def set_context_menu(self, context_menu: bool):
827
876
  """
828
877
  Sets the context menu of the window.
@@ -1296,6 +1345,7 @@ class _BrowserWindow:
1296
1345
  "x": self.x,
1297
1346
  "y": self.y,
1298
1347
  "frame": self.frame,
1348
+ "transparent": self.transparent, # Add transparent to properties
1299
1349
  "context_menu": self.context_menu,
1300
1350
  "dev_tools": self.dev_tools,
1301
1351
  }
@@ -2069,14 +2119,26 @@ class BrowserWindow(QObject):
2069
2119
  height: int,
2070
2120
  x: int,
2071
2121
  y: int,
2072
- frame: bool,
2073
- context_menu: bool,
2074
- dev_tools: bool,
2122
+ frame: bool = True,
2123
+ context_menu: bool = False,
2124
+ dev_tools: bool = False,
2075
2125
  rpc: Optional[PyloidRPC] = None,
2126
+ transparent: bool = False,
2076
2127
  ):
2077
2128
  super().__init__()
2078
2129
  self._window = _BrowserWindow(
2079
- app, self, title, width, height, x, y, frame, context_menu, dev_tools, rpc
2130
+ app,
2131
+ self,
2132
+ title,
2133
+ width,
2134
+ height,
2135
+ x,
2136
+ y,
2137
+ frame,
2138
+ context_menu,
2139
+ dev_tools,
2140
+ rpc,
2141
+ transparent,
2080
2142
  )
2081
2143
  self.command_signal.connect(self._handle_command)
2082
2144
 
@@ -2112,6 +2174,10 @@ class BrowserWindow(QObject):
2112
2174
  result = self._window.set_position_by_anchor(params["anchor"])
2113
2175
  elif command_type == "set_frame":
2114
2176
  result = self._window.set_frame(params["frame"])
2177
+ elif command_type == "set_transparent":
2178
+ result = self._window.set_transparent(params["transparent"])
2179
+ elif command_type == "get_transparent":
2180
+ result = self._window.get_transparent()
2115
2181
  elif command_type == "set_context_menu":
2116
2182
  result = self._window.set_context_menu(params["context_menu"])
2117
2183
  elif command_type == "set_dev_tools":
@@ -2395,6 +2461,34 @@ class BrowserWindow(QObject):
2395
2461
  """
2396
2462
  return self.execute_command("set_frame", {"frame": frame})
2397
2463
 
2464
+ # TODO: Can't use this function in runtime
2465
+ # def set_transparent(self, transparent: bool) -> None:
2466
+ # """
2467
+ # Sets the transparency of the window.
2468
+
2469
+ # Parameters
2470
+ # ----------
2471
+ # transparent : bool
2472
+ # If True, the window background will be transparent.
2473
+ # If False, it will be opaque.
2474
+
2475
+ # Examples
2476
+ # --------
2477
+ # >>> window.set_transparent(True)
2478
+ # """
2479
+ # return self.execute_command("set_transparent", {"transparent": transparent})
2480
+
2481
+ def get_transparent(self) -> bool:
2482
+ """
2483
+ Returns the transparency state of the window.
2484
+
2485
+ Returns
2486
+ -------
2487
+ bool
2488
+ True if the window is set to be transparent, False otherwise.
2489
+ """
2490
+ return self.execute_command("get_transparent", {})
2491
+
2398
2492
  def set_context_menu(self, context_menu: bool) -> None:
2399
2493
  """
2400
2494
  Sets the context menu of the window.
pyloid/pyloid.py CHANGED
@@ -243,6 +243,7 @@ class _Pyloid(QApplication):
243
243
  context_menu: bool = False,
244
244
  dev_tools: bool = False,
245
245
  rpc: Optional[PyloidRPC] = None,
246
+ transparent: bool = False,
246
247
  ) -> BrowserWindow:
247
248
  """
248
249
  Creates a new browser window.
@@ -267,6 +268,8 @@ class _Pyloid(QApplication):
267
268
  Whether to use developer tools (default is False)
268
269
  rpc : PyloidRPC, optional
269
270
  The RPC server instance to be used in the window
271
+ transparent : bool, optional
272
+ Whether the window is transparent (default is False)
270
273
 
271
274
  Returns
272
275
  -------
@@ -290,6 +293,7 @@ class _Pyloid(QApplication):
290
293
  context_menu,
291
294
  dev_tools,
292
295
  rpc,
296
+ transparent,
293
297
  )
294
298
  self.windows_dict[window._window.id] = window
295
299
  # latest_window_id = list(self.windows_dict.keys())[-1]
@@ -1654,6 +1658,7 @@ class Pyloid(QObject):
1654
1658
  context_menu=params.get("context_menu", False),
1655
1659
  dev_tools=params.get("dev_tools", False),
1656
1660
  rpc=params.get("rpc", None),
1661
+ transparent=params.get("transparent", False),
1657
1662
  )
1658
1663
  result = window
1659
1664
 
@@ -1829,6 +1834,7 @@ class Pyloid(QObject):
1829
1834
  context_menu: bool = False,
1830
1835
  dev_tools: bool = False,
1831
1836
  rpc: Optional[PyloidRPC] = None,
1837
+ transparent: bool = False,
1832
1838
  ) -> BrowserWindow:
1833
1839
  """
1834
1840
  Creates a new browser window.
@@ -1853,6 +1859,8 @@ class Pyloid(QObject):
1853
1859
  Whether to use developer tools (default is False)
1854
1860
  rpc : PyloidRPC, optional
1855
1861
  The RPC server instance to be used in the window
1862
+ transparent : bool, optional
1863
+ Whether the window is transparent (default is False)
1856
1864
 
1857
1865
  Returns
1858
1866
  -------
@@ -1874,6 +1882,7 @@ class Pyloid(QObject):
1874
1882
  "context_menu": context_menu,
1875
1883
  "dev_tools": dev_tools,
1876
1884
  "rpc": rpc,
1885
+ "transparent": transparent,
1877
1886
  }
1878
1887
  return self.execute_command("create_window", params)
1879
1888
 
pyloid/store.py CHANGED
@@ -20,7 +20,7 @@ class Store:
20
20
  os.makedirs(os.path.dirname(path), exist_ok=True)
21
21
  self.db = PickleDB(path)
22
22
 
23
- def get(self, key: str) -> Any:
23
+ def get(self, key: str, default: Any = None) -> Any:
24
24
  """
25
25
  Retrieve the value associated with the specified key.
26
26
 
@@ -28,6 +28,8 @@ class Store:
28
28
  ----------
29
29
  key: str
30
30
  The key to look up in the database
31
+ default: Any
32
+ The value to return if the value does not exist in the database
31
33
 
32
34
  Returns
33
35
  -------
@@ -44,8 +46,11 @@ class Store:
44
46
  {'name': 'John Doe', 'age': 30}
45
47
  >>> print(store.get("non_existent_key"))
46
48
  None
49
+ >>> print(store.get("non_existent_key", "default_value"))
50
+ 'default_value'
47
51
  """
48
- return self.db.get(key)
52
+ stored_value = self.db.get(key)
53
+ return stored_value if stored_value is not None else default
49
54
 
50
55
  def set(self, key: str, value: Any) -> bool:
51
56
  """
@@ -198,4 +198,4 @@ Apache License
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
199
199
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
200
  See the License for the specific language governing permissions and
201
- limitations under the License.
201
+ limitations under the License.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyloid
3
- Version: 0.24.5
3
+ Version: 0.24.7
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -25,8 +25,7 @@ Description-Content-Type: text/markdown
25
25
 
26
26
  <h2 align="center" style="font-size: 28px;"><b>Pyloid: Thread-Safe Desktop Apps—Unified with Any Frontend and Python Technology</b></h2>
27
27
 
28
-
29
- ## 💡 Key Features
28
+ ## 💡 Key Features
30
29
 
31
30
  - **All Frontend Frameworks** are supported
32
31
  - **All features necessary** for a desktop application are implemented
@@ -39,8 +38,6 @@ Description-Content-Type: text/markdown
39
38
  - Window Customization
40
39
  - **Detailed Numpy-style Docstrings**
41
40
 
42
-
43
-
44
41
  ## 🚀 Getting Started
45
42
 
46
43
  ### [Prerequisites](https://docs.pyloid.com/getting-started/prerequisites)
@@ -55,6 +52,10 @@ Description-Content-Type: text/markdown
55
52
  npm create pyloid-app@latest
56
53
  ```
57
54
 
55
+ ## Discord 🎉
56
+
57
+ [Our Discord!](https://discord.gg/VTqexxxTy9)
58
+
58
59
  ## Documentation 📚
59
60
 
60
61
  [Pyloid Documentation](https://docs.pyloid.com/)
@@ -1,23 +1,23 @@
1
1
  pyloid/__init__.py,sha256=YKwMCSOds1QVi9N7EGfY0Z7BEjJn8j6HGqRblZlZClA,235
2
2
  pyloid/api.py,sha256=A61Kmddh8BlpT3LfA6NbPQNzFmD95vQ4WKX53oKsGYU,2419
3
3
  pyloid/autostart.py,sha256=K7DQYl4LHItvPp0bt1V9WwaaZmVSTeGvadkcwG-KKrI,3899
4
- pyloid/browser_window.py,sha256=ujdygs3Oq1GXH-lh9u1rStez6Zckuf-X1oIPRR1Mb5M,101262
4
+ pyloid/browser_window.py,sha256=mm38dDvicahkY5zM-zqcCJAqFYC9H6Va_wtcSEd4X-0,104281
5
5
  pyloid/custom/titlebar.py,sha256=itzK9pJbZMQ7BKca9kdbuHMffurrw15UijR6OU03Xsk,3894
6
6
  pyloid/filewatcher.py,sha256=3M5zWVUf1OhlkWJcDFC8ZA9agO4Q-U8WdgGpy6kaVz0,4601
7
7
  pyloid/js_api/base.py,sha256=Z3ID-4AJ0eHusmljRltlSaK4m2RKvRNfmqX76NLF77o,8585
8
8
  pyloid/js_api/event_api.py,sha256=w0z1DcmwcmseqfcoZWgsQmFC2iBCgTMVJubTaHeXI1c,957
9
9
  pyloid/js_api/window_api.py,sha256=-isphU3m2wGB5U0yZrSuK_4XiBz2mG45HsjYTUq7Fxs,7348
10
10
  pyloid/monitor.py,sha256=1mXvHm5deohnNlTLcRx4sT4x-stnOIb0dUQnnxN50Uo,28295
11
- pyloid/pyloid.py,sha256=y3kHGahvNkJ_4vMESBVHh1j3OU9foM4GLQF2MID3Vhg,84099
11
+ pyloid/pyloid.py,sha256=DSHpMRDW4WvZgAAo2nJMesMJuOkNTVEEsDhCFIvjB5w,84509
12
12
  pyloid/rpc.py,sha256=OnF1sRGok9OJ-Q5519eQARD4oZTohyPhsPAT2Mg4_Gg,20377
13
13
  pyloid/serve.py,sha256=wJIBqiLr1-8FvBdV3yybeBtVXsu94FfWYKjHL0eQ68s,1444
14
- pyloid/store.py,sha256=teoa-HYzwm93Rivcw3AhKw6rAmQqQ_kmF6XYSkC3G_I,4541
14
+ pyloid/store.py,sha256=8PnBxtkUgbF8Lxh-iYlEuhbLE76bGBF8t5KV5u5NzoQ,4831
15
15
  pyloid/thread_pool.py,sha256=fKOBb8jMfZn_7crA_fJCno8dObBRZE31EIWaNQ759aw,14616
16
16
  pyloid/timer.py,sha256=RqMsChFUd93cxMVgkHWiIKrci0QDTBgJSTULnAtYT8M,8712
17
17
  pyloid/tray.py,sha256=D12opVEc2wc2T4tK9epaN1oOdeziScsIVNM2uCN7C-A,1710
18
18
  pyloid/url_interceptor.py,sha256=AFjPANDELc9-E-1TnVvkNVc-JZBJYf0677dWQ8LDaqw,726
19
19
  pyloid/utils.py,sha256=J6owgVE1YDOEfcOPmoP9m9Q6nbYDyNEo9uqPsJs5p5g,6644
20
- pyloid-0.24.5.dist-info/LICENSE,sha256=MTYF-6xpRekyTUglRweWtbfbwBL1I_3Bgfbm_SNOuI8,11525
21
- pyloid-0.24.5.dist-info/METADATA,sha256=zn8TgAWx2pKIHGsJOJvpRr0IUL42VQiHXmV8DNizAvY,2204
22
- pyloid-0.24.5.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
23
- pyloid-0.24.5.dist-info/RECORD,,
20
+ pyloid-0.24.7.dist-info/LICENSE,sha256=F96EzotgWhhpnQTW2TcdoqrMDir1jyEo6H915tGQ-QE,11524
21
+ pyloid-0.24.7.dist-info/METADATA,sha256=cEgj0FYsOyzMNrUuI6QEPY3WmNPFg0WaYVAMMISt79g,2264
22
+ pyloid-0.24.7.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
23
+ pyloid-0.24.7.dist-info/RECORD,,