Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

wxWindow.GetHandle() error: gdk/x11/gdkwindow-x11.c:5653 drawable is not a native X11 window

Open ikarlmarx opened this issue 3 years ago • 12 comments
trafficstars

Hi, I am running wxPython on Ubuntu 21.10. When I use wxWindow.GetHandle(), I get an error: gdk/x11/gdkwindow-x11.c:5653 drawable is not a native X11 window. And GetHandle returns 0. So I can't draw anything in the Window.

Could you give me some help? Thank you. Sam

ikarlmarx avatar Jan 24 '22 23:01 ikarlmarx

Are you running Wayland and not X11?

swt2c avatar Jan 25 '22 00:01 swt2c

Yes.

ikarlmarx avatar Jan 25 '22 03:01 ikarlmarx

GetHandle() doesn't do anything on Wayland as you can see. As a workaround, you could try forcing your program to run in X11 by doing something like GDK_BACKEND=x11 python3 your_program.py.

swt2c avatar Jan 25 '22 04:01 swt2c

Thank you. I will try. But when I run it through Visual Studio Code, it works well and everything is good. Is there something special in Visual Studio Code?

ikarlmarx avatar Jan 25 '22 23:01 ikarlmarx

Visual Studio Code might be forcing X11 itself?

swt2c avatar Jan 26 '22 01:01 swt2c

We could probably make GetHandle() return something on Wayland, probably a wl_surface, but is that what you really want? What are you doing with the handle?

swt2c avatar Jan 26 '22 01:01 swt2c

Return the identifier ID of the window? Just like what Tkinter.ttk.Frame.winfo_id() return. I am using python-vlc to make a media player. The videos need to be displayer in a wxWindow through the id of the wxWindow.

    import vlc, wx

    Instance = vlc.Instance('--no-xlib')
    player = Instance.media_player_new()

    video_panel = wx.Panel(self)
    handle = video_panel.GetHandle()
    player.set_xwindow(handle)

Thank you.

ikarlmarx avatar Jan 26 '22 16:01 ikarlmarx

The problem is, under Wayland, there are no X windows. I looked at the documentation for python-vlc and it seems unlikely that it supports Wayland. If you really want to force X11, you should probably try the GDK_BACKEND=x11 route.

Alternatively, if you are trying to build a media player, have you looked at wx.MediaCtrl?

swt2c avatar Jan 26 '22 17:01 swt2c

I will try that. Thank you very much.

ikarlmarx avatar Jan 26 '22 20:01 ikarlmarx

I tried wx.media.MediaCtrl, and got an error: NotImplementedError. I googled it, and there is no answer for it.

What should I do? Thank you.

ikarlmarx avatar Jan 27 '22 00:01 ikarlmarx

I tested it. VS Code runs python on X11. But python-vlc works well on Wayland with tkinter, and Tkinter.ttk.Frame.winfo_id() return the window id. python-vlc need the window_id to render it.

ikarlmarx avatar Jan 27 '22 01:01 ikarlmarx

I tried wx.media.MediaCtrl, and got an error: NotImplementedError.

That means your wxPython was compiled without wx.MediaCtrl support. That probably means that the gstreamer development packages weren't installed when you compiled wxPython. On Ubuntu, you need libgstreamer-plugins-base1.0-dev for that to work.

But python-vlc works well on Wayland with tkinter, and Tkinter.ttk.Frame.winfo_id() return the window id.

I'm skeptical that Tkinker is really using Wayland.

swt2c avatar Jan 27 '22 01:01 swt2c