wxPython窗口ID [英] wxPython Window ID

查看:256
本文介绍了wxPython窗口ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用wxPython编写相框应用程序.为了查看视频和照片,我开始使用wx.media,但发现gstreamer后端不足.所以我转向mplayerctrl并将其移植到Python3/Phoenix.我一直在努力使其工作的事情是以编程方式检索要传递给mplayer的window id,以便视频在帧内播放.我已经验证了是否可以从xwininfo获取窗口ID,但是如果我使用GetHandle(),它将返回0;如果使用GetGtkWidget(),它将返回一个值,但该值与窗口ID不对应. mplayerctrl的股票版本使用self.Handle. https://docs.wxpython.org/wx.Window.html

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

我正在寻找一种可以在Linux上运行但又可以移植到其他平台上的解决方案.理想情况下,该解决方案也应该是wxPython/Python本机.

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.

谢谢

推荐答案

我认为您试图过早设置handle.
我怀疑您正在初始化handle作为初始化例程的一部分.我发现您应该等到选择要播放的视频后再使用self.xxxxx.GetHandle(),即您对要播放器播放的每个项目都执行该功能.
我已经使用python 3.5.2 wxpython 4.0.02b Linux Mint 18.2并使用Vlc对此进行了测试. 似乎MainLoop必须在GetHandle返回有效值之前启动.

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.

这篇关于wxPython窗口ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