Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X Error of failed request: BadWindow (invalid Window parameter) #445

Open
YuXHe15 opened this issue Aug 3, 2023 · 4 comments
Open

X Error of failed request: BadWindow (invalid Window parameter) #445

YuXHe15 opened this issue Aug 3, 2023 · 4 comments

Comments

@YuXHe15
Copy link

YuXHe15 commented Aug 3, 2023

Hi
I was trying the small example of pyvistaqt, namely

import pyvista as pv
from pyvistaqt import BackgroundPlotter
sphere = pv.Sphere()
plotter = BackgroundPlotter()
plotter.add_mesh(sphere)

while I got error:

X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 12 (X_ConfigureWindow)
Resource id in failed request: 0x3
Serial number of failed request: 7
Current serial number in output stream: 8

After checking line by line I found it happends after creating the instance plotter of BackgoundPlotter()

My system is Ubuntu 22.04.2 LTS, using python 3.10

@YuXHe15
Copy link
Author

YuXHe15 commented Aug 3, 2023

I did a little research around stackoverflow and one answer mentioned that it could happen when the window id passed is not correct, which can be found here:
https://stackoverflow.com/questions/34704542/in-linux-get-window-class-raise-x-error-of-failed-request-badwindow-invalid
I don't know if it would be helpful

@NicolasCami
Copy link

Hi there,

I get the exact same error output. I'm working with virtualenv. I tried with pyqt5, pyqt6, pyside6 (using os.environ["QT_API"]) and get the same error as soon as the BackgroundPlotter is instantiated.

I did several tests to understand if the issue is related to pyqt/pyside or qtpy or pyvista or pyvistaqt:

  • Using directly pyqt/pyside works.
  • Using directly qtpy works.
  • Using pyvista works.
  • It seems that only pyvistaqt produces this error.

Here is an example that works. But if I uncomment QtInteractor or BackgroundPlotter lines I get the same error message.

import os
os.environ["QT_API"] = "pyside6"

from qtpy.QtWidgets import *
from pyvistaqt import QtInteractor, BackgroundPlotter

class MainWindow(QDialog):

    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.frame = QFrame()
        vlayout = QVBoxLayout()
        self.frame.setLayout(vlayout)

if __name__ == '__main__':
    import sys

    app = QApplication(sys.argv)

    # Produces X error: BadWindow
    #plotter = BackgroundPlotter(False, app=app)

    win = MainWindow()

    # Produces X error: BadWindow
    #interactor = QtInteractor(win)

    win.show()
    sys.exit(app.exec())

I wonder if it's related to my Qt installation, or Wayland. My config:

  • Ubuntu 22.04.3
  • GNOME 42.9
  • Wayland

@NicolasCami
Copy link

NicolasCami commented Mar 20, 2024

Additional information: The issue only occurs on Wayland. Running the problematic example on X11 works.
As a workaround, you can force Qt to use X11 instead of Wayland:

export QT_QPA_PLATFORM=xcb
python app.py

@mscheltienne
Copy link

Same problem with Ubuntu 24.04 LTS which defaults to Wayland.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants