From mhammond at skippinet.com.au Tue Jan 2 04:17:33 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 2 Jan 2007 14:17:33 +1100 Subject: [python-win32] Dispatch error 'CoInitialize has not been called' In-Reply-To: Message-ID: <0ee701c72e1c$8c36c4b0$160a0a0a@enfoldsystems.local> Another random comment re CoInitialize in servers... Depending on your requirements, you may be better off with: try: pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) except pythoncom.com_error: # already initialized. pass (and as per Roger's comments, adding a flag to handle CoUninitialize). That way, you are more likely to get a COM object that can be shared across multiple threads (eg, grabbing a shared ActiveDirectory connection), and also handle the possibility someone else has beaten you to the Initialize using different flags (a distinct possibility in a "plugin" style server environment.) Also, many server environments, such as Zope and I guess Apache, use some kind of thread-pool mechanism. Threads are often started early, and only terminated as the process terminates (or whenever the server feels the need to recycle threads for whatever reason). For this reason, I admit that not all code I write ensures CoUninitialize() is always called, even though I should :) Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2180 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20070102/e3270cd8/attachment.bin From todd at ccb.wustl.edu Tue Jan 2 23:04:42 2007 From: todd at ccb.wustl.edu (Todd Dolinsky) Date: Tue, 2 Jan 2007 17:04:42 -0500 Subject: [python-win32] Python hangs on exit after failed IIS GetObject call Message-ID: <97ee2dff0701021404h164a1d1di894a229c002be8d1@mail.gmail.com> Hi Everyone - I'm seeing Python hang on exit after a failed IIS GetObject() call, similar to what is described at http://mail.python.org/pipermail/python-win32/2005-October/003819.html. For instance, the code import win32com.client import pywintypes try: testobj=win32com.client.GetObject("IIS://localhost/doesnotexist") except pywintypes.com_error: print "Could not find directory" will except correctly and print the message, but the Python interpreter will never exit. This appears to only happen when the following error occurs pywintypes.com_error: (-2147024893, 'The system cannot find the path specified.', None, None) Trying pure nonsense arguments in the GetObject or other generated error ids allow the interpreter to exit correctly. I suppose the query to IIS is not cleaning up correctly, but I can't determine what is causing Python to hang. I should note that this is using Python 1.5.2 (and an older version of pywin32 for that release) - unfortunately upgrading is not a viable solution at this time. Thanks in advance for any help! Todd From mhammond at skippinet.com.au Wed Jan 3 00:56:27 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 3 Jan 2007 10:56:27 +1100 Subject: [python-win32] Python hangs on exit after failed IIS GetObject call In-Reply-To: <97ee2dff0701021404h164a1d1di894a229c002be8d1@mail.gmail.com> Message-ID: <106601c72ec9$9e5fa140$160a0a0a@enfoldsystems.local> > I'm seeing Python hang on exit after a failed IIS GetObject() call, > similar to what is described at > http://mail.python.org/pipermail/python-win32/2005-October/003819.html. > For instance, the code > import win32com.client > import pywintypes > try: > testobj=win32com.client.GetObject("IIS://localhost/doesnotexist") > except pywintypes.com_error: > print "Could not find directory" I'm afraid that code works OK for me - it causes a COM exception (-2147024893, 'The system cannot find the path specified.', None, None), but terminates cleanly. If that exact snippet hangs for you and you are unable to upgrade, then I'm afraid I can't help. If that snippet is part of a larger program that fails, I suspect the problem will be that not all COM objects have been cleaned up - but that is pure speculation. Mark From mmorisak at risc.uni-linz.ac.at Thu Jan 4 18:08:35 2007 From: mmorisak at risc.uni-linz.ac.at (Michael Morisak) Date: Thu, 04 Jan 2007 18:08:35 +0100 Subject: [python-win32] win32ui and resources for dialogs Message-ID: <459D3493.9050701@risc.uni-linz.ac.at> Hi I have the following Situation: I have a dialog resource in an dll and I want to open a modal dialog with this resource. dlg= pywin.mfc.dialog.Dialog(myDialogID) dlg.DoModal() works but the problem is that i would set the Parent of the Dialog in MFC the CDialog Constructor allows to pass a Parent (which i need): explicit CDialog( UINT /nIDTemplate/, CWnd* /pParentWnd/ = NULL ); but i really do not know how to do this with python-win32 thanx for the help and the great work done in python.win32 c.u. -- Michael Morisak RISC Software GmbH -- Johannes Kepler Universitaet Linz IT-Center, Hauptstrasse 119 phone: ++43 7236 3343-251 4232 Hagenberg, Austria fax: ++43 7236 3343-250 From axiomx11 at gmail.com Fri Jan 5 23:21:04 2007 From: axiomx11 at gmail.com (Axiom X11) Date: Fri, 5 Jan 2007 17:21:04 -0500 Subject: [python-win32] Calling EasyDialogs.AskFileForOpen, and then killing it Message-ID: <70b542190701051421t4e6c78bbya45e42b4aec24ae4@mail.gmail.com> I have a small program that you no GUI of its own, but is controlled via a series of telnet commands (from a crestron box I believe). The program is running a twisted reactor, and needs to constantly be listening for commands. When this file dialog has come up, the reactor will ignore all other commands until a file has been selected. I fixed this by calling the file dialog in a thread, but what I really need to do is kill the dialog, and in all my previous experiance with threads (very little), there is no way to kill a thread before it has run through its path. (If there is, I should like to know about it) So how would I go about getting rid of this dialog, as if they had clicked the cancel button. (Note: of course it works fine if they just click the cancel button, but this dialog appears on a different screen than the GUI, so I need to GUI to be able to seamlessly kill it when they decide to run a different command). -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070105/595fbc86/attachment.html From einar at ife.no Mon Jan 8 11:43:02 2007 From: einar at ife.no (=?ISO-8859-1?Q?Einar_S=F8rheim?=) Date: Mon, 08 Jan 2007 11:43:02 +0100 Subject: [python-win32] comtypes: Problem with passing string argument Message-ID: <45A22036.4090605@ife.no> I have a com library that I have a hard time getting to work, some of it works in win32com, some in comtypes. Have a question first for comtypes(using python2.4 and svn checkout 3.jan07 of comtypes): The following code fails at the last step: self.dl = comtypes.client.GetModule(r"C:\Program Files\Common Files\Calsep\PvtsDataLayer.dll") self.fl = comtypes.client.GetModule(r"C:\Program Files\Common Files\Calsep\PvtsDataModel.dll") self.datalayer = comtypes.client.CreateObject(self.dl.FluidDepoWaxDataLayer) self.fluid = comtypes.client.CreateObject(self.fl.Fluid) cp=self.datalayer.CheckCompatibility(DatabasePath=r"C:\Program Files\Calsep\Sample Programs\FlashOSDatabase.fdb") Errormessage: File "mtucpvt.py", line 46, in Connect cp=self.datalayer.CheckCompatibility(DatabasePath=r"C:\Program Files\Calsep\Sample Programs\FlashOSDatabase.fdb") ValueError: Procedure probably called with too many arguments (4 bytes in excess) The generated inteface code looks like: _FluidDepoWaxDataLayer._methods_ = [ COMMETHOD([dispid(1745027104), 'propput'], HRESULT, 'UseDatabaseFormat', ( ['in'], PvtsDLUseDatabaseFormat, 'None' )), COMMETHOD([dispid(1745027104), 'propget'], HRESULT, 'UseDatabaseFormat', ( ['retval', 'out'], POINTER(PvtsDLUseDatabaseFormat), 'None' )), COMMETHOD([dispid(1610809375)], HRESULT, 'IsConnectedAsReadOnly', ( ['retval', 'out'], POINTER(VARIANT_BOOL), 'None' )), COMMETHOD([dispid(1610809374)], HRESULT, 'CheckCompatibility', ( ['in'], BSTR, 'DatabasePath' ), ( ['retval', 'out'], POINTER(c_short), 'None' )), Any ideas on what is wrong here? Regards Einar S?rheim From theller at ctypes.org Mon Jan 8 17:46:40 2007 From: theller at ctypes.org (Thomas Heller) Date: Mon, 08 Jan 2007 17:46:40 +0100 Subject: [python-win32] comtypes: Problem with passing string argument In-Reply-To: <45A22036.4090605@ife.no> References: <45A22036.4090605@ife.no> Message-ID: Einar S?rheim schrieb: > I have a com library that I have a hard time getting to work, some of it > works in win32com, some in comtypes. > Have a question first for comtypes(using python2.4 and svn checkout > 3.jan07 of comtypes): > The following code fails at the last step: > self.dl = comtypes.client.GetModule(r"C:\Program Files\Common > Files\Calsep\PvtsDataLayer.dll") > self.fl = comtypes.client.GetModule(r"C:\Program Files\Common > Files\Calsep\PvtsDataModel.dll") > self.datalayer = > comtypes.client.CreateObject(self.dl.FluidDepoWaxDataLayer) > self.fluid = comtypes.client.CreateObject(self.fl.Fluid) > cp=self.datalayer.CheckCompatibility(DatabasePath=r"C:\Program > Files\Calsep\Sample Programs\FlashOSDatabase.fdb") > Errormessage: > File "mtucpvt.py", line 46, in Connect > cp=self.datalayer.CheckCompatibility(DatabasePath=r"C:\Program > Files\Calsep\Sample Programs\FlashOSDatabase.fdb") > ValueError: Procedure probably called with too many arguments (4 bytes > in excess) > > The generated inteface code looks like: > _FluidDepoWaxDataLayer._methods_ = [ > COMMETHOD([dispid(1745027104), 'propput'], HRESULT, 'UseDatabaseFormat', > ( ['in'], PvtsDLUseDatabaseFormat, 'None' )), > COMMETHOD([dispid(1745027104), 'propget'], HRESULT, 'UseDatabaseFormat', > ( ['retval', 'out'], POINTER(PvtsDLUseDatabaseFormat), > 'None' )), > COMMETHOD([dispid(1610809375)], HRESULT, 'IsConnectedAsReadOnly', > ( ['retval', 'out'], POINTER(VARIANT_BOOL), 'None' )), > COMMETHOD([dispid(1610809374)], HRESULT, 'CheckCompatibility', > ( ['in'], BSTR, 'DatabasePath' ), > ( ['retval', 'out'], POINTER(c_short), 'None' )), > > Any ideas on what is wrong here? This looks like some problem with the interface code. Was it generated or written manually? Does (re-)generating the module help? Are you sure that the type library is up-to-date? If you also have problems using the object in win32com, what are the symptoms? Thomas From einar at ife.no Tue Jan 9 08:53:51 2007 From: einar at ife.no (=?ISO-8859-1?Q?Einar_S=F8rheim?=) Date: Tue, 09 Jan 2007 08:53:51 +0100 Subject: [python-win32] comtypes: Problem with passing string argument In-Reply-To: References: <45A22036.4090605@ife.no> Message-ID: <45A34A0F.1070505@ife.no> Thomas Heller wrote: >Einar S?rheim schrieb: > > >>I have a com library that I have a hard time getting to work, some of it >>works in win32com, some in comtypes. >>Have a question first for comtypes(using python2.4 and svn checkout >>3.jan07 of comtypes): >>The following code fails at the last step: >> self.dl = comtypes.client.GetModule(r"C:\Program Files\Common >>Files\Calsep\PvtsDataLayer.dll") >> self.fl = comtypes.client.GetModule(r"C:\Program Files\Common >>Files\Calsep\PvtsDataModel.dll") >> self.datalayer = >>comtypes.client.CreateObject(self.dl.FluidDepoWaxDataLayer) >> self.fluid = comtypes.client.CreateObject(self.fl.Fluid) >> cp=self.datalayer.CheckCompatibility(DatabasePath=r"C:\Program >>Files\Calsep\Sample Programs\FlashOSDatabase.fdb") >>Errormessage: >> File "mtucpvt.py", line 46, in Connect >> cp=self.datalayer.CheckCompatibility(DatabasePath=r"C:\Program >>Files\Calsep\Sample Programs\FlashOSDatabase.fdb") >>ValueError: Procedure probably called with too many arguments (4 bytes >>in excess) >> >>The generated inteface code looks like: >>_FluidDepoWaxDataLayer._methods_ = [ >> COMMETHOD([dispid(1745027104), 'propput'], HRESULT, 'UseDatabaseFormat', >> ( ['in'], PvtsDLUseDatabaseFormat, 'None' )), >> COMMETHOD([dispid(1745027104), 'propget'], HRESULT, 'UseDatabaseFormat', >> ( ['retval', 'out'], POINTER(PvtsDLUseDatabaseFormat), >>'None' )), >> COMMETHOD([dispid(1610809375)], HRESULT, 'IsConnectedAsReadOnly', >> ( ['retval', 'out'], POINTER(VARIANT_BOOL), 'None' )), >> COMMETHOD([dispid(1610809374)], HRESULT, 'CheckCompatibility', >> ( ['in'], BSTR, 'DatabasePath' ), >> ( ['retval', 'out'], POINTER(c_short), 'None' )), >> >>Any ideas on what is wrong here? >> >> > >This looks like some problem with the interface code. Was it generated or >written manually? Does (re-)generating the module help? Are you sure >that the type library is up-to-date? > >If you also have problems using the object in win32com, what are the symptoms? > >Thomas > > Interface code was generated automatically, deleting the files in the 'gen' folder and re-generating the interface files does not help. win32com works as expected on this part of the code, their interface code looks like the following: class _FluidDepoWaxDataLayer(DispatchBaseClass): CLSID = IID('{FF3D17D3-69D4-4BC9-8173-7BDBBDDC4FE3}') coclass_clsid = IID('{F6A1D76E-C0AF-4A99-9D35-DDE8C3DF1B3A}') def AddDepoWaxCase(self, DepoWaxCase=defaultNamedNotOptArg): return self._ApplyTypes_(1610809367, 1, (3, 0), ((16393, 3),), 'AddDepoWaxCase', None,DepoWaxCase ) def AddFluid(self, Fluid=defaultNamedNotOptArg): return self._ApplyTypes_(1610809358, 1, (3, 0), ((16393, 3),), 'AddFluid', None,Fluid ) def CheckCompatibility(self, DatabasePath=defaultNamedNotOptArg): return self._oleobj_.InvokeTypes(1610809374, LCID, 1, (2, 0), ((8, 1),),DatabasePath ) ...... vtables entry is : (( 'CheckCompatibility' , 'DatabasePath' , None , ), 1610809374, (1610809374, (), [ (8, 1, None, None) , (16386, 10, None, None) , ], 1 , 1 , 4 , 0 , 148 , (3, 0, None, None) , 0 , )), However win32com fails at a later stage using a companion com library, I will make a separate post about this problem. thanks, Einar S?rheim From einar at ife.no Tue Jan 9 11:08:02 2007 From: einar at ife.no (=?ISO-8859-1?Q?Einar_S=F8rheim?=) Date: Tue, 09 Jan 2007 11:08:02 +0100 Subject: [python-win32] win32com: Problem with passing short integer? Message-ID: <45A36982.2000304@ife.no> Hi, I have a set of com dlls that I have a hard time to get working together with python. In this particular case everything seems to work nicely until I make a function call with a short int as input argument. The following error message is given: Traceback (most recent call last): File "mtupvt.py", line 123, in ? o.Flash(101300,290) File "mtupvt.py", line 81, in Flash self.DisplayFLashOut() File "mtupvt.py", line 100, in DisplayFLashOut mix.ComponentName(i) File ">", line 2, in ComponentName pywintypes.com_error: (-2147352573, 'Member not found.', None, None) The interface code is generated automatically in the 'gen_py' folder, the interface contains only vtable-entries, I am not sure what this means, however for this particular function it looks like: IFlashPhase_vtables_dispatch_ = 0 IFlashPhase_vtables_ = [ (( 'NumberofComponents' , 'pVal' , ), 1610678272, (1610678272, (), [ (16386, 10, None, None) , ], 1 , 2 , 4 , 0 , 12 , (3, 0, None, None) , 0 , )), (( 'NumberofComponents' , 'pVal' , ), 1610678272, (1610678272, (), [ (2, 1, None, None) , ], 1 , 4 , 4 , 0 , 16 , (3, 0, None, None) , 0 , )), (( 'ComponentName' , 'i' , 'pVal' , ), 1610678274, (1610678274, (), [ (2, 1, None, None) , (16392, 10, None, None) , ], 1 , 2 , 4 , 0 , 20 , (3, 0, None, None) , 0 , )), (( 'ComponentName' , 'i' , 'pVal' , ), 1610678274, (1610678274, (), [ (2, 1, None, None) , (8, 1, None, None) , ], 1 , 4 , 4 , 0 , 24 , (3, 0, None, None) , 0 , )), The calling code is roughly: self.flashmodule = win32com.client.gencache.GetModuleForProgID("PvtsFlash.FlashPhase") mix = win32com.client.Dispatch(self.flashout.Mixture) print mix.NumberofComponents nphases = self.flashout.NumberofPhases print nphases print 'mix',mix i=1 mix._FlagAsMethod("ComponentName") mix.ComponentName(i) When using Pythonwin and its debugger, the ComponentName method pops up using autocompletion, but I can't seem to call it correctly in any way, ideas on how to fix this? I have sample programs doing the same in c++ and VB and it works there. Have tried comtypes but then stumbles on another problem earlier in the program. regards Einar S?rheim From mhammond at skippinet.com.au Tue Jan 9 12:09:42 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 9 Jan 2007 22:09:42 +1100 Subject: [python-win32] win32com: Problem with passing short integer? In-Reply-To: <45A36982.2000304@ife.no> Message-ID: <1c0001c733de$aa27a670$160a0a0a@enfoldsystems.local> > The interface code is generated automatically in the 'gen_py' > folder, > the interface contains only > vtable-entries, I am not sure what this means It almost certainly means that interface does not work with IDispatch - it is vtable only. pywin32 can't call such interfaces yet - I belive comtypes gets closer to that atm. Mark From theller at ctypes.org Tue Jan 9 19:14:15 2007 From: theller at ctypes.org (Thomas Heller) Date: Tue, 09 Jan 2007 19:14:15 +0100 Subject: [python-win32] win32com: Problem with passing short integer? In-Reply-To: <45A36982.2000304@ife.no> References: <45A36982.2000304@ife.no> Message-ID: Einar S?rheim schrieb: > Hi, > I have a set of com dlls that I have a hard time to get working together > with python. [...] > I have sample programs doing the same in c++ and VB and it works there. > Have tried comtypes but then stumbles on another problem > earlier in the program. If it really works in C++ and VB, at least the problem cannot be that the type library does not match the interface. So it could still be a comtypes problem. I guess it is not possible for me to download the COM object you are using somewhere and try for myself? Thomas From rex555 at hotmail.com Tue Jan 9 21:54:04 2007 From: rex555 at hotmail.com (Rex Corrovan) Date: Tue, 09 Jan 2007 12:54:04 -0800 Subject: [python-win32] MemoryError: CreatingSafeArray when trying to use VB COM API Message-ID: I have a VB COM App I am trying to use. I used makepy and it generated the wrapper. Then I go to use: import win32com.client o = win32.client.Dispatch("vbAPI.App") o.myFunct(arg1=("test","test"), arg2=1, arg3=("test2","test2")) The function in the makepy generated wrapper looks like this: def myFunct(self, arg1=defaultNamedNotOptArg, arg2=defaultNamedNotOptArg, arg3=defaultNamedNotOptArg): return self._ApplyTypes_(1610809344, 1, (8, 0), ((24584, 3), (11, 1), (24612, 3)), 'myFunct', None, arg1, arg2, arg3) The output I get is: Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\site-packages\win32com\gen_py\0A54F42C-8CBC-4C09-9F6B-C976C6476689x0x1x1.py", line 43, in myFunct return self._ApplyTypes_(1610809344, 1, (8, 0), ((24584, 3), (11, 1), (24612, 3)), 'myFunct', None, arg1 File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( MemoryError: CreatingSafeArray I am baffled as to what is going on here. Anyone help? Thanks Rex _________________________________________________________________ Get live scores and news about your team: Add the Live.com Football Page www.live.com/?addtemplate=football&icid=T001MSN30A0701 From mhammond at skippinet.com.au Wed Jan 10 04:32:57 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 Jan 2007 14:32:57 +1100 Subject: [python-win32] MemoryError: CreatingSafeArray when trying to use VBCOM API In-Reply-To: Message-ID: <1d7901c73468$05bcc950$160a0a0a@enfoldsystems.local> > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Rex Corrovan > Sent: Wednesday, 10 January 2007 7:54 AM > To: python-win32 at python.org > Subject: [python-win32] MemoryError: CreatingSafeArray when trying to > use VBCOM API > > > I have a VB COM App I am trying to use. > > I used makepy and it generated the wrapper. Then I go to use: > > import win32com.client > o = win32.client.Dispatch("vbAPI.App") > > o.myFunct(arg1=("test","test"), arg2=1, arg3=("test2","test2")) > > > The function in the makepy generated wrapper looks like this: > > def myFunct(self, arg1=defaultNamedNotOptArg, > arg2=defaultNamedNotOptArg, > arg3=defaultNamedNotOptArg): > return self._ApplyTypes_(1610809344, 1, (8, 0), ((24584, > 3), (11, 1), > (24612, 3)), 'myFunct', None, arg1, arg2, arg3) > > > The output I get is: > > Traceback (most recent call last): > File "", line 1, in ? > File > "C:\Python24\lib\site-packages\win32com\gen_py\0A54F42C-8CBC-4 > C09-9F6B-C976C6476689x0x1x1.py", > line 43, in myFunct > return self._ApplyTypes_(1610809344, 1, (8, 0), ((24584, > 3), (11, 1), > (24612, 3)), 'myFunct', None, arg1 > File > "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line > 446, in _ApplyTypes_ > return self._get_good_object_( > MemoryError: CreatingSafeArray This error is raised when the Windows function SafeArrayCreate fails. I'm surprised this is the case - your arrays are very small - but that is the only way this error will be raised. I'm afraid the only advice I can offer is to try and modify the VB test suite to provoke the same error. You will need vb6 and the pywin32 source distro to build the test COM object (in com\TestSources), then use win32com\test\testvb.py to exercise it. That would allow me to reproduce it here. You might also be able to send me the control, and I could at least verify the params we are passing to SafeArrayCreate are sane. Mark From mmorisak at risc.uni-linz.ac.at Wed Jan 10 11:50:36 2007 From: mmorisak at risc.uni-linz.ac.at (Michael Morisak) Date: Wed, 10 Jan 2007 11:50:36 +0100 Subject: [python-win32] win32ui and resources for dialogs In-Reply-To: <459D3493.9050701@risc.uni-linz.ac.at> References: <459D3493.9050701@risc.uni-linz.ac.at> Message-ID: <45A4C4FC.7010206@risc.uni-linz.ac.at> Michael Morisak schrieb: > Hi > > > I have the following Situation: > > I have a dialog resource in an dll and I want to open a modal dialog > with this resource. > > dlg= pywin.mfc.dialog.Dialog(myDialogID) > dlg.DoModal() > > works but the problem is that i would set the Parent of the Dialog > in MFC the CDialog Constructor allows to pass a Parent (which i need): > > explicit CDialog( > UINT /nIDTemplate/, > CWnd* /pParentWnd/ = NULL > ); > > but i really do not know how to do this with python-win32 > > thanx for the help and the great work done in python.win32 > > c.u. > > > > ok i could fix this by opening the dialog in my C++ extension and writing the whole dialog in c++ but now a have a different problem when I did the dialog in c++ i found out that in my case the dialog only works if I add AFX_MANAGE_STATE(AfxGetStaticModuleState()); so i opened the dialog the following way: static PyObject* createConnectOptionsDlg(PyObject *self, PyObject *args) { HWND hwnd; PyObject* settings; CWnd* parent; CDialog* dlg; AFX_MANAGE_STATE(AfxGetStaticModuleState()); if (!PyArg_ParseTuple(args,"iO",&hwnd,&settings)) return NULL; parent= CWnd::FromHandle(hwnd); dlg= new CConnectOptionsDlg(parent,settings); int res= dlg->DoModal(); delete dlg; return Py_BuildValue("i", res); } w0rks fine :) I found out that I need this AFX_MANAGE_STATE(AfxGetStaticModuleState()); because it is a python c++ extension which is used in an ComObject I created in python which is some automation for SolidEdge I read in the article (sorry only in german): http://www.hki.uni-koeln.de/teach/ss06/PS_C++/tag23/21/kap17.htm that if you do mfc stuff in an dll you need to add AFX_MANAGE_STATE(AfxGetStaticModuleState()) to every exported function that uses MFC This information really helped me a lot! After adding this line it started working (SolidEdge did not crash anymore) Now I have a different situation: I need to do the following lines: self.dlg = win32ui.CreateDialog(SolidEdge.PySolidEdge.IDD_LayerStyle) self.dlg.CreateWindow(self.pagewin) self.dlg.ShowWindow(win32con.SW_SHOWNORMAL) self.dlg.HookMessage(self.layerListSelChangeMsgHandler, win32con.WM_COMMAND) the problem is that in principle this works fine but SolidEdge crashes after CreateWindow My suspicion is that i need: AFX_MANAGE_STATE(AfxGetStaticModuleState()) in CreateWindow i tried to add this to the source of python-win32 but i refuses to compile with some link issue Does anybody know what i could do about this problem I do not want to write this whole dlg in c++ since i would have to do a lot of COM in this dialog then thx Michael -- Michael Morisak RISC Software GmbH -- Johannes Kepler Universitaet Linz IT-Center, Hauptstrasse 119 phone: ++43 7236 3343-251 4232 Hagenberg, Austria fax: ++43 7236 3343-250 From niki at vintech.bg Wed Jan 10 11:59:21 2007 From: niki at vintech.bg (Niki Spahiev) Date: Wed, 10 Jan 2007 12:59:21 +0200 Subject: [python-win32] win32ui and resources for dialogs In-Reply-To: <45A4C4FC.7010206@risc.uni-linz.ac.at> References: <459D3493.9050701@risc.uni-linz.ac.at> <45A4C4FC.7010206@risc.uni-linz.ac.at> Message-ID: <45A4C709.9090109@vintech.bg> Michael Morisak wrote: > > Does anybody know what i could do about this problem > I do not want to write this whole dlg in c++ since i would have to do a > lot of COM in this dialog then Do you really need MFC for dialogs? Using MFC for python plug-in is a PITA. We use ctypes for pure win32 dialogs in plug-ins for another CAD system. regards, Niki Spahiev From mhammond at skippinet.com.au Wed Jan 10 13:26:53 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 Jan 2007 23:26:53 +1100 Subject: [python-win32] win32ui and resources for dialogs In-Reply-To: <45A4C4FC.7010206@risc.uni-linz.ac.at> Message-ID: <003e01c734b2$9e663570$160a0a0a@enfoldsystems.local> > i tried to add this to the source of python-win32 > but i refuses to compile with some link issue What issue is that? I'd like for pywin32 to build without too much effort - and at least fail gracefully when it doesn't. As Niki says, avoiding MFC is a good idea. You should also find win32gui complete enough for most dialog work (and Roger has added yet more GDI functions to win32gui since the last release :) Mark From mmorisak at risc.uni-linz.ac.at Wed Jan 10 15:14:36 2007 From: mmorisak at risc.uni-linz.ac.at (Michael Morisak) Date: Wed, 10 Jan 2007 15:14:36 +0100 Subject: [python-win32] win32ui and resources for dialogs In-Reply-To: <003e01c734b2$9e663570$160a0a0a@enfoldsystems.local> References: <003e01c734b2$9e663570$160a0a0a@enfoldsystems.local> Message-ID: <45A4F4CC.6070607@risc.uni-linz.ac.at> Mark Hammond schrieb: >> i tried to add this to the source of python-win32 >> but i refuses to compile with some link issue >> > > What issue is that? I'd like for pywin32 to build without too much effort - > and at least fail gracefully when it doesn't. > > As Niki says, avoiding MFC is a good idea. You should also find win32gui > complete enough for most dialog work (and Roger has added yet more GDI > functions to win32gui since the last release :) > > Mark > > Hi Mark I made the following change: ----------------------- // @pymethod |PyCDialog|CreateWindow|Create a modeless window for the dialog box. static PyObject *ui_dialog_create_window( PyObject *self, PyObject *args ) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); PyObject *obParent = NULL; CWnd *pParent = NULL; // @pyparm |obParent|None|The parent window for the new window if (!PyArg_ParseTuple(args,"|O:CreateWindow", &obParent)) return NULL; . . . . ---------------- after adding AFX_MANAGE_STATE(AfxGetStaticModuleState()); i get the following link-errors: ---- Linking... mfcs71.lib(dllmodul.obj) : error LNK2005: _DllMain at 12 already defined in dllmain.obj mfcs71.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already defined in dllmain.obj mfcs71.lib(dllmodul.obj) : warning LNK4006: _DllMain at 12 already defined in dllmain.obj; second definition ignored mfcs71.lib(dllmodul.obj) : warning LNK4006: __pRawDllMain already defined in dllmain.obj; second definition ignored Creating library .\Build/win32ui.lib and object .\Build/win32ui.exp Build\win32ui.pyd : fatal error LNK1169: one or more multiply defined symbols found Build log was saved at "file://c:\src\pywin\pywin32-210\pythonwin\Build\Temp\win32ui\Release\BuildLog.htm" win32ui - 3 error(s), 2 warning(s) ----- At least M$ says something like (wrong order of linking): http://support.microsoft.com/?scid=kb%3Ben-us%3B148652&x=13&y=18 im already playing around with this linker issue for some hours but no solution yet. Anyway I wonder why AFX_MANAGE_STATE(AfxGetStaticModuleState()); is not included in win32ui on every functioncall dealing with the mfc since it always could happen that somebody would like to open a dlg as a COM-Component :) further inf on AFX_MANAGE_STATE(AfxGetStaticModuleState()) can be found at: http://support.microsoft.com/?scid=kb%3Ben-us%3B140850&x=11&y=9 thx for answering Michael -- Michael Morisak RISC Software GmbH -- Johannes Kepler Universitaet Linz IT-Center, Hauptstrasse 119 phone: ++43 7236 3343-251 4232 Hagenberg, Austria fax: ++43 7236 3343-250 From gustavotabares at gmail.com Wed Jan 10 21:25:52 2007 From: gustavotabares at gmail.com (Gustavo Tabares) Date: Wed, 10 Jan 2007 15:25:52 -0500 Subject: [python-win32] GetVolumeInformation throwing exception Message-ID: <1871c95a0701101225r38283d5dr124a1f1162919802@mail.gmail.com> Hi all, I'm having a problem with the code below and I'm not sure if there is a bug in win32api.GetVolumeInformation. There is a simple workaround, but I'm curious nonetheless. Any help is appreciated. I'm using Python 2.5 final with pywin32-210. # F: is a mapped network drive of a Windows XP share import os import win32api win32api.GetVolumeInformation('F:') os.chdir('F:\\somedir') print os.getcwd() # to verify win32api.GetVolumeInformation('F:') ######################################### Here is the exception thrown on the last line: error: (123, 'GetVolumeInformation', 'The filename, directory name, or volume label syntax is incorrect.') The simple workaround is to add os.sep to the F: string in the last call to GetVolumeInformation; it runs properly. This also still breaks if you chdir back to the local C: drive. Thanks, Gustavo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070110/7e535763/attachment.html From timr at probo.com Wed Jan 10 21:44:26 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Jan 2007 12:44:26 -0800 Subject: [python-win32] GetVolumeInformation throwing exception In-Reply-To: <1871c95a0701101225r38283d5dr124a1f1162919802@mail.gmail.com> References: <1871c95a0701101225r38283d5dr124a1f1162919802@mail.gmail.com> Message-ID: <45A5502A.6000404@probo.com> Gustavo Tabares wrote: > > I'm having a problem with the code below and I'm not sure if there is > a bug in win32api.GetVolumeInformation. There is a simple workaround, > but I'm curious nonetheless. Any help is appreciated. > ... > The simple workaround is to add os.sep to the F: string in the last > call to GetVolumeInformation; it runs properly. This also still breaks > if you chdir back to the local C: drive. It's not a bug. When in doubt, always refer to the documentation. From http://msdn2.microsoft.com/en-us/library/aa364993.aspx: / lpRootPathName/ [in] A pointer to a string that contains the root directory of the volume to be described. If this parameter is NULL, the root of the current directory is used. A trailing backslash is required. For example, you specify \\MyServer\MyShare as \\MyServer\MyShare\, or the C drive as "C:\". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gustavotabares at gmail.com Wed Jan 10 21:57:17 2007 From: gustavotabares at gmail.com (Gustavo Tabares) Date: Wed, 10 Jan 2007 15:57:17 -0500 Subject: [python-win32] GetVolumeInformation throwing exception In-Reply-To: <45A5502A.6000404@probo.com> References: <1871c95a0701101225r38283d5dr124a1f1162919802@mail.gmail.com> <45A5502A.6000404@probo.com> Message-ID: <1871c95a0701101257m5662fc72qf1c61aa7d76a96a0@mail.gmail.com> Hrm ok, so this: win32api.GetVolumeInformation('F:') only works if your current working directory isn't somewhere on that drive (as in my example code)? The rest of the time you need to specify an additional slash or to be safe always include the os separator. Thanks, Gus On 1/10/07, Tim Roberts wrote: > > Gustavo Tabares wrote: > > > > I'm having a problem with the code below and I'm not sure if there is > > a bug in win32api.GetVolumeInformation. There is a simple workaround, > > but I'm curious nonetheless. Any help is appreciated. > > ... > > The simple workaround is to add os.sep to the F: string in the last > > call to GetVolumeInformation; it runs properly. This also still breaks > > if you chdir back to the local C: drive. > > It's not a bug. When in doubt, always refer to the documentation. From > http://msdn2.microsoft.com/en-us/library/aa364993.aspx: > > / lpRootPathName/ > [in] A pointer to a string that contains the root directory of the > volume to be described. > > If this parameter is NULL, the root of the current directory is > used. A trailing backslash is required. For example, you specify > \\MyServer\MyShare as \\MyServer\MyShare\, or the C drive as "C:\". > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070110/dc1fd3eb/attachment.html From timr at probo.com Wed Jan 10 22:09:22 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 10 Jan 2007 13:09:22 -0800 Subject: [python-win32] GetVolumeInformation throwing exception In-Reply-To: <1871c95a0701101257m5662fc72qf1c61aa7d76a96a0@mail.gmail.com> References: <1871c95a0701101225r38283d5dr124a1f1162919802@mail.gmail.com> <45A5502A.6000404@probo.com> <1871c95a0701101257m5662fc72qf1c61aa7d76a96a0@mail.gmail.com> Message-ID: <45A55602.5000702@probo.com> Gustavo Tabares wrote: > Hrm ok, so this: > > win32api.GetVolumeInformation('F:') > > only works if your current working directory isn't somewhere on that > drive (as in my example code)? The rest of the time you need to > specify an additional slash or to be safe always include the os > separator. Beats me. You're asking about undocumented behavior. The fact that it works at all is merely an accident, and might change in the next service pack. The documentation says "a trailing backslash is *required*". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Wed Jan 10 23:45:44 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 11 Jan 2007 09:45:44 +1100 Subject: [python-win32] win32ui and resources for dialogs In-Reply-To: <45A4F4CC.6070607@risc.uni-linz.ac.at> Message-ID: <01e401c73509$108f19e0$160a0a0a@enfoldsystems.local> > Hi Mark > > I made the following change: > > > ----------------------- > // @pymethod |PyCDialog|CreateWindow|Create a modeless window for the > dialog box. > static PyObject *ui_dialog_create_window( PyObject *self, > PyObject *args ) > { > AFX_MANAGE_STATE(AfxGetStaticModuleState()); > > PyObject *obParent = NULL; > CWnd *pParent = NULL; > > > // @pyparm |obParent|None|The parent window for > the new window > if (!PyArg_ParseTuple(args,"|O:CreateWindow", &obParent)) > return NULL; > . > . > . > . > ---------------- > > after adding AFX_MANAGE_STATE(AfxGetStaticModuleState()); > i get the following link-errors: > > ---- > Linking... > mfcs71.lib(dllmodul.obj) : error LNK2005: _DllMain at 12 already > defined in > dllmain.obj That macro is attempting to pull in the static version of MFC, which is causing the failure. We link to the DLL version of MFC. Although they are a bit vague, things I read on the web imply pythonwin does *not* need this, as it is a full blown MFC DLL (ie, an 'extension DLL'). Either way, the fact AFX_MANAGE_STATE tries to drag in the MFC static library seems a deal-breaker. I'm afraid I'm out of time to dig much more into this. Cheers, Mark From rex555 at hotmail.com Thu Jan 11 01:40:04 2007 From: rex555 at hotmail.com (Rex Corrovan) Date: Wed, 10 Jan 2007 16:40:04 -0800 Subject: [python-win32] MemoryError: CreatingSafeArray when trying to use VBCOM API In-Reply-To: <1d7901c73468$05bcc950$160a0a0a@enfoldsystems.local> Message-ID: I figured out when this happens. It happens when you try to pass an array into an arg that requires a Record. I am really confused as to how this all works, but will start trying to find some info on what is going on. Form what I can see, the code in the makepy generated file is trying to take python datatypes and map them into the required. So I need to figure out how to use a Record then. if I do: s = win32com.client.Record("myStruct", o) s.myString = "test" s.myInt = 12 o.myFunct(arg1=("test","test"), arg2=1, arg3=s) it then complains: TypeError: Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object. Meh thanks though Rex From: "Mark Hammond" To: "'Rex Corrovan'" , Subject: RE: [python-win32] MemoryError: CreatingSafeArray when trying to use VBCOM API Date: Wed, 10 Jan 2007 14:32:57 +1100 > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Rex Corrovan > Sent: Wednesday, 10 January 2007 7:54 AM > To: python-win32 at python.org > Subject: [python-win32] MemoryError: CreatingSafeArray when trying to > use VBCOM API > > > I have a VB COM App I am trying to use. > > I used makepy and it generated the wrapper. Then I go to use: > > import win32com.client > o = win32.client.Dispatch("vbAPI.App") > > o.myFunct(arg1=("test","test"), arg2=1, arg3=("test2","test2")) > > > The function in the makepy generated wrapper looks like this: > > def myFunct(self, arg1=defaultNamedNotOptArg, > arg2=defaultNamedNotOptArg, > arg3=defaultNamedNotOptArg): > return self._ApplyTypes_(1610809344, 1, (8, 0), ((24584, > 3), (11, 1), > (24612, 3)), 'myFunct', None, arg1, arg2, arg3) > > > The output I get is: > > Traceback (most recent call last): > File "", line 1, in ? > File > "C:\Python24\lib\site-packages\win32com\gen_py\0A54F42C-8CBC-4 > C09-9F6B-C976C6476689x0x1x1.py", > line 43, in myFunct > return self._ApplyTypes_(1610809344, 1, (8, 0), ((24584, > 3), (11, 1), > (24612, 3)), 'myFunct', None, arg1 > File > "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line > 446, in _ApplyTypes_ > return self._get_good_object_( > MemoryError: CreatingSafeArray This error is raised when the Windows function SafeArrayCreate fails. I'm surprised this is the case - your arrays are very small - but that is the only way this error will be raised. I'm afraid the only advice I can offer is to try and modify the VB test suite to provoke the same error. You will need vb6 and the pywin32 source distro to build the test COM object (in com\TestSources), then use win32com\test\testvb.py to exercise it. That would allow me to reproduce it here. You might also be able to send me the control, and I could at least verify the params we are passing to SafeArrayCreate are sane. Mark _________________________________________________________________ >From photos to predictions, The MSN Entertainment Guide to Golden Globes has it all. http://tv.msn.com/tv/globes2007/?icid=nctagline1 From mhammond at skippinet.com.au Thu Jan 11 02:23:44 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 11 Jan 2007 12:23:44 +1100 Subject: [python-win32] MemoryError: CreatingSafeArray when trying touse VBCOM API In-Reply-To: Message-ID: <023901c7351f$23ae9210$160a0a0a@enfoldsystems.local> > if I do: > s = win32com.client.Record("myStruct", o) > s.myString = "test" > s.myInt = 12 > > o.myFunct(arg1=("test","test"), arg2=1, arg3=s) > > it then complains: > TypeError: Objects for SAFEARRAYS must be sequences (of > sequences), or a > buffer object. In your original mail, you indicated the makepy generated code for the args: > ((24584, 3), (11, 1), (24612, 3)) Arg1 is an array of strings (as you are passing). Arg2 is a bool (an int will work fine, as you have done). Arg3, 24612==pythoncom.VT_RECORD | pythoncom.VT_ARRAY | pythoncom.VT_BYREF - so arg3 wants an array of these records. Hope this helps, Mark From howard at eegsoftware.com Thu Jan 11 20:33:24 2007 From: howard at eegsoftware.com (Howard Lightstone) Date: Thu, 11 Jan 2007 11:33:24 -0800 Subject: [python-win32] building tkinter under VC8 Message-ID: <45A62084.23924.EF90183@howard.eegsoftware.com> I am having trouble rebuilding tkinter for 2.5 under Microsft VC8. The current issue is that TIX won't build under VC8. Has anyone solved this issue yet? The TCL and TK versions 8.4.14 have already been updated to build with VC8 but not TIX. So I was able to build them following the same method as described for building with 8.4.12. I need to rebuild all this since I use an embedded python interpreter - and the configuration rules make me build everything from scratch.... Thanks From zqc53 at 126.com Sat Jan 13 20:29:30 2007 From: zqc53 at 126.com (Chris) Date: Sat, 13 Jan 2007 19:29:30 -0000 Subject: [python-win32] subtree problem with ReadDirectoryChangesW Message-ID: <200712141324266291810@126.com> Hi! I got a problem with win32file.ReadDirectoryChangesW(),that is how to watch a root dir with subdirs? Here is my code: [START] import win32api,win32file,time,threading from win32con import * class worker(threading.Thread): pass def watch_dir_1(): dirName = "d:\\" hdir = win32file.CreateFile( dirName, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, pywintypes.SECURITY_ATTRIBUTES(), OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ) print hdir while(1): time.sleep(.5) print win32file.ReadDirectoryChangesW( hdir, 50, 100, FILE_NOTIFY_CHANGE_LAST_WRITE, None, None ) def watch_dir(): watch_worker = worker() watch_worker.run = watch_dir_1 watch_worker.start() watch_dir() time.sleep(500) [END] The result is that the api works good only if the changes in in top-level and second-level, else I got a () only. I search for msdn and found that there is a parameter 'BOOL bWatchSubtree' in the original api, where is it in pywin32? What can I do now ? Maybe only I can do is to create a watcher thread for each directory in d:\\ Thanks for your help. Chris 2007-12-14 From wenstonezhong at gmail.com Sun Jan 14 10:08:46 2007 From: wenstonezhong at gmail.com (=?GB2312?B?zsTB+g==?=) Date: Sun, 14 Jan 2007 17:08:46 +0800 Subject: [python-win32] MS Agent Event Handling via Python Message-ID: Hi, After searched a lot on web, not quit sure anybody met similar problem before. When I try to track the event fired by MS Agent by using 'DispatchWithEvents', I thought may be this is because IAgentNotifySink did not registered by server. I'm quite new to Python Com, it wrapped well, I wonder is there any convient way to get IAgentNofiySink registered by Server? Any clue and hint are appreciated! ----------------------------------------------------------------- def TestMSAgent(): class AgentEvents: def OnHide(self, CharacterID=defaultNamedNotOptArg, Cause=defaultNamedNotOptArg): print "Hiding" def OnClick(self, CharacterID=defaultNamedNotOptArg, Button=defaultNamedNotOptArg, Shift=defaultNamedNotOptArg, x=defaultNamedNotOptArg, y=defaultNamedNotOptArg): print "Clicked" ag = DispatchWithEvents("Agent.Control", AgentEvents) ag.Characters.Load("robby",r"C:\WINDOWS\msagent\chars\robby.acs") robby = ag.Characters("robby") robby = WithEvents(robby, AgentEvents) robby.Show() while 1: time.sleep(0.2) ------------------------------------------------------------------ no any print after any clicking and hiding. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070114/86c88702/attachment.htm From mhammond at skippinet.com.au Sun Jan 14 10:48:34 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 14 Jan 2007 20:48:34 +1100 Subject: [python-win32] MS Agent Event Handling via Python In-Reply-To: Message-ID: <08f401c737c1$28dff450$160a0a0a@enfoldsystems.local> Try changing your idle loop from: while 1: time.sleep(0.2) to: while 1: pythoncom.PumpWaitingMessages() time.sleep(0.2) (possibly importing pythoncom first). Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of ???? Sent: Sunday, 14 January 2007 8:09 PM To: python-win32 at python.org Subject: [python-win32] MS Agent Event Handling via Python Hi, After searched a lot on web, not quit sure anybody met similar problem before. When I try to track the event fired by MS Agent by using 'DispatchWithEvents', I thought may be this is because IAgentNotifySink did not registered by server. I'm quite new to Python Com, it wrapped well, I wonder is there any convient way to get IAgentNofiySink registered by Server? Any clue and hint are appreciated! ----------------------------------------------------------------- def TestMSAgent(): class AgentEvents: def OnHide(self, CharacterID=defaultNamedNotOptArg, Cause=defaultNamedNotOptArg): print "Hiding" def OnClick(self, CharacterID=defaultNamedNotOptArg, Button=defaultNamedNotOptArg, Shift=defaultNamedNotOptArg, x=defaultNamedNotOptArg, y=defaultNamedNotOptArg): print "Clicked" ag = DispatchWithEvents("Agent.Control", AgentEvents) ag.Characters.Load("robby",r"C:\WINDOWS\msagent\chars\robby.acs") robby = ag.Characters("robby") robby = WithEvents(robby, AgentEvents) robby.Show() while 1: time.sleep(0.2) ------------------------------------------------------------------ no any print after any clicking and hiding. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070114/f112c3dd/attachment.html From mhammond at skippinet.com.au Sun Jan 14 10:55:55 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 14 Jan 2007 20:55:55 +1100 Subject: [python-win32] subtree problem with ReadDirectoryChangesW In-Reply-To: <200712141324266291810@126.com> Message-ID: <08fd01c737c2$2f786170$160a0a0a@enfoldsystems.local> Check out win32\test\test_win32file - it has a test for that function, including some comments about using it with threads. The short version is that you don't sleep - just call ReadDirectoryChangesW - it will return when a change happens. > The result is that the api works good only if the changes in > in top-level and second-level, else I got a () only. > > I search for msdn and found that there is a parameter 'BOOL > bWatchSubtree' in the original api, where is it in pywin32? Check out the help file installed with pywin32 - it documents that as the 3rd param. > What can I do now ? Maybe only I can do is to create a > watcher thread for each directory in d:\\ I've successfully used this function to watch a sub-tree in the past, although not from the root. I'd expect that to be expensive! Mark From rwupole at msn.com Sun Jan 14 11:42:35 2007 From: rwupole at msn.com (Roger Upole) Date: Sun, 14 Jan 2007 05:42:35 -0500 Subject: [python-win32] Re: subtree problem with ReadDirectoryChangesW Message-ID: Also, try using a larger buffer size. The function returns successfully if the buffer is too small without placing any results in the buffer. At several dir levels down, you're probably exceeding the 50 byte size specified. Roger From mail at timgolden.me.uk Mon Jan 15 09:44:43 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 15 Jan 2007 08:44:43 +0000 (UTC) Subject: [python-win32] subtree problem with ReadDirectoryChangesW References: Message-ID: Roger Upole msn.com> writes: > > Also, try using a larger buffer size. The function returns successfully > if the buffer is too small without placing any results in the buffer. > At several dir levels down, you're probably exceeding the 50 byte > size specified. I've posted a working example here: http://tinyurl.com/ym26qr which also passes on (from another user) Roger's warning about buffer size. TJG From rdm at rcblue.com Mon Jan 15 10:59:04 2007 From: rdm at rcblue.com (Dick Moores) Date: Mon, 15 Jan 2007 01:59:04 -0800 Subject: [python-win32] How to restart the shell? Message-ID: <7.0.1.0.2.20070115015634.07a60b88@rcblue.com> I'm just trying out PythonWin 2.5, and can't figure out how to restart, or refresh the shell. Is there a way? Thanks, Dick Moores From mhammond at skippinet.com.au Mon Jan 15 11:21:28 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 15 Jan 2007 21:21:28 +1100 Subject: [python-win32] How to restart the shell? In-Reply-To: <7.0.1.0.2.20070115015634.07a60b88@rcblue.com> Message-ID: <0a8701c7388e$eb910610$160a0a0a@enfoldsystems.local> > I'm just trying out PythonWin 2.5, and can't figure out how to > restart, or refresh the shell. Is there a way? It depends on what you mean exactly by "refresh". The SHChangeNotify function can often be used to tell the shell about a change and its views will refresh accordingly. What exactly are you trying to do? Mark From rdm at rcblue.com Mon Jan 15 22:52:53 2007 From: rdm at rcblue.com (Dick Moores) Date: Mon, 15 Jan 2007 13:52:53 -0800 Subject: [python-win32] How to restart the shell? In-Reply-To: <0b8901c738ed$f37675e0$160a0a0a@enfoldsystems.local> References: <7.0.1.0.2.20070115031509.066341a0@rcblue.com> <0b8901c738ed$f37675e0$160a0a0a@enfoldsystems.local> Message-ID: <7.0.1.0.2.20070115135007.06f526a0@rcblue.com> At 01:41 PM 1/15/2007, you wrote: > > At 02:21 AM 1/15/2007, you wrote: > > > > I'm just trying out PythonWin 2.5, and can't figure out how to > > > > restart, or refresh the shell. Is there a way? > > > > > >It depends on what you mean exactly by "refresh". The SHChangeNotify > > >function can often be used to tell the shell about a change > > and its views > > >will refresh accordingly. What exactly are you trying to do? > > > > I want to do what you can do in IDLE with Ctrl+F6. This wipes out any > > variables or imports, so that when testing code you can know that > > nothing is going to interfere. Here's what happens with IDLE: > >Right - I completely misunderstood :) Sadly that feature does not exist in >pythonwin. Thanks. Dick From mhammond at skippinet.com.au Fri Jan 19 01:28:14 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 19 Jan 2007 11:28:14 +1100 Subject: [python-win32] [pywin32-bugs] Build problem with VC++ 2005 In-Reply-To: <29bf24a80701171615r4e15be9anf6a4f67e6453f2d3@mail.gmail.com> Message-ID: <06b301c73b60$b5a8db70$180a0a0a@enfoldsystems.local> The pywin32-bugs at lists.sourceforge.net mailing list is only for automated mails from the sourceforge bug tracker. The best list for this stuff is python-win32 at python.org. Please drop pywin32-bugs from any followups.. Note that in general, you *must* use the same compiler for extensions that you use for Python itself. However, without *any* details about the error I can't even start to guess what the problem might be. As pywin32 builds using distutils, I expect that any problems you have are not specific to pywin32 but will be common to all extensions you try and build - but that should become clearer once we get a clue as to what is going wrong. Cheers, Mark -----Original Message----- From: pywin32-bugs-bounces at lists.sourceforge.net [mailto:pywin32-bugs-bounces at lists.sourceforge.net]On Behalf Of Howard Lightstone Sent: Thursday, 18 January 2007 11:15 AM To: pywin32-bugs at lists.sourceforge.net Subject: [pywin32-bugs] Build problem with VC++ 2005 I am unable to build 210 (with distutils) using VC++ 2005. Unfortunately, I HAVE to use this compiler and rebuild everything (since VC 7 is no longer distributed) going forward. Is this just an issue with the setup.py script? Is it possible to just "manually" (shudder) make up a project file for pywin32 and build that way? -- Howard Lightstone hlightstone at gmail.com From howard at eegsoftware.com Fri Jan 19 02:04:09 2007 From: howard at eegsoftware.com (Howard Lightstone) Date: Thu, 18 Jan 2007 17:04:09 -0800 Subject: [python-win32] Building with VC8 Message-ID: <45AFA889.13962.10B01ADF@howard.eegsoftware.com> I tried building with Visual Studio 2005 (which uses the VC8 compiler line) and distutils reports that it cannot find a compiler. Where should I go to find a solution for this? Is this better posted to the distutils list (although this is just a Windows issue)? From timr at probo.com Fri Jan 19 02:22:39 2007 From: timr at probo.com (Tim Roberts) Date: Thu, 18 Jan 2007 17:22:39 -0800 Subject: [python-win32] Build problem with VC++ 2005 In-Reply-To: <06b301c73b60$b5a8db70$180a0a0a@enfoldsystems.local> References: <06b301c73b60$b5a8db70$180a0a0a@enfoldsystems.local> Message-ID: <45B01D5F.20803@probo.com> Howard Lightstone wrote: > I am unable to build 210 (with distutils) using VC++ 2005. > > Unfortunately, I HAVE to use this compiler and rebuild > everything (since VC 7 is no longer distributed) going forward. > VC 7 is no longer being SOLD, but you can certainly download it if you have an MSDN subscription. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Fri Jan 19 03:34:25 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 19 Jan 2007 13:34:25 +1100 Subject: [python-win32] Building with VC8 In-Reply-To: <45AFA889.13962.10B01ADF@howard.eegsoftware.com> Message-ID: <000a01c73b72$55a621d0$0200a8c0@enfoldsystems.local> > I tried building with Visual Studio 2005 (which uses the VC8 > compiler line) > and distutils reports that it cannot find a compiler. Right. It looks like distutils still just supports only the version used to build Python itself - and no official Python releases use vc8. > Where should I go to find a solution for this? Is this > better posted to the > distutils list (although this is just a Windows issue)? Yeah, I think distutils is the best. I believe there is already some support for building extensions with cygwin, so allowing a different MSVC compiler to be specified would follow that pattern. The distutils folk would have the best insights into how to best approach this. FWIW, some of the pywin32 modules do still have msvc6 project files checked in and up-to-date - if you only need to build a subset that might work for you. Cheers, Mark From evadream at gmail.com Sun Jan 21 01:35:36 2007 From: evadream at gmail.com (jbd) Date: Sun, 21 Jan 2007 00:35:36 +0000 (UTC) Subject: [python-win32] PyWin32 - PostMessage return value Message-ID: Hello everybody ! I'm used to work under Linux/Unix environnement, but i've to deal with the windows API which i didn't know anything about a few hours ago. I think that my questions are pywin32 related even if it seems purely a problem with the win32 api. I hope it's not a problem. Here is my story. I create a process via the CreateProcess function, and i wait using WaitForInputIdle to be sure that the process is in ready state, it works well (ie: the process is launched). I send a message via PostMessage and i'd like to know if the command had been correctly processed, and i don't know how to do it. But, although the application is in ready state, some hardware initialization has to be done and seems not to be accomplished when WaitForInputIdle returns. The message i posted using PostMessage is correctly processed, but nothing appends since the ressource i need were not yet initialized. If i introduce a time.sleep(2) between the WaitForInputIdle and the PostMessage function, everything is working fine. On the msdn site, the PostMessage function returns a BOOL, but since this is an asynchrone function, the return value just means that the message has been posted without problem. Am i correct ? By the way, how do i check for this return value with pywin32 ? All message related function seems to return None. Hope my explanation is clear. Thanks you for any insights ! From gagsl-p32 at yahoo.com.ar Sun Jan 21 03:34:56 2007 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 20 Jan 2007 23:34:56 -0300 Subject: [python-win32] PyWin32 - PostMessage return value In-Reply-To: References: Message-ID: <7.0.1.0.0.20070120231148.03e47cf8@yahoo.com.ar> At Saturday 20/1/2007 21:35, jbd wrote: >I create a process via the CreateProcess function, and i wait using >WaitForInputIdle to be sure that the process is in ready state, it works >well (ie: the process is launched). Check also whether WaitForInputIdle returns 0, and not WAIT_TIMEOUT (meaning that the process is not ready yet) >I send a message via PostMessage and >i'd like to know if the command had been correctly processed, and i don't >know how to do it. > >But, although the application is in ready state, some hardware >initialization has to be done and seems not to be accomplished when >WaitForInputIdle returns. The message i posted using PostMessage is >correctly processed, but nothing appends since the ressource i need were >not yet initialized. If i introduce a time.sleep(2) between the >WaitForInputIdle and the PostMessage function, everything is working fine. And the sleep isn't an acceptable solution, I presume. You can use some form of interprocess communication; coming from a Unix environment you may know some of them, like pipes, queues. Or a synchornization mechanism like a semaphore. But since you're already using messages, maybe the easiest way is making the target application broadcast a message telling "I'm ready now", and when the caller sees it, it knows it can post the message. Use RegisterWindowMessage on both applications, with the same name, to obtain a unique message identifier. Use HWND_BROADCAST as the first argument to PostMessage to broadcast it to all top level windows. >On the msdn site, the PostMessage function returns a BOOL, but since this >is an asynchrone function, the return value just means that the message >has been posted without problem. Am i correct ? By the way, how do i check >for this return value with pywin32 ? All message related function seems to >return None. Yes, it appears that you cannot retrieve the return value of PostMessage. Anyway it won't tell you much. The caller can communicate its own window handle to the target application, using the wParam or lParam arguments when it sends some message. This way, the target application can reply to the caller when he has completed processing the operation (either ok or with an error). -- Gabriel Genellina Softlab SRL __________________________________________________ Pregunt?. Respond?. Descubr?. Todo lo que quer?as saber, y lo que ni imaginabas, est? en Yahoo! Respuestas (Beta). ?Probalo ya! http://www.yahoo.com.ar/respuestas From rschroev_nospam_ml at fastmail.fm Sun Jan 21 11:15:32 2007 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Sun, 21 Jan 2007 11:15:32 +0100 Subject: [python-win32] PyWin32 - PostMessage return value In-Reply-To: References: Message-ID: jbd schreef: > I create a process via the CreateProcess function, and i wait using > WaitForInputIdle to be sure that the process is in ready state, it works > well (ie: the process is launched). I send a message via PostMessage and > i'd like to know if the command had been correctly processed, and i don't > know how to do it. I think you should use SendMessage or SendMessageTimeout instead of PostMessage. SendMessage blocks until the message has been processed, and it returns an LRESULT which is the return value of the window procedure that processed the message (I think). That could be used to determine success or failure. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven From evadream at gmail.com Sun Jan 21 11:56:01 2007 From: evadream at gmail.com (jbd) Date: Sun, 21 Jan 2007 10:56:01 +0000 (UTC) Subject: [python-win32] PyWin32 - PostMessage return value References: <7.0.1.0.0.20070120231148.03e47cf8@yahoo.com.ar> Message-ID: > At Saturday 20/1/2007 21:35, jbd wrote: > Check also whether WaitForInputIdle returns 0, and not WAIT_TIMEOUT > (meaning that the process is not ready yet) That's why i'm doing. Moreover, i'm using INFINITE as a timeout. ret = win32event.WaitForInputIdle(handle, win32event.INFINITE) if ret != 0: raise SystemExit("Problem during process wait") > But since you're already using messages, maybe the easiest way is > making the target application broadcast a message telling "I'm ready > now", and when the caller sees it, it knows it can post the message. > Use RegisterWindowMessage on both applications, with the same name, > to obtain a unique message identifier. > Use HWND_BROADCAST as the first argument to PostMessage to broadcast > it to all top level windows. Ok. Thanks for the tip. The fact is really don't know when the target application is really ready. I'll have to spy it on Monday =) Is there way to detect that a entry in a menu is not activated ? > Yes, it appears that you cannot retrieve the return value of > PostMessage. Anyway it won't tell you much. The caller can communicate > its own window handle to the target application, using the wParam or > lParam arguments when it sends some message. This way, the target > application can reply to the caller when he has completed processing the > operation (either ok or with an error). Ok, i'm gonna look into it ! Thanks a lot for having taking time to respond. From gagsl-p32 at yahoo.com.ar Mon Jan 22 20:16:23 2007 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 22 Jan 2007 16:16:23 -0300 Subject: [python-win32] PyWin32 - PostMessage return value In-Reply-To: References: <7.0.1.0.0.20070120231148.03e47cf8@yahoo.com.ar> Message-ID: <7.0.1.0.0.20070122161114.05937e28@yahoo.com.ar> At Sunday 21/1/2007 07:56, jbd wrote: > > But since you're already using messages, maybe the easiest way is > > making the target application broadcast a message telling "I'm ready > > now", and when the caller sees it, it knows it can post the message. > > Use RegisterWindowMessage on both applications, with the same name, > > to obtain a unique message identifier. > > Use HWND_BROADCAST as the first argument to PostMessage to broadcast > > it to all top level windows. > >Ok. Thanks for the tip. The fact is really don't know when the target >application is really ready. I'll have to spy it on Monday =) >Is there way to detect that a entry in a menu is not activated ? Ouch, does that mean that you are not in control of the target application? If not, most of these suggestions are not very useful since they require to modify the app. To detect if a menu is enabled or not, you could use GetMenuState, but I'm not sure if that helps you at all... -- Gabriel Genellina Softlab SRL __________________________________________________ Pregunt?. Respond?. Descubr?. Todo lo que quer?as saber, y lo que ni imaginabas, est? en Yahoo! Respuestas (Beta). ?Probalo ya! http://www.yahoo.com.ar/respuestas From bborcic at gmail.com Tue Jan 23 16:25:11 2007 From: bborcic at gmail.com (Boris Borcic) Date: Tue, 23 Jan 2007 16:25:11 +0100 Subject: [python-win32] windows text rendering question Message-ID: Hello, I am trying to use UI Automation to drive an MS Windows app with pywinauto. I need to scrape the app's window contents and use some form of OCR to get at the texts (pywinauto can't get at them). As an alternative to integrating an OCR engine, and since I know the fonts and sizes used to write on the app's windows, I reasoned that I could base a simple text recognition module on the capability to drive MSWindows text rendering - eg to generate pixmaps of texts I expect to find in the driven app's windows, exact to the pixel. The advantage of that approach would be exactitude and self-containment. I've verified manually inside an Idle window, that indeed I could produce pixmaps of expected app texts, exact to the pixel (with Tkinter+screen capture at least). I could use help to turn this into a programmable capability, ie : does anyone here know of a simple - with Tkinter or otherwise - way to wrap access to the MS Windows UI text rendering engine, as a function that would return a picture of rendered text, given a string, a font, a size and colors ? And ideally, without interfering with screen contents ? Thanks in advance for any guidance, Boris Borcic From timr at probo.com Tue Jan 23 18:58:28 2007 From: timr at probo.com (Tim Roberts) Date: Tue, 23 Jan 2007 09:58:28 -0800 Subject: [python-win32] windows text rendering question In-Reply-To: References: Message-ID: <45B64CC4.6010608@probo.com> Boris Borcic wrote: > I am trying to use UI Automation to drive an MS Windows app with pywinauto. > > I need to scrape the app's window contents and use some form of OCR to get at > the texts (pywinauto can't get at them). > > As an alternative to integrating an OCR engine, and since I know the fonts and > sizes used to write on the app's windows, I reasoned that I could base a simple > text recognition module on the capability to drive MSWindows text rendering - eg > to generate pixmaps of texts I expect to find in the driven app's windows, exact > to the pixel. > > The advantage of that approach would be exactitude and self-containment. > But what if the user has font anti-aliasing or, even worse, ClearType turned on? Your screen image won't be pixel-for-pixel accurate. This seems like a very delicate solution to me. I'm surprised you can't get at the window contents. Have you used the spyxx.exe utility to poke through the window structure? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mark.m.mcmahon at gmail.com Tue Jan 23 20:18:35 2007 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Tue, 23 Jan 2007 14:18:35 -0500 Subject: [python-win32] windows text rendering question In-Reply-To: <45B64CC4.6010608@probo.com> References: <45B64CC4.6010608@probo.com> Message-ID: <71b6302c0701231118h6618b0abi60521928a85af65d@mail.gmail.com> Hi, On 1/23/07, Tim Roberts wrote: > > I'm surprised you can't get at the window contents. Have you used the > spyxx.exe utility to poke through the window structure? > Unfortunately there are quite a few controls in software that are either owner drawn or are custom and do not respond to WM_GETTTEXT or other similar messages. One (extreme?) way is to hook the DrawText/TextOut? functions and force a refresh of your window - then if there is text it should go through those methods (I am simplifying because I don't have all the details on this method - if anybody has working code (ctypes even?) I would be interested to see it. > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > Mark Mc Mahon From howard at eegsoftware.com Tue Jan 23 20:52:58 2007 From: howard at eegsoftware.com (Howard Lightstone) Date: Tue, 23 Jan 2007 11:52:58 -0800 Subject: [python-win32] rebuilding 210 with VC8 woes Message-ID: <45B5F71A.3901.14D7808C@howard.eegsoftware.com> While trying to rebuild pywin32 using VC8 (after a couple of distutils patches...), I have reached my C++ limit. I got all the way to building pythonwin and ... I am getting an error as follows: d:\python25\pywin32-210\pythonwin\win32uiExt.h(393) : error C2653: 'ThisClass' : is not a class or namespace name d:\python25\pywin32-210\pythonwin\win32uiExt.h(392) : while compiling class template static data member 'const AFX_MSGMAP_ENTRY CPythonWndFramework _messageEntries[]' with [ T=CFrameWnd ] d:\python25\pywin32-210\pythonwin\win32uiExt.h(387) : while compiling class template static data member 'const AFX_MSGMAP CPythonWndFramework::mess eMap' with [ T=CFrameWnd ] d:\python25\pywin32-210\pythonwin\pythonframe.h(9) : see reference to class template instantiation 'CPythonWndFramework' being compiled with [ T=CFrameWnd ] d:\python25\pywin32-210\pythonwin\win32uiExt.h(394) : error C2653: 'ThisClass' : is not a class or namespace name ???? I am not sure what this means..... I *assume* it must be some difference with using VC8 (part of Visual Studio 8) as the compiler. I will submit changes for the minor errors/issues I had to fix to get to this point but they were all scope or explicit cast issues. I am stumped here. Any help would be appreciated. From jonathan-lists at cleverdevil.org Tue Jan 23 23:33:25 2007 From: jonathan-lists at cleverdevil.org (Jonathan LaCour) Date: Tue, 23 Jan 2007 17:33:25 -0500 Subject: [python-win32] wrapping objects from a COM server Message-ID: <173C7FD1-F9DD-49A3-976E-49196B52963F@cleverdevil.org> I am writing my first COM Server using the wonderful win32 extensions, and am running into a bit of an annoyance. My COM Server is using a dynamic policy by implementing `_dynamic_` to act as a proxy to some Python modules, very similarly to the Python String wrapper described in the Python Programming on Win32 book in Chapter 12. However, my proxied modules tend to return more than basic Python types. They can also return Python objects. I have made it so that all of the Python objects that are returned will always have the `_public_attrs_` and `_public_methods_` attributes properly set, but I am still having to walk through arbitrary data structures and manually wrap every single Python object instance, which is a big pain and I am hitting edge cases where I am not totally able to walk the object structures. Is there a way that I can automatically have this happen for me, so that `win32com.server.util.wrap` will automatically be called on the way out of a method? Thanks in advance for any assistance you can provide! -- Jonathan LaCour http://cleverdevil.org From mhammond at skippinet.com.au Tue Jan 23 23:50:18 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 24 Jan 2007 09:50:18 +1100 Subject: [python-win32] wrapping objects from a COM server In-Reply-To: <173C7FD1-F9DD-49A3-976E-49196B52963F@cleverdevil.org> Message-ID: <08f301c73f40$db985980$0200a8c0@enfoldsystems.local> > Is there a way that I can automatically have this happen for me, so > that `win32com.server.util.wrap` will automatically be called on the > way out of a method? It should be possible to have your _dynamic_ method do this for you? Instead of returning the result item, introspect what is returned and if it is an instance with _public_methods_ etc, just explicitly do the wrap yourself. Or I'm missing something... :) Cheers, Mark From jonathan-lists at cleverdevil.org Wed Jan 24 01:33:31 2007 From: jonathan-lists at cleverdevil.org (Jonathan LaCour) Date: Tue, 23 Jan 2007 19:33:31 -0500 Subject: [python-win32] wrapping objects from a COM server In-Reply-To: <08f301c73f40$db985980$0200a8c0@enfoldsystems.local> References: <08f301c73f40$db985980$0200a8c0@enfoldsystems.local> Message-ID: <325BD793-CC0C-40FA-AB0C-B8E0C4D89656@cleverdevil.org> Mark Hammond wrote: >> Is there a way that I can automatically have this happen for me, so >> that `win32com.server.util.wrap` will automatically be called on the >> way out of a method? > > It should be possible to have your _dynamic_ method do this for you? > Instead of returning the result item, introspect what is returned > and if it > is an instance with _public_methods_ etc, just explicitly do the wrap > yourself. > > Or I'm missing something... :) Well, thats basically what I am doing now, but these object structures that are returned can be arbitrarily complex, with lists of objects that contain other kinds of objects, which have lists of even more objects. Having to walk through arbitrary object structures and look for lists/tuples of other objects, etc. is a bit of a pain, and I am not sure if I can really do this reliably. Here is a simple example: class Person: _public_methods_ = [] _public_attrs_ = [ 'firstName', 'lastName', 'titles' ] class Title: _public_methods_ = [] _public_attrs_ = [ 'name', 'description' ] p1 = Person() p1.firstName = 'Jonathan' p1.lastName = 'LaCour' t1 = Title() t1.name = 'Some Title' t1.description = 'Some Description' p1.titles.append(t1) In order to return arbitrary objects from my _dynamic_ method, I have to check and see if any of the public attributes are lists or have their own public attributes, and then replace them with "wrapped" versions. Then I have to see if the things contained within the lists have _their_ own attributes, and so on. It would be nice if I could just do this: from win32com.server.util import wrap, register_wrapper register_wrapper(Title, wrap) register_wrapper(Person, wrap) class MyServer: ... def _dynamic_(self, ...): ... return wrap(p1) Right now, if I just wrap the "outer" Person instance, the bridge complains about not being able to convert a Title object into a COM VARIANT. If I could just tell it to use the existing `wrap` function, then it could do all of this bridging for me automatically. Does this make more sense? -- Jonathan LaCour http://cleverdevil.org From mhammond at skippinet.com.au Wed Jan 24 03:04:02 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 24 Jan 2007 13:04:02 +1100 Subject: [python-win32] wrapping objects from a COM server In-Reply-To: <325BD793-CC0C-40FA-AB0C-B8E0C4D89656@cleverdevil.org> Message-ID: <094101c73f5b$ec595600$0200a8c0@enfoldsystems.local> > Mark Hammond wrote: > > >> Is there a way that I can automatically have this happen for me, so > >> that `win32com.server.util.wrap` will automatically be > called on the > >> way out of a method? > > > > It should be possible to have your _dynamic_ method do this for you? > > Instead of returning the result item, introspect what is returned > > and if it > > is an instance with _public_methods_ etc, just explicitly > do the wrap > > yourself. > > > > Or I'm missing something... :) > > Well, thats basically what I am doing now, but these object structures > that are returned can be arbitrarily complex, with lists of objects > that contain other kinds of objects, which have lists of even more > objects. Having to walk through arbitrary object structures and look > for lists/tuples of other objects, etc. is a bit of a pain, and I am > not sure if I can really do this reliably. You don't need to recurse deeply though. If all your objects use the same policy, the sub-objects will work automatically > > Here is a simple example: > > class Person: > _public_methods_ = [] > _public_attrs_ = [ > 'firstName', > 'lastName', > 'titles' > ] > > class Title: > _public_methods_ = [] > _public_attrs_ = [ > 'name', > 'description' > ] > > p1 = Person() > p1.firstName = 'Jonathan' > p1.lastName = 'LaCour' > > t1 = Title() > t1.name = 'Some Title' > t1.description = 'Some Description' > > p1.titles.append(t1) > > In order to return arbitrary objects from my _dynamic_ method, I have > to check and see if any of the public attributes are lists or have > their own public attributes, and then replace them with "wrapped" > versions. In the above example, your hack would be called with a Person object, which you wrap. When this person object references the 'titles' attribute, you will then have see the list of instances that you wrap. There is no need to deal with the 'titles' when wrapping the Person object - just wait for the person object to return the other instances. > from win32com.server.util import wrap, register_wrapper > > register_wrapper(Title, wrap) > register_wrapper(Person, wrap) That makes sense - but such a facility doesn't exist. It would work - but I'd be leaning towards the more explicit: class Title: _com_wrap_ = wrap _public_methods_ = [...] (although the name _com_wrap_ sucks :) This would be backwards compatible. The C code in pythoncom would check for that special attribute and call it to perform a conversion into a COM object. It might get a little complicated though with respect to object identity. Consider the Python COM objects: class Child: _com_wrap_ = wrap ... class Foo: _com_wrap_ = wrap _public_attrs_ = 'child' def __init__(self): self.child = Child() # just an instance In the above example, self.child is a standard Python instance. Each time the .child attribute is fetched, COM would do the auto-wrap thing and return an instance. However - this implies it would be a *different* COM object each time the attribute was referenced. Anyone doing equality tests etc of the object itself would always fail. In the pyxpcom world, we solved that by having the wrapper store a weak-reference to the COM object. It is something we need to consider. But in general, this is something that I've always felt should be implemented in one way or another. I don't have much time at the moment though, but would be happy to help if you wanted to investigate. Cheers, Mark From le.dahut at laposte.net Wed Jan 24 09:40:47 2007 From: le.dahut at laposte.net (le dahut) Date: Wed, 24 Jan 2007 09:40:47 +0100 Subject: [python-win32] Launch process Message-ID: <45B71B8F.7000804@laposte.net> Hello, What's the best way to launch a process and waiting for its exit code ? I'm looking for something that can take win32con.SW_HIDE as argument (os.spawnv don't). K. From bborcic at gmail.com Wed Jan 24 11:48:31 2007 From: bborcic at gmail.com (Boris Borcic) Date: Wed, 24 Jan 2007 11:48:31 +0100 Subject: [python-win32] windows text rendering question In-Reply-To: <45B64CC4.6010608@probo.com> References: <45B64CC4.6010608@probo.com> Message-ID: Tim Roberts wrote: > Boris Borcic wrote: >> I am trying to use UI Automation to drive an MS Windows app with pywinauto. >> >> I need to scrape the app's window contents and use some form of OCR to get at >> the texts (pywinauto can't get at them). >> >> As an alternative to integrating an OCR engine, and since I know the fonts and >> sizes used to write on the app's windows, I reasoned that I could base a simple >> text recognition module on the capability to drive MSWindows text rendering - eg >> to generate pixmaps of texts I expect to find in the driven app's windows, exact >> to the pixel. >> >> The advantage of that approach would be exactitude and self-containment. >> > > But what if the user has font anti-aliasing or, even worse, ClearType > turned on? Your screen image won't be pixel-for-pixel accurate. This > seems like a very delicate solution to me. That's why I spoke of "wrapping the the Windows UI text rendering engine", ie so that the text gets rendered according to user options. And as a matter of fact, my tests with Idle - the paragraph just after those you cited : >> I've verified manually inside an Idle window, that indeed I could produce >> pixmaps of expected app texts, exact to the pixel (with Tkinter+screen >> capture at least). - where done with cleartype on and were pixel-to-pixel accurate. > > I'm surprised you can't get at the window contents. Have you used the > spyxx.exe utility to poke through the window structure? > I think that's what pywinauto does as well, and I had no better results with another automation module that uses pywin32 rather than ctypes (winguiauto iirc). Regards, Boris Borcic From jonathan-lists at cleverdevil.org Wed Jan 24 15:10:26 2007 From: jonathan-lists at cleverdevil.org (Jonathan LaCour) Date: Wed, 24 Jan 2007 09:10:26 -0500 Subject: [python-win32] wrapping objects from a COM server In-Reply-To: <094101c73f5b$ec595600$0200a8c0@enfoldsystems.local> References: <094101c73f5b$ec595600$0200a8c0@enfoldsystems.local> Message-ID: <226469AA-812A-43A6-943E-C5D5A50B7B4C@cleverdevil.org> Mark Hammond wrote: >> Well, thats basically what I am doing now, but these object >> structures that are returned can be arbitrarily complex, with lists >> of objects that contain other kinds of objects, which have lists >> of even more objects. Having to walk through arbitrary object >> structures and look for lists/tuples of other objects, etc. is a bit >> of a pain, and I am not sure if I can really do this reliably. > > You don't need to recurse deeply though. If all your objects use the > same policy, the sub-objects will work automatically Really? This is not my experience. I am using whatever the default policy is on all of my objects, and a test case very much like my "Person" and "Title" example below fails unless I loop through the `titles` attribute of my Person instances and manually wrap the Title instances before returning the Person instance. Am I doing something wrong? Do I need to use a different policy to make this happen? >> from win32com.server.util import wrap, register_wrapper >> >> register_wrapper(Title, wrap) >> register_wrapper(Person, wrap) > > That makes sense - but such a facility doesn't exist. It would work - > but I'd be leaning towards the more explicit: > > class Title: > _com_wrap_ = wrap > _public_methods_ = [...] > > (although the name _com_wrap_ sucks :) This would be backwards > compatible. The C code in pythoncom would check for that special > attribute and call it to perform a conversion into a COM object. Yes, I think your way fits more into the convention that pythoncom already sets. The only downside is that its a bit more difficult to register a wrapper function onto a pre-existing object (which is basically what I am doing). > It might get a little complicated though with respect to object > identity. Fair enough, but this wouldn't be an issue in my case. I am only passing back and forth instances that have a unique ID on them, and use that for all comparisons. But, I see your point :) > But in general, this is something that I've always felt should > be implemented in one way or another. I don't have much time at > the moment though, but would be happy to help if you wanted to > investigate. Depending on how far I get without it, I might just take you up on that. Thanks for all your help. -- Jonathan LaCour http://cleverdevil.org From gagsl-p32 at yahoo.com.ar Wed Jan 24 18:18:17 2007 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 24 Jan 2007 14:18:17 -0300 Subject: [python-win32] Launch process In-Reply-To: <45B71B8F.7000804@laposte.net> References: <45B71B8F.7000804@laposte.net> Message-ID: <7.0.1.0.0.20070124141656.05a75398@yahoo.com.ar> At Wednesday 24/1/2007 05:40, le dahut wrote: >What's the best way to launch a process and waiting for its exit code ? >I'm looking for something that can take win32con.SW_HIDE as argument >(os.spawnv don't). CreateProcess and then WaitForSingleEvent on the process handle. Remember to close the thread and process handles when not needed. -- Gabriel Genellina Softlab SRL __________________________________________________ Pregunt?. Respond?. Descubr?. Todo lo que quer?as saber, y lo que ni imaginabas, est? en Yahoo! Respuestas (Beta). ?Probalo ya! http://www.yahoo.com.ar/respuestas From cappy2112 at gmail.com Wed Jan 24 20:17:57 2007 From: cappy2112 at gmail.com (Tony Cappellini) Date: Wed, 24 Jan 2007 11:17:57 -0800 Subject: [python-win32] Python-win32 Digest, Vol 46, Issue 18 In-Reply-To: References: Message-ID: <8249c4ac0701241117r6743f3e8t5910cafb92d45c49@mail.gmail.com> If you want to hide the window which your app was launched, rename the .py file to .pyw You wan't see the console window then Message: 9 Date: Wed, 24 Jan 2007 09:40:47 +0100 From: le dahut Subject: [python-win32] Launch process To: python-win32 at python.org Message-ID: <45B71B8F.7000804 at laposte.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hello, What's the best way to launch a process and waiting for its exit code ? I'm looking for something that can take win32con.SW_HIDE as argument (os.spawnv don't). -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070124/42da7238/attachment.html From mhammond at skippinet.com.au Wed Jan 24 23:13:17 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 25 Jan 2007 09:13:17 +1100 Subject: [python-win32] wrapping objects from a COM server In-Reply-To: <226469AA-812A-43A6-943E-C5D5A50B7B4C@cleverdevil.org> Message-ID: <0b7001c74004$daf5b0d0$0200a8c0@enfoldsystems.local> > >> Well, thats basically what I am doing now, but these object > >> structures that are returned can be arbitrarily complex, with lists > >> of objects that contain other kinds of objects, which have lists > >> of even more objects. Having to walk through arbitrary object > >> structures and look for lists/tuples of other objects, > etc. is a bit > >> of a pain, and I am not sure if I can really do this reliably. > > > > You don't need to recurse deeply though. If all your > objects use the > > same policy, the sub-objects will work automatically > > Really? This is not my experience. I am using whatever the default > policy is on all of my objects, and a test case very much like my > "Person" and "Title" example below fails unless I loop through the > `titles` attribute of my Person instances and manually wrap the Title > instances before returning the Person instance. > > Am I doing something wrong? Do I need to use a different policy to > make this happen? It should work as described. Logically, there should be no need to wrap an object until it is actually passed via COM. ie, if the person.titles attribute was never referenced it should never need to be wrapped - which implies it could be wrapped as late as possible rather than as early as possible. > > It might get a little complicated though with respect to object > > identity. > > Fair enough, but this wouldn't be an issue in my case. I am only > passing back and forth instances that have a unique ID on them, and > use that for all comparisons. But, I see your point :) Yes, this is a point I would need to consider before adding the facility to pythoncom - it must work in the general case. Cheers, Mark From jonathan-lists at cleverdevil.org Wed Jan 24 23:36:52 2007 From: jonathan-lists at cleverdevil.org (Jonathan LaCour) Date: Wed, 24 Jan 2007 17:36:52 -0500 Subject: [python-win32] wrapping objects from a COM server In-Reply-To: <0b7001c74004$daf5b0d0$0200a8c0@enfoldsystems.local> References: <0b7001c74004$daf5b0d0$0200a8c0@enfoldsystems.local> Message-ID: <0D47DE0C-DB75-4B93-9896-2234FCC481F4@cleverdevil.org> Mark Hammond wrote: >> Really? This is not my experience. I am using whatever the default >> policy is on all of my objects, and a test case very much like my >> "Person" and "Title" example below fails unless I loop through the >> `titles` attribute of my Person instances and manually wrap the >> Title instances before returning the Person instance. >> >> Am I doing something wrong? Do I need to use a different policy to >> make this happen? > > It should work as described. Logically, there should be no need > to wrap an object until it is actually passed via COM. ie, if the > person.titles attribute was never referenced it should never need to > be wrapped - which implies it could be wrapped as late as possible > rather than as early as possible. Strangely enough, if I attempt to return a `Person` instance that has a `title` attribute that is a list populated with `Title` instances, the only way that I can get it to return without raising an Exception is to loop through all of the `Title` objects and replace them with wrapped versions. That being said, I have mostly made my project work. I ended up just writing some utility functions that can walk through the object's attributes recursively (including traversing lists/tuples) and wrap or unwrap accordingly. Its a little gross, but it works! Thanks again for the help. By and large, this project makes COM easy to work with, when my prior experiences had been fairly painful. -- Jonathan LaCour http://cleverdevil.org From rex555 at hotmail.com Thu Jan 25 01:31:30 2007 From: rex555 at hotmail.com (Rex Corrovan) Date: Wed, 24 Jan 2007 16:31:30 -0800 Subject: [python-win32] using a COM interface with [in, out] Message-ID: So I am using an interface where the .idl looks like this: HRESULT getVersion( [in, out] BSTR* Version, [in, out] BSTR* error, [out, retval] VARIANT_BOOL* ); [id(0x60030002)] Now, I ran makepy, and tried to use this. The use is supposed to be to call with two pointers and the function will populate those two pointers. I tried calling it as res, ver, err = o.getVersion(None, None) that puts empty strings into ver and err and returns false. Trying res, ver, err = o.getVersion() results in a traceback complaining about parameters not being optional. Is it possible to do this with python? _________________________________________________________________ Valentine?s Day -- Shop for gifts that spell L-O-V-E at MSN Shopping http://shopping.msn.com/content/shp/?ctId=8323,ptnrid=37,ptnrdata=24095&tcode=wlmtagline From rex555 at hotmail.com Thu Jan 25 01:55:40 2007 From: rex555 at hotmail.com (Rex Corrovan) Date: Wed, 24 Jan 2007 16:55:40 -0800 Subject: [python-win32] using a COM interface with [in, out] In-Reply-To: Message-ID: Nevermind, I am an idiot, figured out my problem. Sorry to bother. From: "Rex Corrovan" To: Python-win32 at python.org Subject: [python-win32] using a COM interface with [in, out] Date: Wed, 24 Jan 2007 16:31:30 -0800 So I am using an interface where the .idl looks like this: HRESULT getVersion( [in, out] BSTR* Version, [in, out] BSTR* error, [out, retval] VARIANT_BOOL* ); [id(0x60030002)] Now, I ran makepy, and tried to use this. The use is supposed to be to call with two pointers and the function will populate those two pointers. I tried calling it as res, ver, err = o.getVersion(None, None) that puts empty strings into ver and err and returns false. Trying res, ver, err = o.getVersion() results in a traceback complaining about parameters not being optional. Is it possible to do this with python? _________________________________________________________________ Valentine?s Day -- Shop for gifts that spell L-O-V-E at MSN Shopping http://shopping.msn.com/content/shp/?ctId=8323,ptnrid=37,ptnrdata=24095&tcode=wlmtagline _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _________________________________________________________________ Get in the mood for Valentine's Day. View photos, recipes and more on your Live.com page. http://www.live.com/?addTemplate=ValentinesDay&ocid=T001MSN30A0701 From timr at probo.com Thu Jan 25 02:47:14 2007 From: timr at probo.com (Tim Roberts) Date: Wed, 24 Jan 2007 17:47:14 -0800 Subject: [python-win32] using a COM interface with [in, out] In-Reply-To: References: Message-ID: <45B80C22.7080609@probo.com> Rex Corrovan wrote: > Nevermind, I am an idiot, figured out my problem. Sorry to bother. What was the problem? You can help the next guy trying to do this. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From le.dahut at laposte.net Thu Jan 25 11:32:17 2007 From: le.dahut at laposte.net (le dahut) Date: Thu, 25 Jan 2007 11:32:17 +0100 Subject: [python-win32] Launch process In-Reply-To: <7.0.1.0.0.20070124141656.05a75398@yahoo.com.ar> References: <45B71B8F.7000804@laposte.net> <7.0.1.0.0.20070124141656.05a75398@yahoo.com.ar> Message-ID: <45B88731.4090006@laposte.net> Thanks, but finally I use subprocess.Popen(cmd, shell=True) which sets SW_HIDE in startupinfo properties and with which you can wait for process' exit code using subprocess.Popen(cmd, shell=True).wait() Gabriel Genellina wrote : > At Wednesday 24/1/2007 05:40, le dahut wrote: > >> What's the best way to launch a process and waiting for its exit code ? >> I'm looking for something that can take win32con.SW_HIDE as argument >> (os.spawnv don't). > > CreateProcess and then WaitForSingleEvent on the process handle. > Remember to close the thread and process handles when not needed. > > From rex555 at hotmail.com Thu Jan 25 23:04:02 2007 From: rex555 at hotmail.com (Rex Corrovan) Date: Thu, 25 Jan 2007 14:04:02 -0800 Subject: [python-win32] using a COM interface with [in, out] In-Reply-To: <45B80C22.7080609@probo.com> Message-ID: The problem was actually that the COM interface had not been fully implemented. The API was just bouncing back input. The COM server is not mine, I am just required to write code against it. The fact that this API was not fully implimented was not apparent until I started delving into the VB code of the server. Communication here is not at an all time high :) The few things I did figure out is that if the API has [in, out] params, where in is never actually used, you can just send it junk and it will return the values as it normally does. retval, return1, return2 = o.testFunc(realval, junkval1, junkval2) Where real val is a required input or an [in], and junkval1 and junkval 2 are [in, out] and meant to return data. retval has the HRESULT and return1 has the return data from the junkval1 [in, out] and return2 has the returned data from the junkval2 [in,out]. Might be obvious to some, but for those of us just trying to make heads or tails of COM programming, the subtlties in things like this can get you. From: Tim Roberts To: Python-Win32 List Subject: Re: [python-win32] using a COM interface with [in, out] Date: Wed, 24 Jan 2007 17:47:14 -0800 Rex Corrovan wrote: > Nevermind, I am an idiot, figured out my problem. Sorry to bother. What was the problem? You can help the next guy trying to do this. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _________________________________________________________________ >From predictions to trailers, check out the MSN Entertainment Guide to the Academy Awards? http://movies.msn.com/movies/oscars2007/?icid=ncoscartagline1 From howard at eegsoftware.com Thu Jan 25 21:06:26 2007 From: howard at eegsoftware.com (Howard Lightstone) Date: Thu, 25 Jan 2007 20:06:26 +0000 (UTC) Subject: [python-win32] C++ problem (was rebuilding 210 with VC8 woes) References: <45B5F71A.3901.14D7808C@howard.eegsoftware.com> Message-ID: "Howard Lightstone" wrote in news:45B5F71A.3901.14D7808C at howard.eegsoftware.com: > While trying to rebuild pywin32 using VC8 (after a couple of distutils > patches...), I have reached my C++ limit. I got all the way to > building pythonwin and ... > > > I am getting an error as follows: > > d:\python25\pywin32-210\pythonwin\win32uiExt.h(393) : error C2653: > 'ThisClass' : is not a class or namespace name > d:\python25\pywin32-210\pythonwin\win32uiExt.h(392) : while > compiling > class template static data member 'const AFX_MSGMAP_ENTRY > CPythonWndFramework > _messageEntries[]' > with > [ > T=CFrameWnd > ] > d:\python25\pywin32-210\pythonwin\win32uiExt.h(387) : while Is there some explanation of how these templates were set up for pythonwin so I can get someplace to start? From wccppp at gmail.com Fri Jan 26 17:43:53 2007 From: wccppp at gmail.com (wccppp) Date: Fri, 26 Jan 2007 06:43:53 -1000 Subject: [python-win32] VBA IDE Intellisense to work with python COM server? Message-ID: <87bd46aa0701260843w302e4b01s21da06cb0283c8ac@mail.gmail.com> Hello, I created a simple COM server following the sample DynamicPolicy.py in Mark's book. When testing it with VBA, I noticed intellisense/calltip does not work. Is this how it is supposed to be? Any way to get it to work? Thank you! -- wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070126/2835f1e8/attachment.htm From timr at probo.com Fri Jan 26 19:15:34 2007 From: timr at probo.com (Tim Roberts) Date: Fri, 26 Jan 2007 10:15:34 -0800 Subject: [python-win32] VBA IDE Intellisense to work with python COM server? In-Reply-To: <87bd46aa0701260843w302e4b01s21da06cb0283c8ac@mail.gmail.com> References: <87bd46aa0701260843w302e4b01s21da06cb0283c8ac@mail.gmail.com> Message-ID: <45BA4546.9080804@probo.com> wccppp wrote: > > I created a simple COM server following the sample DynamicPolicy.py in > Mark's book. When testing it with VBA, I noticed intellisense/calltip > does not work. Is this how it is supposed to be? Any way to get it > to work? Python COM servers all have to use "late binding", meaning that the properties and methods cannot be known until the object is actually up and running. VBA doesn't instantiate the object until you run the script. Thus, intellisense can't work. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Mon Jan 29 00:20:22 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 29 Jan 2007 10:20:22 +1100 Subject: [python-win32] C++ problem (was rebuilding 210 with VC8 woes) In-Reply-To: Message-ID: <059201c74332$e30aa560$230a0a0a@enfoldsystems.local> I'm afraid that compile error doesn't ring any bells with me, and I've no copy of VC8 handy to verify your error with. > "Howard Lightstone" wrote in > news:45B5F71A.3901.14D7808C at howard.eegsoftware.com: > > > While trying to rebuild pywin32 using VC8 (after a couple > of distutils > > patches...), I have reached my C++ limit. I got all the way to > > building pythonwin and ... > > > > > > I am getting an error as follows: > > > > d:\python25\pywin32-210\pythonwin\win32uiExt.h(393) : error C2653: > > 'ThisClass' : is not a class or namespace name > > d:\python25\pywin32-210\pythonwin\win32uiExt.h(392) : while > > compiling > > class template static data member 'const AFX_MSGMAP_ENTRY > > CPythonWndFramework > > _messageEntries[]' > > with > > [ > > T=CFrameWnd > > ] > > d:\python25\pywin32-210\pythonwin\win32uiExt.h(387) : while > > > Is there some explanation of how these templates were set up > for pythonwin so I can get someplace to start? I'm not sure what you mean - they were setup by hand creating win32uiExt.h. They were created to give the win32ui related subclasses common functionality without a copy-and-paste between various implementations with different base classes. I wish I could be more help, Mark From nytrokiss at gmail.com Mon Jan 29 05:11:57 2007 From: nytrokiss at gmail.com (James Matthews) Date: Sun, 28 Jan 2007 23:11:57 -0500 Subject: [python-win32] VBA IDE Intellisense to work with python COM server? In-Reply-To: <45BA4546.9080804@probo.com> References: <87bd46aa0701260843w302e4b01s21da06cb0283c8ac@mail.gmail.com> <45BA4546.9080804@probo.com> Message-ID: <8a6b8e350701282011te8927fcv9bb6b9a1ff01558f@mail.gmail.com> Thanks On 1/26/07, Tim Roberts wrote: > > wccppp wrote: > > > > I created a simple COM server following the sample DynamicPolicy.py in > > Mark's book. When testing it with VBA, I noticed intellisense/calltip > > does not work. Is this how it is supposed to be? Any way to get it > > to work? > > Python COM servers all have to use "late binding", meaning that the > properties and methods cannot be known until the object is actually up > and running. VBA doesn't instantiate the object until you run the > script. Thus, intellisense can't work. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com http://www.wazoozle.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20070128/8062136d/attachment.htm From python.leojay at gmail.com Mon Jan 29 11:43:09 2007 From: python.leojay at gmail.com (Leo Jay) Date: Mon, 29 Jan 2007 18:43:09 +0800 Subject: [python-win32] how to generate an IPersistStream object? Message-ID: <4e307e0f0701290243l678e82ffu4f59a398d2a860b9@mail.gmail.com> i need to pass an IPersistStream object to a COM function, and i find a type named PyIPersistStream in the manual of pywin32. but i don't know how to generate a PyIPersistStream object and pass it to the function. anyone could help me? thanks in advance. -- Best Regards, Leo Jay From gagsl-p32 at yahoo.com.ar Mon Jan 29 19:41:40 2007 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 29 Jan 2007 15:41:40 -0300 Subject: [python-win32] how to generate an IPersistStream object? In-Reply-To: <4e307e0f0701290243l678e82ffu4f59a398d2a860b9@mail.gmail.co m> References: <4e307e0f0701290243l678e82ffu4f59a398d2a860b9@mail.gmail.com> Message-ID: <7.0.1.0.0.20070129152620.042007d8@yahoo.com.ar> At Monday 29/1/2007 07:43, Leo Jay wrote: >i need to pass an IPersistStream object to a COM function, >and i find a type named PyIPersistStream in the manual of pywin32. > >but i don't know how to generate a PyIPersistStream object and pass it >to the function. >anyone could help me? I've never implemented that interfase myself, but usually you only have to add two class attributes: _com_interfaces_ and _public_methods_, and implement the needed methods. You should refer to the Microsoft documentation on the exact semantics of each method. -- Gabriel Genellina Softlab SRL __________________________________________________ Pregunt?. Respond?. Descubr?. Todo lo que quer?as saber, y lo que ni imaginabas, est? en Yahoo! Respuestas (Beta). ?Probalo ya! http://www.yahoo.com.ar/respuestas From mhammond at skippinet.com.au Mon Jan 29 22:05:58 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 Jan 2007 08:05:58 +1100 Subject: [python-win32] how to generate an IPersistStream object? In-Reply-To: <4e307e0f0701290243l678e82ffu4f59a398d2a860b9@mail.gmail.com> Message-ID: <073201c743e9$465eb000$230a0a0a@enfoldsystems.local> > i need to pass an IPersistStream object to a COM function, > and i find a type named PyIPersistStream in the manual of pywin32. > > but i don't know how to generate a PyIPersistStream object and pass it > to the function. > anyone could help me? Gabriel is completely correct - see ./win32com/demos/ietoolbar.py and ./win32com/test/testStreams.py for 2 samples that use this interface. Mark From python.leojay at gmail.com Tue Jan 30 02:56:38 2007 From: python.leojay at gmail.com (Leo Jay) Date: Tue, 30 Jan 2007 09:56:38 +0800 Subject: [python-win32] how to generate an IPersistStream object? In-Reply-To: <073201c743e9$465eb000$230a0a0a@enfoldsystems.local> References: <4e307e0f0701290243l678e82ffu4f59a398d2a860b9@mail.gmail.com> <073201c743e9$465eb000$230a0a0a@enfoldsystems.local> Message-ID: <4e307e0f0701291756h3204bc35k525fb94bf6210080@mail.gmail.com> On 1/30/07, Mark Hammond wrote: > > i need to pass an IPersistStream object to a COM function, > > and i find a type named PyIPersistStream in the manual of pywin32. > > > > but i don't know how to generate a PyIPersistStream object and pass it > > to the function. > > anyone could help me? > > Gabriel is completely correct - see ./win32com/demos/ietoolbar.py and > ./win32com/test/testStreams.py for 2 samples that use this interface. > thanks to all of you for helping me. do i have to implement the IPersistStream by my self? regarding to IStorage and IStream, i can invoke StgCreateDocfile and IStorage::CreateStream to generate corresponding objects. i thought there must be some way to do that effectively, without having to do all trivial things by myself. i went through all of the samples coming up with pywin32 before i post this thread. as to ./win32com/test/testStreams.py, it implements IStream and IPersist interfaces by itself (and the implementation is incomplete). i don't think that's a good way to implement all of the interfaces that i need, do you? thanks. -- Best Regards, Leo Jay From mhammond at skippinet.com.au Tue Jan 30 04:32:57 2007 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 Jan 2007 14:32:57 +1100 Subject: [python-win32] how to generate an IPersistStream object? In-Reply-To: <4e307e0f0701291756h3204bc35k525fb94bf6210080@mail.gmail.com> Message-ID: <07ab01c7441f$567b13d0$230a0a0a@enfoldsystems.local> > On 1/30/07, Mark Hammond wrote: > > > i need to pass an IPersistStream object to a COM function, > > > and i find a type named PyIPersistStream in the manual of pywin32. > > > > > > but i don't know how to generate a PyIPersistStream > object and pass it > > > to the function. > > > anyone could help me? > > > > Gabriel is completely correct - see > ./win32com/demos/ietoolbar.py and > > ./win32com/test/testStreams.py for 2 samples that use this > interface. > > > > thanks to all of you for helping me. > > do i have to implement the IPersistStream by my self? > regarding to IStorage and IStream, i can invoke StgCreateDocfile and > IStorage::CreateStream to generate corresponding objects. > > i thought there must be some way to do that effectively, without > having to do all trivial things by myself. That is the nature of interfaces - they generally don't come with an implementation. Certainly Python removes the need for many of the trivial things C++ would require you to do, but I can't think of any other details a generic Python implementation could provide. However, if you can come up with an implementation of a base class you believe would be useful for people implementing this interface I'd be happy to look at including it in pywin32. > > i went through all of the samples coming up with pywin32 before i post > this thread. > as to ./win32com/test/testStreams.py, it implements IStream and > IPersist interfaces > by itself (and the implementation is incomplete). > i don't think that's a good way to implement all of the interfaces > that i need, do you? It obviously depends on your caller - but in general I agree, providing a partial implementation of an interface is not what production code should do. But that is the nature of samples - they are intended to give you enough information to create something for your own application and do not profess to be complete implementations of anything. Mark From charles_darvy at hotmail.com Wed Jan 31 02:04:33 2007 From: charles_darvy at hotmail.com (Charles Darvy) Date: Tue, 30 Jan 2007 20:04:33 -0500 Subject: [python-win32] Bug in Python disutils? Message-ID: Hi all, I have been battling this for a bit. I am trying to compile the meld3 (http://www.plope.com/software/meld3) Python extension under Windows 2003 (Python 2.5 final MinGW (MinGW-5.1.3.exe). I settled on the method outlined at http://wiki.python.org/moin/PyrexOnWindows for compiling Python extensions on Windows (and followed those directions). Unfortunately, this is the output I received on my first attempt (which is better than nothing I guess :-)): C:\meld3-0.6>python setup. py install running install running build running build_py creating build creating build\lib.win32-2.5 creating build\lib.win32-2.5\meld3 copying meld3\ clearsilverprofile.py -> build\lib.win32-2.5\meld3 copying meld3\example. py -> build\lib.win32-2.5\meld3 copying meld3\meld3.py -> build\lib.win32- 2.5\meld3 copying meld3\melddiff.py -> build\lib.win32-2.5\meld3 copying meld3\meldprofile.py -> build\lib.win32-2.5\meld3 copying meld3\setup.py -> build\lib.win32-2.5\meld3 copying meld3\testclone.py -> build\lib.win32-2.5\meld3 copying meld3\test_getiterator. py -> build\lib.win32-2.5\meld3 copying meld3\test_meld3.py -> build\lib.win32- 2.5\meld3 copying meld3\zptprofile.py -> build\lib.win32-2.5\meld3 copying meld3\__init__.py -> build\lib.win32-2.5\meld3 running build_ext building 'meld3/cmeld3' extension creating build\temp.win32- 2.5 creating build\temp.win32-2.5\Release creating build\temp.win32-2.5\Release\meld3 C:\MinGW\bin\gcc.exe - mno-cygwin -mdll -O -Wall -IC:\Python25\include -IC :\Python25\PC -c meld3/cmeld3.c -o build\temp.win32-2.5\Release\meld3\cmeld3.o writing build\temp.win32-2.5\Release\meld3\cmeld3.def C:\MinGW\bin\gcc.exe -mno -cygwin -shared -s build\temp.win32-2.5\Release\meld3\cmeld3.o build\temp.win32-2.5\Release\meld3\cmeld3.def -LC:\Python25\libs -LC:\Python25\PCBuild -lpython25 -lmsvcr71 -o build\lib.win32-2.5\meld3/cmeld3.pyd Cannot export initmeld3/cmeld3: symbol not defined collect2: ld returned 1 exit status error: command 'gcc ' failed with exit status 1 When I opened build\temp.win32-2.5\Release\meld3\cmeld3.def, I found: LIBRARY cmeld3.pyd EXPORTS initmeld3/cmeld3 When I changed the last line from "initmeld3/cmeld3" to "initcmeld3" (adding a "c" and dropping the "/cmeld3") like so: LIBRARY cmeld3.pyd EXPORTS initcmeld3 and reran the compile command manually: C:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.5\Release\meld3\cmeld3.o build\temp.win32-2.5\Release\meld3\cmeld3.def -LC:\Python25\libs -LC:\Python25\PCBuild -lpython25 -lmsvcr71 -o build\lib.win32-2.5\meld3/cmeld3.pyd ..it compiled cmeld.pyd. I then reran python "setup.py install" and got: C:\meld3-0.6>python setup.py install running install running build running build_py running build_ext running install_lib creating C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\clearsilverprofile.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\cmeld3.pyd -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\example.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\meld3.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\melddiff.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\meldprofile.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32- 2.5\meld3\setup.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\testclone.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\test_getiterator.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\test_meld3.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\zptprofile.py -> C:\Python25\Lib\site-packages\meld3 copying build\lib.win32-2.5\meld3\__init__.py -> C:\Python25\Lib\site-packages\meld3 byte-compiling C:\Python25\Lib\site-packages\meld3\clearsilverprofile.py to clearsilverprofile.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\example.py to example.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\meld3.py to meld3.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\melddiff.py to melddiff.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\meldprofile.py to meldprofile.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\setup.py to setup.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\testclone.py to testclone.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\test_getiterator.py to test_getiterator.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\test_meld3.py to test_meld3.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\zptprofile.py to zptprofile.pyc byte-compiling C:\Python25\Lib\site-packages\meld3\__init__.py to __init__.pyc running install_egg_info Writing C:\Python25\Lib\site-packages\meld3-0.6-py2.5.egg-info Is this a bug in Python disutils? Any thoughts? Thanks, Jason _________________________________________________________________ Get live scores and news about your team: Add the Live.com Football Page http://www.live.com/?addtemplate=football From molotok at online.fr Wed Jan 31 22:23:00 2007 From: molotok at online.fr (Alexander Kabanets) Date: Wed, 31 Jan 2007 21:23:00 +0000 (UTC) Subject: [python-win32] rebuilding 210 with VC8 woes References: <45B5F71A.3901.14D7808C@howard.eegsoftware.com> Message-ID: Howard Lightstone eegsoftware.com> writes: > > While trying to rebuild pywin32 using VC8 (after a couple of distutils > patches...), I have reached my C++ limit. I got all the way to building > pythonwin and ... > > I am getting an error as follows: > > d:\python25\pywin32-210\pythonwin\win32uiExt.h(393) : error C2653: > 'ThisClass' : is not a class or namespace name > d:\python25\pywin32-210\pythonwin\win32uiExt.h(392) : while compiling > class template static data member 'const AFX_MSGMAP_ENTRY > CPythonWndFramework > _messageEntries[]' > with > [ > T=CFrameWnd > ] > d:\python25\pywin32-210\pythonwin\win32uiExt.h(387) : while compiling > class template static data member 'const AFX_MSGMAP > CPythonWndFramework::mess > eMap' > with > [ > T=CFrameWnd > ] > d:\python25\pywin32-210\pythonwin\pythonframe.h(9) : see reference > to class template instantiation 'CPythonWndFramework' being compiled > with > [ > T=CFrameWnd > ] > d:\python25\pywin32-210\pythonwin\win32uiExt.h(394) : error C2653: > 'ThisClass' : is not a class or namespace name > > ???? I am not sure what this means..... I *assume* it must be some > difference with using VC8 (part of Visual Studio 8) as the compiler. > > I will submit changes for the minor errors/issues I had to fix to get to > this > point but they were all scope or explicit cast issues. I am stumped here. > Any > help would be appreciated. > Hi, I've compiled successfully by modifing win32uiExt.h: 1. add before "template const AFX_MSGMAP_ENTRY CPythonWndFramework::_messageEntries[] = {" (line 391) _________________________________________ #define ThisClass CPythonWndFramework _________________________________________ and after "{0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } };" (line 413) _________________________________________ #undef ThisClass _________________________________________ 2. Change "afx_msg UINT OnNcHitTest(CPoint pt) " by "afx_msg LRESULT OnNcHitTest(CPoint pt)" (line 293) 3 . replace the definition of CPythonPrtDlgFramework::_messageEntries by ____________________________________________________________________ // I added pointers to the functions template const AFX_MSGMAP_ENTRY CPythonPrtDlgFramework::_messageEntries[] = { ON_MESSAGE(WM_INITDIALOG, &HandleInitDialog) ON_COMMAND(IDC_PRINT_TO_FILE, &HandlePrintToFile) ON_COMMAND(IDC_PRINT_COLLATE, &HandleCollate) ON_COMMAND_RANGE(IDC_PRINT_RANGE_ALL, IDC_PRINT_RANGE_PAGES, &HandlePrintRange) {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } }; ____________________________________________________________________ It will be placed at line 983. That's all. regards, Alexander Kabanets