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