pyloid 0.15.1__py3-none-any.whl → 0.16.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pyloid/browser_window.py CHANGED
@@ -22,6 +22,8 @@ from PySide6.QtWidgets import (
22
22
  )
23
23
  from .custom.titlebar import CustomTitleBar
24
24
  from .js_api.window_api import WindowAPI
25
+ from PySide6.QtGui import QPixmap, QMovie
26
+ from PySide6.QtWidgets import QSplashScreen, QLabel
25
27
 
26
28
 
27
29
  # 어차피 load 부분에만 쓰이니까 나중에 분리해서 load 위에서 선언하자.
@@ -341,6 +343,10 @@ class BrowserWindow:
341
343
  ]
342
344
  )
343
345
  self.web_view.page().runJavaScript(js_code % js_api_init)
346
+
347
+ # if splash screen is set, close it when the page is loaded
348
+ if self.close_on_load and self.splash_screen:
349
+ self.close_splash_screen()
344
350
  else:
345
351
  pass
346
352
 
@@ -1261,3 +1267,229 @@ class BrowserWindow:
1261
1267
  ```
1262
1268
  """
1263
1269
  return self.resizable
1270
+
1271
+ ###########################################################################################
1272
+ # For Custom Pyside6 Features
1273
+ ###########################################################################################
1274
+ def get_QMainWindow(self) -> QMainWindow:
1275
+ """
1276
+ Returns the QMainWindow object of the window.
1277
+
1278
+ you can use all the features of QMainWindow for customizing the window.
1279
+
1280
+ Returns
1281
+ -------
1282
+ QMainWindow
1283
+ QMainWindow object of the window
1284
+
1285
+ Examples
1286
+ --------
1287
+ ```python
1288
+ from PySide6.QtCore import Qt
1289
+ from pyloid import Pyloid
1290
+
1291
+ app = Pyloid(app_name="Pyloid-App")
1292
+
1293
+ window = app.create_window("pyloid-window")
1294
+ qmain = window.get_QMainWindow()
1295
+
1296
+ qmain.setWindowFlags(qmain.windowFlags() | Qt.WindowStaysOnTopHint) # window stays on top
1297
+ ```
1298
+ """
1299
+ return self._window
1300
+
1301
+ ###########################################################################################
1302
+ # QMainWindow flags
1303
+ ###########################################################################################
1304
+ def set_window_stay_on_top(self, on_top: bool):
1305
+ """
1306
+ Sets the window stay on top flag of the window.
1307
+
1308
+ Parameters
1309
+ ----------
1310
+ on_top : bool
1311
+ True to keep the window on top, False otherwise
1312
+
1313
+ Examples
1314
+ --------
1315
+ ```python
1316
+ window.set_window_stay_on_top(True)
1317
+ window.set_window_stay_on_top(False)
1318
+ ```
1319
+ """
1320
+ flags = self._window.windowFlags()
1321
+ if on_top:
1322
+ flags |= Qt.WindowStaysOnTopHint
1323
+ else:
1324
+ flags &= ~Qt.WindowStaysOnTopHint
1325
+
1326
+ # Maintain existing flags while only changing WindowStaysOnTopHint
1327
+ # Explicitly add the close button
1328
+ flags |= Qt.WindowCloseButtonHint
1329
+
1330
+ self._window.setWindowFlags(flags)
1331
+
1332
+ # Show the window again to apply the changes
1333
+ self._window.show()
1334
+
1335
+ def set_window_stay_on_bottom(self, on_bottom: bool):
1336
+ """
1337
+ Sets the window stay on bottom flag of the window.
1338
+
1339
+ Parameters
1340
+ ----------
1341
+ on_bottom : bool
1342
+ True to keep the window on bottom, False otherwise
1343
+
1344
+ Examples
1345
+ --------
1346
+ ```python
1347
+ window.set_window_stay_on_bottom(True)
1348
+ window.set_window_stay_on_bottom(False)
1349
+ ```
1350
+ """
1351
+ flags = self._window.windowFlags()
1352
+ if on_bottom:
1353
+ flags |= Qt.WindowStaysOnBottomHint
1354
+ else:
1355
+ flags &= ~Qt.WindowStaysOnBottomHint
1356
+
1357
+ # Maintain existing flags while only changing WindowStaysOnBottomHint
1358
+ # Explicitly add the close button
1359
+ flags |= Qt.WindowCloseButtonHint
1360
+
1361
+ self._window.setWindowFlags(flags)
1362
+
1363
+ # Show the window again to apply the changes
1364
+ self._window.show()
1365
+
1366
+ ###########################################################################################
1367
+ # Splash Screen
1368
+ ###########################################################################################
1369
+ def set_static_image_splash_screen(
1370
+ self,
1371
+ image_path: str,
1372
+ close_on_load: bool = True,
1373
+ stay_on_top: bool = True,
1374
+ clickable: bool = True,
1375
+ ):
1376
+ """
1377
+ Sets the static image splash screen of the window.
1378
+
1379
+ Parameters
1380
+ ----------
1381
+ image_path : str
1382
+ Path to the image file
1383
+ close_on_load : bool, optional
1384
+ True to close the splash screen when the page is loaded, False otherwise (default is True)
1385
+ stay_on_top : bool, optional
1386
+ True to keep the splash screen on top, False otherwise (default is True)
1387
+ clickable : bool, optional
1388
+ True to make the splash screen clickable, False otherwise (default is True)
1389
+ if clickable is True, you can click the splash screen to close it.
1390
+
1391
+ Examples
1392
+ --------
1393
+ ```python
1394
+ window.set_image_splash_screen("./assets/loading.png", close_on_load=True, stay_on_top=True)
1395
+ ```
1396
+ """
1397
+ pixmap = QPixmap(image_path)
1398
+
1399
+ if not clickable:
1400
+
1401
+ class NonClickableSplashScreen(QSplashScreen):
1402
+ def mousePressEvent(self, event):
1403
+ pass # Ignore click events
1404
+
1405
+ splash = NonClickableSplashScreen(
1406
+ pixmap, Qt.WindowStaysOnTopHint if stay_on_top else Qt.WindowType(0)
1407
+ )
1408
+ else:
1409
+ splash = QSplashScreen(
1410
+ pixmap, Qt.WindowStaysOnTopHint if stay_on_top else Qt.WindowType(0)
1411
+ )
1412
+
1413
+ self.close_on_load = close_on_load
1414
+ self.splash_screen = splash
1415
+ self.splash_screen.show()
1416
+
1417
+ def set_gif_splash_screen(
1418
+ self,
1419
+ gif_path: str,
1420
+ close_on_load: bool = True,
1421
+ stay_on_top: bool = True,
1422
+ clickable: bool = True,
1423
+ ):
1424
+ """
1425
+ Sets the gif splash screen of the window.
1426
+
1427
+ Parameters
1428
+ ----------
1429
+ gif_path : str
1430
+ Path to the gif file
1431
+ close_on_load : bool, optional
1432
+ True to close the splash screen when the page is loaded, False otherwise (default is True)
1433
+ stay_on_top : bool, optional
1434
+ True to keep the splash screen on top, False otherwise (default is True)
1435
+ clickable : bool, optional
1436
+ True to make the splash screen clickable, False otherwise (default is True)
1437
+ if clickable is True, you can click the splash screen to close it.
1438
+
1439
+ Examples
1440
+ --------
1441
+ ```python
1442
+ window.set_gif_splash_screen("./assets/loading.gif", close_on_load=True, stay_on_top=True)
1443
+ ```
1444
+ """
1445
+
1446
+ if not clickable:
1447
+
1448
+ class NonClickableSplashScreen(QSplashScreen):
1449
+ def mousePressEvent(self, event):
1450
+ pass # Ignore click events
1451
+
1452
+ # Create splash screen (using animated GIF)
1453
+ splash = NonClickableSplashScreen(
1454
+ QPixmap(1, 1),
1455
+ Qt.WindowStaysOnTopHint if stay_on_top else Qt.WindowType(0),
1456
+ ) # Start with 1x1 transparent pixmap
1457
+ else:
1458
+ splash = QSplashScreen(
1459
+ QPixmap(1, 1),
1460
+ Qt.WindowStaysOnTopHint if stay_on_top else Qt.WindowType(0),
1461
+ )
1462
+
1463
+ splash.setAttribute(Qt.WA_TranslucentBackground)
1464
+
1465
+ # Create QLabel for GIF animation
1466
+ label = QLabel(splash)
1467
+ movie = QMovie(gif_path)
1468
+ label.setMovie(movie)
1469
+
1470
+ # Start animation and show splash screen
1471
+ movie.start()
1472
+ splash.show()
1473
+
1474
+ # Adjust splash screen size to match GIF size
1475
+ movie.frameChanged.connect(
1476
+ lambda: splash.setFixedSize(movie.currentPixmap().size())
1477
+ )
1478
+
1479
+ self.close_on_load = close_on_load
1480
+ self.splash_screen = splash
1481
+
1482
+ def close_splash_screen(self):
1483
+ """
1484
+ Closes the splash screen if it exists.
1485
+
1486
+ Examples
1487
+ --------
1488
+ ```python
1489
+ window.close_splash_screen()
1490
+ ```
1491
+ """
1492
+ if hasattr(self, "splash_screen") and self.splash_screen:
1493
+ self.splash_screen.close()
1494
+ self.close_on_load = None
1495
+ self.splash_screen = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyloid
3
- Version: 0.15.1
3
+ Version: 0.16.0
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -1,7 +1,7 @@
1
1
  pyloid/__init__.py,sha256=OOPhOKNQVmAM8hnfTeE7lHzxb8LsFNcgegBAvDrA-vY,293
2
2
  pyloid/api.py,sha256=np0pFVUlen_GpN0svY0A3awY_ZjVFk-RpHQZZKFUMuo,2157
3
3
  pyloid/autostart.py,sha256=K7DQYl4LHItvPp0bt1V9WwaaZmVSTeGvadkcwG-KKrI,3899
4
- pyloid/browser_window.py,sha256=L2dKvXzSVol1pKgsUf4bJD6MYBL7OJEtdWwGdgZHR_4,39513
4
+ pyloid/browser_window.py,sha256=-w7Y5BFSjrDzP-DrcVBaU8bYSaTAk0wJjiM1dLaLSk0,47293
5
5
  pyloid/custom/titlebar.py,sha256=itzK9pJbZMQ7BKca9kdbuHMffurrw15UijR6OU03Xsk,3894
6
6
  pyloid/filewatcher.py,sha256=3M5zWVUf1OhlkWJcDFC8ZA9agO4Q-U8WdgGpy6kaVz0,4601
7
7
  pyloid/js_api/event_api.py,sha256=_52yyBonqecmMvJpFW7OMNi_jX8Nrteqw_kI6r-DGG0,951
@@ -11,7 +11,7 @@ pyloid/pyloid.py,sha256=3YymePkpM_hKPzvHSSgELuSHkmbDsKW60HnRwwBMY7A,41178
11
11
  pyloid/timer.py,sha256=RqMsChFUd93cxMVgkHWiIKrci0QDTBgJSTULnAtYT8M,8712
12
12
  pyloid/tray.py,sha256=D12opVEc2wc2T4tK9epaN1oOdeziScsIVNM2uCN7C-A,1710
13
13
  pyloid/utils.py,sha256=VGZE2liY8_AElEqxVe1YLbk3fWlcAevpRc6oOTTgi-U,1927
14
- pyloid-0.15.1.dist-info/LICENSE,sha256=MTYF-6xpRekyTUglRweWtbfbwBL1I_3Bgfbm_SNOuI8,11525
15
- pyloid-0.15.1.dist-info/METADATA,sha256=bJP9CLF9fBirFlzPGLCl__s5cw9fb1pmK5wtXs8MmOE,3050
16
- pyloid-0.15.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
17
- pyloid-0.15.1.dist-info/RECORD,,
14
+ pyloid-0.16.0.dist-info/LICENSE,sha256=MTYF-6xpRekyTUglRweWtbfbwBL1I_3Bgfbm_SNOuI8,11525
15
+ pyloid-0.16.0.dist-info/METADATA,sha256=t5HJxUTwX3uls5dQd_x5tlu63z29C1fCkWDa4evyttg,3050
16
+ pyloid-0.16.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
17
+ pyloid-0.16.0.dist-info/RECORD,,