473,224 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

how to use activex in wxpython with event support

Hello:
i want use activex in wxpython program,but when i use MakeActiveXClass
an exception occurs.

this is my source code dealing the DICOM ocx.I must note that in this
program "hwtxcontrol" 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\wxPython\lib\activexwrapper.py", line 105, in
axw__init__
File "D:\Py22\lib\site-packages\win32com\gen_py\3A75EE8D-8E68-43FF-A90A-E4835B9A3DBDx0x1x0.py",
line 187, in __init__
cookie=cp.Advise(win32com.server.util.wrap(self,
usePolicy=EventHandlerPolicy))
com_error: (-2147220990, 'CONNECT_E_CANNOTCONNECT', None, None)

the ocx and the source code (in delphi) you can down at:

http://www.psychology.nottingham.ac..../dicomcom.html

from wxPython.wx import *
from wxPython.lib.rcsizer import RowColSizer
import pywin.mfc.activex
import activexwrapper,win32ui

if wxPlatform == '__WXMSW__':
from wxPython.lib.activexwrapper import MakeActiveXClass
import win32com.client.gencache
import win32com.client
try:
import hwtxcontrol
hwtxocx=hwtxcontrol
#import ezdicom
#dicomocx=ezdicom
#dicomocx=win32com.client.gencache.EnsureModule("{ 3A75EE8D-8E68-43FF-A90A-E4835B9A3DBD}",0,1,0)
#dicomocx=win32com.client.Dispatch("ezDICOMax.ezDI COMX")
dicomocx=win32com.client.gencache.EnsureModule('{3 A75EE8D-8E68-43FF-A90A-E4835B9A3DBD}',
0, 1, 0)
except:
raise ImportError("IE4 or greater does not appear to be
installed.")

class DicomControl(pywin.mfc.activex.Control, dicomocx.ezDICOMX):
def __init__(self):
pywin.mfc.activex.Control.__init__(self)
dicomocx.ezDICOMX.__init__(self)
def OnDCMmouseDown(self, X ,Y ,Button ,Shift):
print "DICOM ocx Click!"

class HwtxControl(pywin.mfc.activex.Control, hwtxocx.Hwtx):
def __init__(self):
pywin.mfc.activex.Control.__init__(self)
hwtxocx.Hwtx.__init__(self)
def OnClick(self):
print "hwtx click!"
class TestPanel(wxWindow):
def __init__(self, parent, log, frame=None):
wxWindow.__init__(self, parent, -1,

style=wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE)
sizer = wxBoxSizer(wxVERTICAL)
hwtxCtls=RowColSizer()
theClass2 = MakeActiveXClass(dicomocx.ezDICOMX,eventClass=Dico mControl)
#theClass2 =
MakeActiveXClass(hwtxocx.Hwtx,eventClass=HwtxContr ol)
self.ie4=theClass2(self,-1)
self.ie4.SetSize(wxSize(300,300))
#self.ie4.filename="e:\\d02.img"
#self.ie4.palnumber=12
#self.ie4.state=1
hwtxCtls.Add(self.ie4, row=2, col=2)
sizer.Add(hwtxCtls, 0, wxEXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)
EVT_WINDOW_DESTROY(self, self.OnDestroy)
def OnDestroy(self, evt):
if self.ie4:
self.ie4.Cleanup()
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_INFORMATION)
dlg.ShowModal()
dlg.Destroy()

overview = __doc__

if __name__ == '__main__':
class TestFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, None, -1, "ActiveX test -- Internet
Explorer",
size=(640, 480),

style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_R ESIZE)
self.CreateStatusBar()
self.tp = TestPanel(self, sys.stdout, self)
EVT_CLOSE(self, self.OnCloseWindow)

