问题
I'm trying to write a photo frame app utilizing wxPython. To view videos as well as photos I started off using wx.media but found the gstreamer backend to insufficient. So I turned to mplayerctrl and ported it over to Python3/Phoenix. The thing I've been struggling with to get it working is programmatically retrieving the window id to pass into mplayer so that the video plays inside the frame. I've verified that this works if I get the window id from xwininfo however if I use GetHandle() it returns 0 and if I use GetGtkWidget() it returns a value but that value doesn't correspond to the window id. The stock version of mplayerctrl used self.Handle. https://docs.wxpython.org/wx.Window.html
I'm looking for a solution that works in Linux but will hopefully be portable to other platforms. Also ideally this solution would be wxPython/Python native.
Thanks
回答1:
I believe that you are attempting to set the handle
too soon.
I suspect that you are initiating the handle
as part of your initialisation routine. I have found that you should wait until you have selected a video to play and use the self.xxxxx.GetHandle()
at that point i.e. you perform that function for each item that you ask the player to play.
I have tested this with python 3.5.2 wxpython 4.0.02b Linux Mint 18.2 and using Vlc
.
It seems to be that the MainLoop
must have started before GetHandle
will return a valid value.
来源:https://stackoverflow.com/questions/46472213/wxpython-window-id