47 lines
3.1 KiB
Plaintext
47 lines
3.1 KiB
Plaintext
From the information you've provided, particularly the configuration in the systemd service file for Weston and related directories, we can deduce several important environmental setup aspects for running applications using the Wayland display server (Weston) on your device.
|
||
|
||
Key Takeaways
|
||
Weston Configuration and Runtime Directory:
|
||
Weston is run with specific configurations specified in /usr/comma/weston.ini.
|
||
The XDG_RUNTIME_DIR environment variable is set to /var/tmp/weston. This is crucial because Wayland clients locate the Wayland server (Weston in this case) through the WAYLAND_DISPLAY environment variable, which typically points to a socket file within XDG_RUNTIME_DIR.
|
||
Service Setup:
|
||
Pre-execution steps in the Weston service ensure that the runtime directory exists and has the correct permissions. This directory is used by Weston to store its runtime data, including the socket file (wayland-0), which clients use to communicate with Weston.
|
||
Execution Parameters:
|
||
Weston is started with the --config flag pointing to a custom configuration file and on a specific TTY. This setup is essential for correctly initializing the display server on your device.
|
||
Making Your PyQt Application Work
|
||
Given the above setup, you should ensure your PyQt application is configured to correctly interact with this environment. Here's what you need to do:
|
||
|
||
Set the XDG_RUNTIME_DIR Environment Variable: This should match the configuration of the Weston service to ensure that your application can find the Wayland display server.
|
||
Direct PyQt to use the Wayland Platform:
|
||
Explicitly set the platform to Wayland in your PyQt application.
|
||
Ensure the WAYLAND_DISPLAY environment variable points to the correct socket file, usually wayland-0 inside your runtime directory.
|
||
Here’s how you can modify your Python script to accommodate these settings:
|
||
|
||
python
|
||
Copy code
|
||
import os
|
||
import sys
|
||
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QScrollBar
|
||
from PyQt5.QtCore import Qt
|
||
|
||
# Set environment variables to match the Weston configuration
|
||
os.environ["XDG_RUNTIME_DIR"] = "/var/tmp/weston"
|
||
os.environ["WAYLAND_DISPLAY"] = "wayland-0" # Typically the socket is named wayland-0
|
||
os.environ["QT_QPA_PLATFORM"] = "wayland"
|
||
|
||
app = QApplication(sys.argv)
|
||
window = QWidget()
|
||
window.setWindowTitle("PyQt on Wayland")
|
||
layout = QHBoxLayout(window)
|
||
scroll = QScrollBar(Qt.Vertical)
|
||
layout.addWidget(scroll)
|
||
window.setLayout(layout)
|
||
window.show()
|
||
|
||
sys.exit(app.exec_())
|
||
Summary
|
||
By aligning your PyQt environment with the established Weston configuration:
|
||
|
||
You replicate the environmental setup that native applications use, ensuring compatibility.
|
||
You directly address the issue of the PyQt application failing to find or connect to the Weston display server, which is indicated by errors related to the xcb platform plugin.
|
||
This setup should resolve the issues you've been facing with launching your PyQt application on the device. Ensure that Weston is actively running when you attempt to start your application, as it must be running to accept connections from Wayland clients. |