pyloid 0.16.1__tar.gz → 0.16.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pyloid-0.16.1 → pyloid-0.16.3}/PKG-INFO +1 -1
- {pyloid-0.16.1 → pyloid-0.16.3}/pyproject.toml +1 -1
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/browser_window.py +96 -5
- {pyloid-0.16.1 → pyloid-0.16.3}/LICENSE +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/README.md +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/__init__.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/api.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/autostart.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/custom/titlebar.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/filewatcher.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/js_api/event_api.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/js_api/window_api.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/monitor.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/pyloid.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/timer.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/tray.py +0 -0
- {pyloid-0.16.1 → pyloid-0.16.3}/src/pyloid/utils.py +0 -0
@@ -24,6 +24,11 @@ from .custom.titlebar import CustomTitleBar
|
|
24
24
|
from .js_api.window_api import WindowAPI
|
25
25
|
from PySide6.QtGui import QPixmap, QMovie
|
26
26
|
from PySide6.QtWidgets import QSplashScreen, QLabel
|
27
|
+
from PySide6.QtCore import QSize
|
28
|
+
from typing import TYPE_CHECKING
|
29
|
+
|
30
|
+
if TYPE_CHECKING:
|
31
|
+
from ..pyloid import Pyloid
|
27
32
|
|
28
33
|
|
29
34
|
# 어차피 load 부분에만 쓰이니까 나중에 분리해서 load 위에서 선언하자.
|
@@ -163,7 +168,7 @@ class CustomWebEngineView(QWebEngineView):
|
|
163
168
|
class BrowserWindow:
|
164
169
|
def __init__(
|
165
170
|
self,
|
166
|
-
app,
|
171
|
+
app: "Pyloid",
|
167
172
|
title: str = "pyloid app",
|
168
173
|
width: int = 800,
|
169
174
|
height: int = 600,
|
@@ -480,6 +485,57 @@ class BrowserWindow:
|
|
480
485
|
self.y = y
|
481
486
|
self._window.setGeometry(self.x, self.y, self.width, self.height)
|
482
487
|
|
488
|
+
def set_position_by_anchor(self, anchor: str):
|
489
|
+
"""
|
490
|
+
Positions the window at a specific location on the screen.
|
491
|
+
|
492
|
+
Parameters
|
493
|
+
----------
|
494
|
+
anchor : str
|
495
|
+
The anchor point indicating where to position the window.
|
496
|
+
Possible values: 'center', 'top', 'bottom', 'left', 'right',
|
497
|
+
'top-left', 'top-right', 'bottom-left', 'bottom-right'
|
498
|
+
|
499
|
+
Examples
|
500
|
+
--------
|
501
|
+
>>> window.set_position_by_anchor('center')
|
502
|
+
>>> window.set_position_by_anchor('top-right')
|
503
|
+
"""
|
504
|
+
screen = self.app.primaryScreen().availableGeometry()
|
505
|
+
window_size = self.get_size()
|
506
|
+
|
507
|
+
if anchor == "center":
|
508
|
+
x = (screen.width() - window_size["width"]) // 2
|
509
|
+
y = (screen.height() - window_size["height"]) // 2
|
510
|
+
elif anchor == "top":
|
511
|
+
x = (screen.width() - window_size["width"]) // 2
|
512
|
+
y = screen.top()
|
513
|
+
elif anchor == "bottom":
|
514
|
+
x = (screen.width() - window_size["width"]) // 2
|
515
|
+
y = screen.bottom() - window_size["height"]
|
516
|
+
elif anchor == "left":
|
517
|
+
x = screen.left()
|
518
|
+
y = (screen.height() - window_size["height"]) // 2
|
519
|
+
elif anchor == "right":
|
520
|
+
x = screen.right() - window_size["width"]
|
521
|
+
y = (screen.height() - window_size["height"]) // 2
|
522
|
+
elif anchor == "top-left":
|
523
|
+
x = screen.left()
|
524
|
+
y = screen.top()
|
525
|
+
elif anchor == "top-right":
|
526
|
+
x = screen.right() - window_size["width"]
|
527
|
+
y = screen.top()
|
528
|
+
elif anchor == "bottom-left":
|
529
|
+
x = screen.left()
|
530
|
+
y = screen.bottom() - window_size["height"]
|
531
|
+
elif anchor == "bottom-right":
|
532
|
+
x = screen.right() - window_size["width"]
|
533
|
+
y = screen.bottom() - window_size["height"]
|
534
|
+
else:
|
535
|
+
raise ValueError("Invalid anchor point.")
|
536
|
+
|
537
|
+
self.set_position(x, y)
|
538
|
+
|
483
539
|
def set_frame(self, frame: bool):
|
484
540
|
"""
|
485
541
|
Sets the frame of the window.
|
@@ -1395,6 +1451,7 @@ class BrowserWindow:
|
|
1395
1451
|
close_on_load: bool = True,
|
1396
1452
|
stay_on_top: bool = True,
|
1397
1453
|
clickable: bool = True,
|
1454
|
+
position: str = "center",
|
1398
1455
|
):
|
1399
1456
|
"""
|
1400
1457
|
Sets the static image splash screen of the window.
|
@@ -1410,6 +1467,8 @@ class BrowserWindow:
|
|
1410
1467
|
clickable : bool, optional
|
1411
1468
|
True to make the splash screen clickable, False otherwise (default is True)
|
1412
1469
|
if clickable is True, you can click the splash screen to close it.
|
1470
|
+
position : str, optional
|
1471
|
+
Position of the splash screen. Options are 'center', 'top-left', 'top-right', 'bottom-left', 'bottom-right' (default is 'center')
|
1413
1472
|
|
1414
1473
|
Examples
|
1415
1474
|
--------
|
@@ -1435,6 +1494,7 @@ class BrowserWindow:
|
|
1435
1494
|
|
1436
1495
|
self.close_on_load = close_on_load
|
1437
1496
|
self.splash_screen = splash
|
1497
|
+
self._position_splash_screen(position)
|
1438
1498
|
self.splash_screen.show()
|
1439
1499
|
|
1440
1500
|
def set_gif_splash_screen(
|
@@ -1443,6 +1503,7 @@ class BrowserWindow:
|
|
1443
1503
|
close_on_load: bool = True,
|
1444
1504
|
stay_on_top: bool = True,
|
1445
1505
|
clickable: bool = True,
|
1506
|
+
position: str = "center",
|
1446
1507
|
):
|
1447
1508
|
"""
|
1448
1509
|
Sets the gif splash screen of the window.
|
@@ -1458,6 +1519,8 @@ class BrowserWindow:
|
|
1458
1519
|
clickable : bool, optional
|
1459
1520
|
True to make the splash screen clickable, False otherwise (default is True)
|
1460
1521
|
if clickable is True, you can click the splash screen to close it.
|
1522
|
+
position : str, optional
|
1523
|
+
Position of the splash screen. Options are 'center', 'top-left', 'top-right', 'bottom-left', 'bottom-right' (default is 'center')
|
1461
1524
|
|
1462
1525
|
Examples
|
1463
1526
|
--------
|
@@ -1490,17 +1553,45 @@ class BrowserWindow:
|
|
1490
1553
|
movie = QMovie(gif_path)
|
1491
1554
|
label.setMovie(movie)
|
1492
1555
|
|
1493
|
-
# Start animation and show splash screen
|
1494
|
-
movie.start()
|
1495
|
-
splash.show()
|
1496
|
-
|
1497
1556
|
# Adjust splash screen size to match GIF size
|
1498
1557
|
movie.frameChanged.connect(
|
1499
1558
|
lambda: splash.setFixedSize(movie.currentPixmap().size())
|
1500
1559
|
)
|
1501
1560
|
|
1561
|
+
# Start animation and show splash screen
|
1562
|
+
movie.start()
|
1502
1563
|
self.close_on_load = close_on_load
|
1503
1564
|
self.splash_screen = splash
|
1565
|
+
self._position_splash_screen(position)
|
1566
|
+
splash.show()
|
1567
|
+
|
1568
|
+
def _position_splash_screen(self, position: str):
|
1569
|
+
if not self.splash_screen:
|
1570
|
+
return
|
1571
|
+
|
1572
|
+
screen = self.app.primaryScreen().geometry()
|
1573
|
+
splash_size = self.splash_screen.size()
|
1574
|
+
|
1575
|
+
if position == "center":
|
1576
|
+
new_position = screen.center() - QPoint(
|
1577
|
+
splash_size.width() // 2, splash_size.height() // 2
|
1578
|
+
)
|
1579
|
+
elif position == "top-left":
|
1580
|
+
new_position = screen.topLeft()
|
1581
|
+
elif position == "top-right":
|
1582
|
+
new_position = screen.topRight() - QPoint(splash_size.width(), 0)
|
1583
|
+
elif position == "bottom-left":
|
1584
|
+
new_position = screen.bottomLeft() - QPoint(0, splash_size.height())
|
1585
|
+
elif position == "bottom-right":
|
1586
|
+
new_position = screen.bottomRight() - QPoint(
|
1587
|
+
splash_size.width(), splash_size.height()
|
1588
|
+
)
|
1589
|
+
else:
|
1590
|
+
new_position = screen.center() - QPoint(
|
1591
|
+
splash_size.width() // 2, splash_size.height() // 2
|
1592
|
+
)
|
1593
|
+
|
1594
|
+
self.splash_screen.move(new_position)
|
1504
1595
|
|
1505
1596
|
def close_splash_screen(self):
|
1506
1597
|
"""
|
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
|