Files
fluent_widgets_pyside6/examples/window/web_engine/demo.py
2025-08-14 18:45:16 +08:00

61 lines
1.7 KiB
Python

# coding:utf-8
import sys
from PySide6.QtCore import Qt, QUrl
from PySide6.QtGui import QIcon, QDesktopServices
from PySide6.QtWidgets import QApplication, QFrame, QHBoxLayout, QVBoxLayout
from qfluentwidgets import setTheme, Theme, SubtitleLabel, setFont, SplitFluentWindow
from qfluentwidgets import FluentIcon as FIF
from qframelesswindow.webengine import FramelessWebEngineView
class Widget(QFrame):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setObjectName("homeInterface")
self.webView = FramelessWebEngineView(self)
self.webView.load(QUrl("https://www.baidu.com/"))
self.vBoxLayout = QVBoxLayout(self)
self.vBoxLayout.setContentsMargins(0, 48, 0, 0)
self.vBoxLayout.addWidget(self.webView)
class Window(SplitFluentWindow):
def __init__(self):
super().__init__()
# create sub interface
self.homeInterface = Widget(self)
self.initNavigation()
self.initWindow()
def initNavigation(self):
self.addSubInterface(self.homeInterface, FIF.HOME, "Home")
# NOTE: enable acrylic effect
# self.navigationInterface.setAcrylicEnabled(True)
def initWindow(self):
self.resize(900, 700)
self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png'))
self.setWindowTitle('PyQt-Fluent-Widgets')
desktop = QApplication.screens()[0].availableGeometry()
w, h = desktop.width(), desktop.height()
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
if __name__ == '__main__':
# setTheme(Theme.DARK)
app = QApplication(sys.argv)
w = Window()
w.show()
w.setMicaEffectEnabled(True)
app.exec()