|
Re: Catching NavigateError in test_browser.py: msg#00021python.ctypes
"Brad Clements" <bkc@xxxxxxxxxxxxx> writes: > Sorry for the cross-post to ctypes. Venster list seems to be very idle. > > > > I'm trying to catch NavigateError events in test_browser. > > In testing, I added this to the browserWindow class > > def NavigateError(self, this, pDisp, URL, targetFrameName, statusCode, > Cancel): > > > 1. what is "this" ? "this" is an implementation detail. You may think of it as a reminder that you are *implementing* a com interface method. > 2. Cancel is Python type bool, but I'm looking for a POINTER(c_int) as > described in ie6_gen > > > DISPMETHOD(0x10f, None, "NavigateError", POINTER(IDispatch), > POINTER(VARIANT), POINTER(VARIANT), POINTER(VARIANT), POINTER(c_int)), > > > I need to set Cancel.value = 1 > > How is it that Cancel is being converted to a bool? I how can I set > it's value by reference? The conversion is done in ctypes.com.automation, in the VARIANT class. And it seems I got it wrong for the VT_BYREF cases. Maybe you can fix it yourself, by inserting this field in the VARIANT's class U(Union) _fields_ definition: class U(Union): _fields_ = [("VT_BOOL", c_short), ("pBool", POINTER(c_short)), # new field ("VT_I1", c_char), ... and adding this code to the get_value() method, in the giant if: elif: construct, just before the 'elif self.vt & VT_BYREF:' line: elif self.vt == VT_BYREF|VT_BOOL: return self._.pBool.contents After that, the NavigateError method will probably be called with an c_short instance as last parameter, then you can do Cancel.value = True. I tested that with the BeforeNavigate2 method (in the ctypes\com\samples\iexplorer.py file), and it worked for me. This should probably be fixed for other VT_BYREF types as well. Thomas ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Problems with nested structures: 00021, Thomas Heller |
|---|---|
| Next by Date: | RE: Re: Problems with nested structures: 00021, Stefan Schukat |
| Previous by Thread: | Catching NavigateError in test_browser.pyi: 00021, Brad Clements |
| Next by Thread: | Re: Catching NavigateError in test_browser.py: 00021, Thomas Heller |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |