geometry is 1161x480+821+429. This error occurs when you try to set a geometry for a window that is not valid or not supported by the operating system.

To fix this error, you can try the following solutions:

  1. Check if the parent widget or window is valid and properly initialized before setting the geometry.

  2. Make sure that the specified geometry is within the screen boundaries and does not exceed the maximum allowed size.

  3. Try setting a different geometry that is supported by the operating system. You can use the QDesktopWidget class to get the available screen geometry and adjust your window accordingly.

Here is an example of how you can use the QDesktopWidget class to set a valid geometry for your window:

from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox, QDesktopWidget

app = QApplication([])
window = QWidget()

# Create a QMessageBox
message_box = QMessageBox(window)
message_box.setWindowTitle("Error")
message_box.setText("An error occurred.")

# Set the desired geometry
desired_geometry = QRect(821, 429, 640, 480)

# Get the available screen geometry
screen_geometry = QDesktopWidget().availableGeometry()

# Adjust the desired geometry if needed
adjusted_geometry = screen_geometry.intersected(desired_geometry)

# Set the adjusted geometry for the QMessageBox
message_box.setGeometry(adjusted_geometry)

# Show the QMessageBox
message_box.show()

app.exec()

By using the QDesktopWidget class, you can ensure that the geometry you set for your window is valid and supported by the operating system.

setGeometry Unable to set geometry 640x480+821+429 on QWidgetWindowQMessageBoxClassWindow Resulting