I tried to use Python.NET with COM objects, and I couldn't
get it to work. The documentation says it works, so I
assume either that there is a bug or that I'm doing
something wrong.
Background: I have a large COM library of vtbl-based
interfaces, not accessible through Win32all. They can be
accessed through ctypes but it's slow and there are a many
cases where the autogenerated wrappers are wrong. This
library ships with .NET assemblies which properly deal with
those special cases, so that's why I'm interested in
Python.NET.
What happens is I can import the interfaces, and I can
import the CoClasses, but Python.NET seems to think the
CoClasses are interfaces too. So when I try to instantiate
an object, it fails with a message "interface constructor
requires a single argument" or something like that.
Any ideas?
Bruce
Hi all,
I've got a python script that I want to create a C# GUI for. I'd like to
have a web browser control on the form that I can control from python. This
is not too difficult - just drop a WebBrowser control on the form and create
a public property to expose the control.
The problem is that .net is wrapping the control (AxHost etc) and not all
the methods are exposed (e.g. Document.all.tags does not work...)
Can I get the control's IDispatch and use late-binding? If so how????
If I cant can I create the activex control from python and 'place' it on a
specific form (given a HWND)? Any examples of manually creating and placing
a activeX control?
Thanks for any advice.
Andre
How does one use PythonNET in a Zope Environment to access .NET libraries...
Can we also use pre-created .NET libraries, which inturn access database servers, the results of which can be shown via ZPT?
Kind Regards,
Anand.
More data:
If I'm running Python from a Novell network share
volume (that is, no local Python install) and try
running a Python.NET script, I receive:
Unhandled Exception:
System.Security.Policy.PolicyException: Required
permissions cannot be acquired.
at CLRModule.initCLR()
The script I'm running is simply a single line,
"import CLR".
Any tips from the .NET savvy programmers on the list?
(Aside from: "Don't do that." ;)
Additionally, I'm having trouble getting McMillan's
installer to behave with the CLR imports. Is this
something that may get resolved in the next beta?
I've seen mention of switching to using the official
import hooks in the TODO file in CVS. This sounds
like something promising.
TIA - It's really remarkable how well Python.NET
works, and how simple it is to take C# code and
convert it.
A new puzzle:
Today I tried a Python.NET app on a machine that was
accessing a Python installed on a network share. I
had moved the CLR.dll & Python.Runtime.dll into the
same place that I have them on my workstation's Python
install. I ended up getting an error every time I
tried to import the CLR module.
For kicks, I copied all of the Python.NET files to a
network folder and tried using it (in this case,
simply trying to run python.exe), and I receive:
Unhandled Exception:
System.Security.Policy.PolicyException:
Required permissions cannot be acquired.
at PythonConsole.Main(String[] args)
Any idea on why Python for .NET would get frisky on a
Novell share? Help me out here, I suspect I'm
overlooking something super obvious...it's been a long
week!
-BA
Today I found that in my wxPython apps, adding a CLR
import at the top of the files causes wxPython's
mainloop to generate a warning message box which reads
"Could not initialize OLE". Otherwise, the
application seemed functional. I experimented with
it, and it seems that delaying CLR-related imports
until after the wx Mainloop has started does the
trick.
Here's a tiny wxPython app that demonstrates the
error:
import wx
#import CLR
class MyApp(wx.App):
def OnInit(self):
# global CLR
# import CLR
self.frame = wx.Frame(None, -1, 'Test Window')
self.frame.Show(True)
return True
app = MyApp(0)
app.MainLoop()
If you uncomment the first comment, the application
window will open, and an OleInitialize failure message
will pop up. If you instead uncomment the second two
comments, the application window will open without
error. (Note: this was with the latest wxPython build,
2.5.1.5 - I assume similar failures occur with older
builds.)
It's not a big deal to move the imports, but it's a
little unnatural to me. Is this something that's
broken in Python for .NET, or .NET, or... Here's a
possibly related message I found on wx-users: http://lists.wxwidgets.org/archive/wx-users/msg30069.html