[python-win32] Python-win32 Digest, Vol 33, Issue 7
Tony C
cappy2112 at gmail.com
Thu Dec 8 21:38:58 CET 2005
Ok, I've removed all of the references to my Class nam in the Reg- there
were a lot, put in a static GUID,
added self back to the arg list, and now the call to the split function
works.
There seems to be a problem on the VB side now, related to the types.
Mark said all vars in VB need to be objects, and that's another place where
I went wrong.
Will change my variants to Objects.
On 12/8/05, Tony C <cappy2112 at gmail.com> wrote:
>
>
>
> >>Your main problem is that you forgot the "self" param in the method.
>
>
> Actually, I started out *with* the self as described in the book.
> I removed it because the error message implied two args were being passed
> instead of one, not vice-versa.
>
> What do you suggest?
> Is there any chance that the previous turds in the reg are causing a
> problem?
>
> I will try to remove them all, if I can find them
>
>
> Cheers,
> >
> > Mark
> > -----Original Message-----
> > From: Tony C [mailto:cappy2112 at gmail.com]
> > Sent: Thursday, 8 December 2005 3:25 PM
> > To: Mark Hammond
> > Cc: python-win32 at python.org
> > Subject: Re: Python-win32 Digest, Vol 33, Issue 7
> >
> >
> > Ok, I'm about 90% there now
> >
> > I've used the Simple.py from page 213, because there is less involved.
> > when I run it- I see the registration messages. All is good so far.
> > I made one tiny change, related to the call to CreateGuid()
> >
> > import pythoncom
> >
> > class PythonCOMServer:
> >
> > _public_methods_ = ['pyCOMSplit']
> > _reg_progid_= "PythonCOMDemo"
> > _reg_clsid_= pythoncom.CreateGuid()
> >
> > def pyCOMSplit(StringFromVB):
> > from string import split
> > if self.StringFromVB != None:
> > return split(self.StringFromVB )
> >
> >
> > if __name__ == '__main__':
> > print"Registering COM server"
> > import win32com.server.register
> > win32com.server.register.UseCommandLine( PythonCOMServer )
> >
> >
> > When I try sending a string from the VB side,
> > Type Error; str() takes at most 1 arguments, two given
> >
> > I see no explicit calls to str.
> >
> >
> > Here's the VB side
> >
> >
> > Option Explicit
> >
> > Private Sub cmdToPython_Click()
> >
> >
> > Dim Python As Object
> > Dim FromPython As Variant
> >
> > Set Python = CreateObject("PythonCOMDemo")
> >
> > FromPython = Python.pyCOMSplit("This string to Python")
> >
> > txtFromPython = FromPython
> >
> > End Sub
> >
> >
> > This call, is what is causing the runtime exception
> > Python.pyCOMSplit ("This string to Python")
> >
> >
> > What am I doing wrong?
> >
> > thanks
> >
> >
> >
> >
> >
> >
> >
> >
> > On 12/6/05, Mark Hammond < mhammond at skippinet.com.au> wrote:
> > > >>Certainly COM would work. In this case your VB EXE would use
> > CreateObject
> > > >>to create a Python implemented object.
> >
> > > As what type of Python Object?
> >
> > > I have the VB6 ide open, and the references Browser as well,
> > > there is no generic Python object to include into a VB project.
> >
> > > Which means one would have to create a Python COM server
> > > and Type library first, before being able to reference it
> > > from the VB IDE.
> >
> > Actually, you don't need to create a typelib. Just register the
> > PythonCOM
> > server, and have VB use CreateObject with the ProgID. All vars will
> > need to
> > be declared as "object", and you wont get auto-complete type features,
> > but
> > it will work. VB supports late-binding.
> >
> >
> > > Even though I have Python Programming in Win32, I'm not sure what
> > > needs to be done to make a minimal Python COM server that can be
> > > called from VB.
> >
> > Pages 221 and 222 have an example using VBA (ie, the VB embedded in
> > MSOffice
> > apps)
> >
> > > Also, creating a type library requires using Visual C- which isn't a
> > > problem, it's the language of the IDL required to create the TLB that
> > > I don't udnerstand.
> >
> > You should be able to avoid TLBs - certainly to get started...
> >
> > Mark
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20051208/e851335a/attachment.htm
More information about the Python-win32
mailing list