pyloid 0.24.5__py3-none-any.whl → 0.24.6__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
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyloid
3
- Version: 0.24.5
3
+ Version: 0.24.6
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -1,14 +1,14 @@
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=EkYcqwdX_WC2woIUcElwI7E4BgpXk_a_hgJJcDS1vc4,104226
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
14
  pyloid/store.py,sha256=teoa-HYzwm93Rivcw3AhKw6rAmQqQ_kmF6XYSkC3G_I,4541
@@ -17,7 +17,7 @@ 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.6.dist-info/LICENSE,sha256=MTYF-6xpRekyTUglRweWtbfbwBL1I_3Bgfbm_SNOuI8,11525
21
+ pyloid-0.24.6.dist-info/METADATA,sha256=MUdtV5-iru99UsWv46KP_VVAtmFu3f-nP6NAreUTy1g,2204
22
+ pyloid-0.24.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
23
+ pyloid-0.24.6.dist-info/RECORD,,