Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4630

Graphics programming • PySide6 MainWindow not positioning on screen (Bookworm OS Pi4)

$
0
0
I have a problem getting PySide 6 main window to be displayed at a position of my choice on screen. It defaults to being in the center of the screen and although it can then be re-positioned by grabbing the title bar I want it to open in my chosen place.

I am using a Py4 running Bookworm OS and python programming in a virtual environment. My test code is detailed below. By using "echo $XDG_SESSION_TYPE" I discovered that I was using "Wayland" video drivers and thought that might be the cause? So, by switching to X11 (using sudo raspi-config > advanced Options > A6 Wayland > W1 X11 Openbox Window Manager" followed by a reboot and confirmation that I was now using X11) the same test code causes the following error:

"qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This plugin does not support propagateSizeHints()"

While in my virtual environment I have tried to load xcb-cursor0 and also libxcb-cursor0 but both cannot be found using "python3 -m pip install xcb-cursor0"

I have also tried PyQt6 but get the same problem with positioning the main window.
I don't care which video driver I need to use nor whether it's PySide6 or PyQt6 but i do need a solution using Bookworm OS. I don't want to use a legacy OS on my Pi4
Can some one please help me?

Code:

# Simple Sample Programimport sysfrom PySide6.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QVBoxLayout, QHBoxLayout, QWidgetclass DemoWindow(QMainWindow):   def __init__(self):       super().__init__()       # Main Widget and Layout       main_widget = QWidget()       self.setCentralWidget(main_widget)       main_layout = QVBoxLayout(main_widget)       # Function to add widget with label       def add_widget_with_label(layout, widget, label_text):           hbox = QHBoxLayout()           label = QLabel(label_text)           hbox.addWidget(label)           hbox.addWidget(widget)           layout.addLayout(hbox)       # QLineEdit       self.line_edit = QLineEdit()       add_widget_with_label(main_layout, self.line_edit, 'Example Input:')# Run the applicationapp = QApplication(sys.argv)window = DemoWindow()window.setGeometry(1000,0,400,300)window.show()sys.exit(app.exec())

Statistics: Posted by Bill_Newton — Tue Dec 17, 2024 12:47 pm — Replies 0 — Views 2



Viewing all articles
Browse latest Browse all 4630

Trending Articles