def OnCloseWindow(self, 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
Jul 18 '05 #1
1 5917
i have solve the problem.my solution is :since this activex(DICOM)
works fine in vb,and i know activex controls developed by vb works
fine in python,so why cant i develop an activex control which wrap
this activex(DICOM)?so i build a vb's activex project insert this
activex(DICOM) in it and delegate this control(DICOM) events into vb
control's event.

this activex developed by vb works fine in wxpython,MakeActiveXClass
works fine.

but i really dont understand why this method works,can you give me
some explanation?

best regards.

wangxiaoyu
wx*****@hotmail.com (wang xiaoyu) wrote in message news:<e4**************************@posting.google. com>...
Hello:
i want use activex in wxpython program,but when i use MakeActiveXClass
an exception occurs.

this is my source code dealing the DICOM ocx.I must note that in this
program "hwtxcontrol" 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\wxPython\lib\activexwrapper.py", line 105, in
axw__init__
File "D:\Py22\lib\site-packages\win32com\gen_py\3A75EE8D-8E68-43FF-A90A-E4835B9A3DBDx0x1x0.py",
line 187, in __init__
cookie=cp.Advise(win32com.server.util.wrap(self,
usePolicy=EventHandlerPolicy))
com_error: (-2147220990, 'CONNECT_E_CANNOTCONNECT', None, None)

the ocx and the source code (in delphi) you can down at:

http://www.psychology.nottingham.ac..../dicomcom.html

from wxPython.wx import *
from wxPython.lib.rcsizer import RowColSizer
import pywin.mfc.activex
import activexwrapper,win32ui

if wxPlatform == '__WXMSW__':
from wxPython.lib.activexwrapper import MakeActiveXClass
import win32com.client.gencache
import win32com.client
try:
import hwtxcontrol
hwtxocx=hwtxcontrol
#import ezdicom
#dicomocx=ezdicom
#dicomocx=win32com.client.gencache.EnsureModule("{ 3A75EE8D-8E68-43FF-A90A-E4835B9A3DBD}",0,1,0)
#dicomocx=win32com.client.Dispatch("ezDICOMax.ezDI COMX")
dicomocx=win32com.client.gencache.EnsureModule('{3 A75EE8D-8E68-43FF-A90A-E4835B9A3DBD}',
0, 1, 0)
except:
raise ImportError("IE4 or greater does not appear to be
installed.")

class DicomControl(pywin.mfc.activex.Control, dicomocx.ezDICOMX):
def __init__(self):
pywin.mfc.activex.Control.__init__(self)
dicomocx.ezDICOMX.__init__(self)
def OnDCMmouseDown(self, X ,Y ,Button ,Shift):
print "DICOM ocx Click!"

class HwtxControl(pywin.mfc.activex.Control, hwtxocx.Hwtx):
def __init__(self):
pywin.mfc.activex.Control.__init__(self)
hwtxocx.Hwtx.__init__(self)
def OnClick(self):
print "hwtx click!"
class TestPanel(wxWindow):
def __init__(self, parent, log, frame=None):
wxWindow.__init__(self, parent, -1,

style=wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE)
sizer = wxBoxSizer(wxVERTICAL)
hwtxCtls=RowColSizer()
theClass2 = MakeActiveXClass(dicomocx.ezDICOMX,eventClass=Dico mControl)
#theClass2 =
MakeActiveXClass(hwtxocx.Hwtx,eventClass=HwtxContr ol)
self.ie4=theClass2(self,-1)
self.ie4.SetSize(wxSize(300,300))
#self.ie4.filename="e:\\d02.img"
#self.ie4.palnumber=12
#self.ie4.state=1
hwtxCtls.Add(self.ie4, row=2, col=2)
sizer.Add(hwtxCtls, 0, wxEXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)
EVT_WINDOW_DESTROY(self, self.OnDestroy)
def OnDestroy(self, evt):
if self.ie4:
self.ie4.Cleanup()
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_INFORMATION)
dlg.ShowModal()
dlg.Destroy()

overview = __doc__

if __name__ == '__main__':
class TestFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, None, -1, "ActiveX test -- Internet
Explorer",
size=(640, 480),

style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_R ESIZE)
self.CreateStatusBar()
self.tp = TestPanel(self, sys.stdout, self)
EVT_CLOSE(self, self.OnCloseWindow)

def OnCloseWindow(self, 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

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: dw85745 | last post by:
PROBLEMS I Haven't solved: 1. Timing issue between real-time server #1 and my drawing tools. Will moving the tools (currently within module) to an ActiveX (exe or DLL) solve the problem or...
0
by: Paul H. Milenkovic | last post by:
I think the problem is with ActiveX controls developed in Delphi -- I am having the same CONNECT_E_CANNOTCONNECT error message at that same point when I try to use ActiveX control I have developed in...
2
by: Daniel Bickett | last post by:
Hello, I am writing an application using two event-driven libraries: wxPython, and twisted. The first problem I encountered in the program is the confliction between the two all-consuming...
5
by: fooooo | last post by:
This is a network app, written in wxPython and the socket module. This is what I want to happen: GUI app starts. User clicks a button to 'start' the work of the app. When start is pressed, a new...
8
by: Jan Danielsson | last post by:
Hello all, I wanted to plot some statistics, so I wrote a simple wxPython class to do it. Then I realized that I would like to draw bar graphs, so I added that too. Since I'm a complete...
0
by: zevikw | last post by:
I am using an ActiveX control in a .NET application which I put on a form. I have another .NET control on that form that handles the Validating event. The method that handles the Validating event,...
0
by: =?utf-8?B?5LiA6aaW6K+X?= | last post by:
Hi all! Have u tried genaxmodule.py provided by wxPython to create a wrapper module for an activex control? For me, some times it works, but some times, it doesn't....
0
by: vml | last post by:
Hello, I am trying to mograte from vb 6 to python. I have a very usefull AX control. It can be : -just a bitmap -an active picture where you can plot data and put cursors -a data explorer ...
1
by: Jialiang Ge [MSFT] | last post by:
Hello Philippe, In addition to bruce's points, I'd suggest the KB article http://support.microsoft.com/kb/317392. It demonstrates how to host an ActiveX control in ASP.NET (for your first...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.