Phoenix
Phoenix copied to clipboard
wxWindow.GetHandle() error: gdk/x11/gdkwindow-x11.c:5653 drawable is not a native X11 window
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
Are you running Wayland and not X11?
Yes.
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.
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?
Visual Studio Code might be forcing X11 itself?
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?
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.
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?
I will try that. Thank you very much.
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.
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.
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.