Functions fromWinId and createWindowContainer not working on Linux
Unsolved
Qt for Python
-
I am developping a gui application on Python with PySide2. I'm using fromWinId and createWindowContainer functions to embed an external window app in my app. It's perfectly working on Windows, I can access my embedded app (Paint app for example). But on Linux, it's not working the same. I manage to get the window id of the external app and to embed it my app, but when it's embedded, I only have a frozen image of the external app. This is my code :
import Xlib.display from PySide2.QtGui import QWindow from PySide2.QtWidgets import QWidget, QApplication, QPushButton, QMainWindow, QVBoxLayout def _get_window_id_win32(title): import win32gui return win32gui.FindWindow(None, title) def get_window_id_linux(name): display = Xlib.display.Display() root = display.screen().root window_ids = root.get_full_property(display.intern_atom('_NET_CLIENT_LIST'), Xlib.X.AnyPropertyType).value for window_id in window_ids: window = display.create_resource_object('window', window_id) window_name = window.get_wm_name() if window_name and name in window_name: return window_id def run_app(window_id): app = QApplication([]) main = QMainWindow() widget_central = QWidget() layout = QVBoxLayout() button = QPushButton() button.setText('CLICK') layout.addWidget(button) window = QWindow.fromWinId(window_id) widget = QWidget.createWindowContainer(window) layout.addWidget(widget) widget_central.setLayout(layout) main.setCentralWidget(widget_central) main.show() app.exec_() if __name__ == '__main__': window_id = get_window_id_linux('Window Title') # REPLACE 'Window Title' by the title of the window you want to embed # window_id = _get_window_id_win32('Window Title') IF YOU WANT TO TEST ON WINDOWS if window_id: run_app(window_id)