76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
import os
|
|
import sys
|
|
import signal
|
|
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QGraphicsView, QGraphicsScene
|
|
from PyQt5.QtCore import Qt, QUrl, QPointF, QTimer, QObject, QEvent
|
|
from PyQt5.QtGui import QCursor, QPixmap, QTransform
|
|
from PyQt5.QtWebEngineWidgets import QWebEngineView
|
|
|
|
import rotation
|
|
|
|
webview = None
|
|
|
|
def create_webview_app():
|
|
global webview
|
|
|
|
# Set environment for Wayland
|
|
os.environ["XDG_RUNTIME_DIR"] = "/var/tmp/weston"
|
|
os.environ["WAYLAND_DISPLAY"] = "wayland-0"
|
|
os.environ["QT_QPA_PLATFORM"] = "wayland"
|
|
os.environ["QT_WAYLAND_SHELL_INTEGRATION"] = "wl-shell"
|
|
|
|
# Application setup
|
|
app = QApplication(sys.argv)
|
|
desktop = QApplication.desktop()
|
|
|
|
sg = desktop.availableGeometry(desktop.primaryScreen())
|
|
|
|
window = QWidget()
|
|
window.setWindowTitle("Qt WebView Example")
|
|
window.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
|
|
window.setGeometry(0, 0, sg.height(), sg.width())
|
|
window.setStyleSheet("background-color: black;")
|
|
window.showFullScreen()
|
|
|
|
scene = QGraphicsScene()
|
|
view = QGraphicsView(scene, window)
|
|
view.setGeometry(0, 0, sg.width(), sg.height())
|
|
view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
|
view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
|
|
|
# Create WebView
|
|
webview = QWebEngineView()
|
|
webview.load(QUrl("https://cdpn.io/yananas/fullpage/rwvZvY"))
|
|
webview.setGeometry(0, 0, sg.width(), sg.height())
|
|
|
|
# Add WebView to the scene
|
|
proxy_webview = scene.addWidget(webview)
|
|
view.setScene(scene)
|
|
# view.rotate(90) # Rotate the view by 90 degrees
|
|
|
|
# Layout setup
|
|
window_layout = QHBoxLayout(window)
|
|
window_layout.addWidget(view)
|
|
window_layout.setContentsMargins(0, 0, 0, 0)
|
|
window.setLayout(window_layout)
|
|
|
|
window_handle = int(window.winId())
|
|
# window_handle = window.windowHandle()
|
|
print ("Handle:")
|
|
print (window_handle)
|
|
# if window_handle:
|
|
# rotation.rotate_display(window_handle)
|
|
# else:
|
|
# print("Window handle is not valid.")
|
|
|
|
return app, window
|
|
|
|
def main():
|
|
signal.signal(signal.SIGINT, signal.SIG_DFL) # Enable Ctrl+C to terminate the application
|
|
app, window = create_webview_app()
|
|
exit_code = app.exec_()
|
|
sys.exit(exit_code)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|