Hi
I try to use nBit HTML Editor ActiveX control from python. I observed that there are multiple ways to use ActiveX in python.
I use: wxPython2.8-win32-unicode-2.8.10.1-py26.exe
I tried to implement it "ActiveXWrapper_Acrobat.py" way and it works OK but similarly like "ActiveXWrapper_Acrobat.py" - it crashes on exit.
I tested the "ActiveXWrapper_Acrobat.py". It works OK. But it looks like there is a problem with application exit. The application always crashes on exit.
Do you know a way how to improve "ActiveXWrapper_Acrobat.py" to be able to not crash on exit of the application?
There is displayed exception: "Win32 exception occurred releasing IUnknown" and Application Error dialog displayed.
···
---------------------------
python.exe - Application Error
---------------------------
The instruction at "0x1e0a47da" referenced memory at "0x00000004". The memory could not be "read".
Click on OK to terminate the program
---------------------------
OK ---------------------------
Attached is screenshot.
I tried to use other way - similarly like it is in "ActiveX_FlashWindow" and "flashwin.py". There is used comtypes package for it. http://starship.python.net/crew/theller/comtypes/
And use of wx.lib.activex.ActiveXCtrl class there.
Comptypes includes a code generator that does create modules containing the Python interface class (and more) automatically from COM typelibraries.
GetModule(tlib)
But I observed following problems below. It looks like there is a problem with "None" constant there. "None" is reserved word in the PYTHON language. That is why generation of interface classes for {446276EE-F180-4092-8999-4B4D33FA389F} fails. Is there a way how to solve it?
Python console:
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import comtypes.client
>>> test = comtypes.client.GetModule(('{446276EE-F180-4092-8999-4B4D33FA389F}', 347,4))
# Generating comtypes.gen._446276EE_F180_4092_8999_4B4D33FA389F_0_347_4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\win_prgs\Python26\lib\site-packages\comtypes\client\_generate.py", li
ne 112, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "C:\win_prgs\Python26\lib\site-packages\comtypes\client\_generate.py", li
ne 188, in _CreateWrapper
mod = _my_import(fullname)
File "C:\win_prgs\Python26\lib\site-packages\comtypes\client\_generate.py", li
ne 26, in _my_import
return __import__(fullname, globals(), locals(), ['DUMMY'])
File "C:\win_prgs\Python26\lib\site-packages\comtypes\gen\_446276EE_F180_4092_
8999_4B4D33FA389F_0_347_4.py", line 97
None = 0
SyntaxError: assignment to None
>>>
Pavel
Pavel Nikitenko wrote:
I tried to implement it "ActiveXWrapper_Acrobat.py" way and it works OK but similarly like "ActiveXWrapper_Acrobat.py" - it crashes on exit.
I tested the "ActiveXWrapper_Acrobat.py". It works OK. But it looks like there is a problem with application exit. The application always crashes on exit.
Do you know a way how to improve "ActiveXWrapper_Acrobat.py" to be able to not crash on exit of the application
What version of Adobe Reader are you using?
There is a problem with Version 9 that produces the crash on exit that
you are seeing. It is most likely a problem with Adobe Reader itself as
there are reports of other non-Python users experiencing the same
thing, but there are no acknowledgements of a problem in any of the
Adobe support forums that I have seen. Adobe Reader Version 5 through 8
all work fine with the wxPython wrappers.
Regards,
David Hughes
Forestfield Software
It also crashes on exit for: "ActiveXWrapper_IE.py"
···
On Jun 12, 2:05 pm, David Hughes <d...@forestfield.co.uk> wrote:
Pavel Nikitenko wrote:
> I tried to implement it "ActiveXWrapper_Acrobat.py" way and it works OK
> but similarly like "ActiveXWrapper_Acrobat.py" - it crashes on exit.
> I tested the "ActiveXWrapper_Acrobat.py". It works OK. But it looks like
> there is a problem with application exit. The application always crashes
> on exit.
> Do you know a way how to improve "ActiveXWrapper_Acrobat.py" to be able
> to not crash on exit of the application
What version of Adobe Reader are you using? There is a problem with
Version 9 that produces the crash on exit that you are seeing. It is
most likely a problem with Adobe Reader itself as there are reports of
other non-Python users experiencing the same thing, but there are no
acknowledgements of a problem in any of the Adobe support forums that I
have seen. Adobe Reader Version 5 through 8 all work fine with the
wxPython wrappers.
Regards,
David Hughes
Forestfield Software
Pavel Nikitenko schrieb:
> Hi
>
> I try to use nBit HTML Editor ActiveX control from python. I observed
> that there are multiple ways to use ActiveX in python.
[...]
> I tried to use other way - similarly like it is in "ActiveX_FlashWindow"
> and "flashwin.py". There is used comtypes package for it.
> http://starship.python.net/crew/theller/comtypes/
> And use of wx.lib.activex.ActiveXCtrl class there.
>
> Comptypes includes a code generator that does create modules containing
> the Python interface class (and more) automatically from COM typelibraries.
>
> GetModule(tlib)
>
>
> But I observed following problems below. It looks like there is a
> problem with "None" constant there. "None" is reserved word in the
> PYTHON language. That is why generation of interface classes for
> {446276EE-F180-4092-8999-4B4D33FA389F} fails. Is there a way how to
> solve it?
The comtypes code generator currently does not check for valid Python
identifier names, so the generated module raises a SyntaxError when
you try to import it.
The reason is the following code snippet from the decompiled HTML editor
type information:
typedef [uuid(45749F33-3BC9-42DE-840A-D92AE0153DC0), version(1.0)]
enum {
None = 0,
Solid = 1
} EdBorderStyle;
which lets the code generator create this Python code:
# values for enumeration 'EdBorderStyle'
None = 0
Solid = 1
EdBorderStyle = c_int # enum
You can try to manually change the generated code like this:
# values for enumeration 'EdBorderStyle'
ED_None = 0
ED_Solid = 1
EdBorderStyle = c_int # enum
and then you may be able to use the module. comtypes will
not overwrite it once it exists.
Thomas