Hello:
i want use activex in wxpython program,but when i use MakeActiveXClas s
an exception occurs.
this is my source code dealing the DICOM ocx.I must note that in this
program "hwtxcontro l" is a ocx developed my me use vc6,this ocx works
fine in wxpython.
but you can see i only change this ocx with a new DICOM ocx and set up
eventClass,
but the exception occure:
File ".\site-packages\wxPyth on\lib\activexw rapper.py", line 105, in
axw__init__
File "D:\Py22\lib\si te-packages\win32c om\gen_py\3A75E E8D-8E68-43FF-A90A-E4835B9A3DBDx0x 1x0.py",
line 187, in __init__
cookie=cp.Advis e(win32com.serv er.util.wrap(se lf,
usePolicy=Event HandlerPolicy))
com_error: (-2147220990, 'CONNECT_E_CANN OTCONNECT', None, None)
the ocx and the source code (in delphi) you can down at:
from wxPython.wx import *
from wxPython.lib.rc sizer import RowColSizer
import pywin.mfc.activ ex
import activexwrapper, win32ui
if wxPlatform == '__WXMSW__':
from wxPython.lib.ac tivexwrapper import MakeActiveXClas s
import win32com.client .gencache
import win32com.client
try:
import hwtxcontrol
hwtxocx=hwtxcon trol
#import ezdicom
#dicomocx=ezdic om
#dicomocx=win32 com.client.genc ache.EnsureModu le("{3A75EE8D-8E68-43FF-A90A-E4835B9A3DBD}", 0,1,0)
#dicomocx=win32 com.client.Disp atch("ezDICOMax .ezDICOMX")
dicomocx=win32c om.client.genca che.EnsureModul e('{3A75EE8D-8E68-43FF-A90A-E4835B9A3DBD}',
0, 1, 0)
except:
raise ImportError("IE 4 or greater does not appear to be
installed.")
class DicomControl(py win.mfc.activex .Control, dicomocx.ezDICO MX):
def __init__(self):
pywin.mfc.activ ex.Control.__in it__(self)
dicomocx.ezDICO MX.__init__(sel f)
def OnDCMmouseDown( self, X ,Y ,Button ,Shift):
print "DICOM ocx Click!"
class HwtxControl(pyw in.mfc.activex. Control, hwtxocx.Hwtx):
def __init__(self):
pywin.mfc.activ ex.Control.__in it__(self)
hwtxocx.Hwtx.__ init__(self)
def OnClick(self):
print "hwtx click!"
class TestPanel(wxWin dow):
def __init__(self, parent, log, frame=None):
wxWindow.__init __(self, parent, -1,
style=wxCLIP_CH ILDREN|wxNO_FUL L_REPAINT_ON_RE SIZE)
sizer = wxBoxSizer(wxVE RTICAL)
hwtxCtls=RowCol Sizer()
theClass2 = MakeActiveXClas s(dicomocx.ezDI COMX,eventClass =DicomControl)
#theClass2 =
MakeActiveXClas s(hwtxocx.Hwtx, eventClass=Hwtx Control)
self.ie4=theCla ss2(self,-1)
self.ie4.SetSiz e(wxSize(300,30 0))
#self.ie4.filen ame="e:\\d02.im g"
#self.ie4.palnu mber=12
#self.ie4.state =1
hwtxCtls.Add(se lf.ie4, row=2, col=2)
sizer.Add(hwtxC tls, 0, wxEXPAND)
self.SetSizer(s izer)
self.SetAutoLay out(True)
EVT_WINDOW_DEST ROY(self, self.OnDestroy)
def OnDestroy(self, evt):
if self.ie4:
self.ie4.Cleanu p()
self.ie4 = None
def runTest(frame, nb, log):
if wxPlatform == '__WXMSW__':
win = TestPanel(nb, log, frame)
return win
else:
dlg = wxMessageDialog (frame, 'This demo only works on MSW.',
'Sorry', wxOK | wxICON_INFORMAT ION)
dlg.ShowModal()
dlg.Destroy()
overview = __doc__
if __name__ == '__main__':
class TestFrame(wxFra me):
def __init__(self):
wxFrame.__init_ _(self, None, -1, "ActiveX test -- Internet
Explorer",
size=(640, 480),
style=wxDEFAULT _FRAME_STYLE|wx NO_FULL_REPAINT _ON_RESIZE)
self.CreateStat usBar()
self.tp = TestPanel(self, sys.stdout, self)
EVT_CLOSE(self, self.OnCloseWin dow)
def OnCloseWindow(s elf, evt):
self.tp.Destroy ()
self.Destroy()
app = wxPySimpleApp()
frame = TestFrame()
frame.Show(True )
app.MainLoop()
i am a new python programer but i was really attracted by it elegant
code.i really want use wxpython as my framework,but if i cant use
activeX,i will have to change to vb:(
can you help me.Best regards.
sincerely
wangxiaoyu
i want use activex in wxpython program,but when i use MakeActiveXClas s
an exception occurs.
this is my source code dealing the DICOM ocx.I must note that in this
program "hwtxcontro l" is a ocx developed my me use vc6,this ocx works
fine in wxpython.
but you can see i only change this ocx with a new DICOM ocx and set up
eventClass,
but the exception occure:
File ".\site-packages\wxPyth on\lib\activexw rapper.py", line 105, in
axw__init__
File "D:\Py22\lib\si te-packages\win32c om\gen_py\3A75E E8D-8E68-43FF-A90A-E4835B9A3DBDx0x 1x0.py",
line 187, in __init__
cookie=cp.Advis e(win32com.serv er.util.wrap(se lf,
usePolicy=Event HandlerPolicy))
com_error: (-2147220990, 'CONNECT_E_CANN OTCONNECT', None, None)
the ocx and the source code (in delphi) you can down at:
from wxPython.wx import *
from wxPython.lib.rc sizer import RowColSizer
import pywin.mfc.activ ex
import activexwrapper, win32ui
if wxPlatform == '__WXMSW__':
from wxPython.lib.ac tivexwrapper import MakeActiveXClas s
import win32com.client .gencache
import win32com.client
try:
import hwtxcontrol
hwtxocx=hwtxcon trol
#import ezdicom
#dicomocx=ezdic om
#dicomocx=win32 com.client.genc ache.EnsureModu le("{3A75EE8D-8E68-43FF-A90A-E4835B9A3DBD}", 0,1,0)
#dicomocx=win32 com.client.Disp atch("ezDICOMax .ezDICOMX")
dicomocx=win32c om.client.genca che.EnsureModul e('{3A75EE8D-8E68-43FF-A90A-E4835B9A3DBD}',
0, 1, 0)
except:
raise ImportError("IE 4 or greater does not appear to be
installed.")
class DicomControl(py win.mfc.activex .Control, dicomocx.ezDICO MX):
def __init__(self):
pywin.mfc.activ ex.Control.__in it__(self)
dicomocx.ezDICO MX.__init__(sel f)
def OnDCMmouseDown( self, X ,Y ,Button ,Shift):
print "DICOM ocx Click!"
class HwtxControl(pyw in.mfc.activex. Control, hwtxocx.Hwtx):
def __init__(self):
pywin.mfc.activ ex.Control.__in it__(self)
hwtxocx.Hwtx.__ init__(self)
def OnClick(self):
print "hwtx click!"
class TestPanel(wxWin dow):
def __init__(self, parent, log, frame=None):
wxWindow.__init __(self, parent, -1,
style=wxCLIP_CH ILDREN|wxNO_FUL L_REPAINT_ON_RE SIZE)
sizer = wxBoxSizer(wxVE RTICAL)
hwtxCtls=RowCol Sizer()
theClass2 = MakeActiveXClas s(dicomocx.ezDI COMX,eventClass =DicomControl)
#theClass2 =
MakeActiveXClas s(hwtxocx.Hwtx, eventClass=Hwtx Control)
self.ie4=theCla ss2(self,-1)
self.ie4.SetSiz e(wxSize(300,30 0))
#self.ie4.filen ame="e:\\d02.im g"
#self.ie4.palnu mber=12
#self.ie4.state =1
hwtxCtls.Add(se lf.ie4, row=2, col=2)
sizer.Add(hwtxC tls, 0, wxEXPAND)
self.SetSizer(s izer)
self.SetAutoLay out(True)
EVT_WINDOW_DEST ROY(self, self.OnDestroy)
def OnDestroy(self, evt):
if self.ie4:
self.ie4.Cleanu p()
self.ie4 = None
def runTest(frame, nb, log):
if wxPlatform == '__WXMSW__':
win = TestPanel(nb, log, frame)
return win
else:
dlg = wxMessageDialog (frame, 'This demo only works on MSW.',
'Sorry', wxOK | wxICON_INFORMAT ION)
dlg.ShowModal()
dlg.Destroy()
overview = __doc__
if __name__ == '__main__':
class TestFrame(wxFra me):
def __init__(self):
wxFrame.__init_ _(self, None, -1, "ActiveX test -- Internet
Explorer",
size=(640, 480),
style=wxDEFAULT _FRAME_STYLE|wx NO_FULL_REPAINT _ON_RESIZE)
self.CreateStat usBar()
self.tp = TestPanel(self, sys.stdout, self)
EVT_CLOSE(self, self.OnCloseWin dow)
def OnCloseWindow(s elf, evt):
self.tp.Destroy ()
self.Destroy()
app = wxPySimpleApp()
frame = TestFrame()
frame.Show(True )
app.MainLoop()
i am a new python programer but i was really attracted by it elegant
code.i really want use wxpython as my framework,but if i cant use
activeX,i will have to change to vb:(
can you help me.Best regards.
sincerely
wangxiaoyu
Comment