feat(*): implement v0.1.0, add docs
This commit is contained in:
59
examples/window_glass.py
Normal file
59
examples/window_glass.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""Full window glass effect example.
|
||||
|
||||
The simplest possible example: a window with glass filling the entire
|
||||
content area.
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow, QVBoxLayout, QWidget
|
||||
|
||||
import pyqt_liquidglass as glass
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setWindowTitle("Window Glass")
|
||||
self.resize(600, 400)
|
||||
|
||||
central = QWidget()
|
||||
central.setStyleSheet("background: transparent;")
|
||||
|
||||
layout = QVBoxLayout(central)
|
||||
layout.setContentsMargins(40, 60, 40, 40)
|
||||
|
||||
label = QLabel("Hello, Liquid Glass!")
|
||||
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
label.setStyleSheet(
|
||||
"""
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: white;
|
||||
background: transparent;
|
||||
"""
|
||||
)
|
||||
|
||||
layout.addWidget(label)
|
||||
self.setCentralWidget(central)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
window = MainWindow()
|
||||
|
||||
# Prepare window BEFORE showing
|
||||
glass.prepare_window_for_glass(window)
|
||||
|
||||
window.show()
|
||||
|
||||
# Apply glass AFTER showing
|
||||
glass.apply_glass_to_window(window)
|
||||
|
||||
return app.exec()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user