新人求助wxPython中嵌入ActiveX控件的问题
我用wx.lib.activexwrapper 中的 MakeActiveXClass类在界面中嵌入ActiveX控件,一般的控件都没有问题,但是唯独嵌入Windows Media Player时会出问题
下面是我的代码:
import wx
from wx.lib.activexwrapper import MakeActiveXClass
import win32com.client.gencache as win32
mediaControl = win32.EnsureModule('{6BF52A50-394A-11D3-B153-00C04F79FAA6}',0,1,0)
print dir(mediaControl)
if mediaControl is None:
raise ImportError("Can't load wmp. Make sure you have wmp installed.")
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,'MediaPlayer',(50,50),(800,600)) #初始化一个窗口
p=wx.Panel(self)
ActiveXWrapper =MakeActiveXClass(mediaControl.WindowsMediaPlayer)
self.med = ActiveXWrapper(p,-1)
if __name__=="__main__":
app=wx.PySimpleApp()
media1=MyFrame()
media1.Show()
app.MainLoop()
运行结果:
Traceback (most recent call last):
File "D:\JQC\Python\IDE\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "D:\pyhtontest\Mymedia_client_3.py", line 58, in ?
media1=MyFrame()
File "D:\pyhtontest\Mymedia_client_3.py", line 25, in __init__
self.med = ActiveXWrapper(p,-1)
File "D:\JQC\Python\IDE\lib\site-packages\wx-2.8-msw-unicode\wx\lib\activexwrapper.py", line 119, in axw__init__
(0, 0, sz.width, sz.height), self._wnd, ID)
File "D:\JQC\Python\IDE\Lib\site-packages\pythonwin\pywin\mfc\activex.py", line 23, in CreateControl
self.__dict__["_obj_"] = win32ui.CreateControl(clsid, windowTitle, style, rect, parent, id, None, False, lic_string)
win32ui: The window can not be created as it has an invalid handle
同样方法用在别的控件上不会出错,我还试过日历控件,Quicktime,realplayer(结果嵌入的是音频的)
我试过别的方法嵌入media player控件,比如用wx.media.MediaCtrl,这可能是最简单的方法了,但是只能载入WMP6.4的,6.4在连接http服务器播放流媒体时会出错(具体问题我在CSDN论坛里面提问但没有得到解答)
而且wx.medai调用的是_media.pyd,看不见他的源代码,也无从修改
可能这里是讨论Linux的地方,我也不知道发在这里合不合适,但我发现这里讨论wxPython蛮多的,在CSDN上面几乎没人讨论wx,望各位老大不吝赐教