Hi,

I'm using Python .Net in conjuction with .Net WinForms to do some GUI
development. What I have is one class that derives from Control and has
all the GUI code and one class that handles all the network I/O (using
standard Python sockets). The network I/O code runs in a separate thread
and when it receives some data it needs to pass it to the GUI thread to
display it. What I need is a custom delegate. If it was a C# program, it
would be really easy to create:
        public delegate void DataArrived(object data);

With Python.Net I don't see how I can do that. What I ended up doing is
writing a simple assembly in C# that just contains the following lines:

        public delegate void NoArgDelegate();
        public delegate void ObjectArgDelegate(object arg);
        public delegate void ArrayArgDelegate(object[] arg);

My hope is to keep this utility assembly around for those times when I
need a custom delegate. The delegates are somewhat general and with the
last one, it is possible to pass as many arguments as needed. I would
like to know, however, if anyone else encountered this problem and how
they solved it. Is there a way to solve it with pure Python .Net
(without C#)? If not, maybe a custom delegate(s) should be included into
Python .Net?

My second problem is that I can't pass Python class instances as
arguments to my delegates. For example:

def callback(arg):
        pass
d = ObjectArgDelegate(callback)

class PythonClass(object):
        pass

d(PythonClass())

Results in:

TypeError: no method matches given arguments


Is there a way to convert a python class instance to a .Net object and
then convert it back to python class instance?

Eugene
[EMAIL PROTECTED]
_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Reply via email to