Page 1 of 1

getParent()

Posted: Sun Jul 25, 2021 12:28 pm
by berkinet
Python 2.7

The api documentation says I can do

Code: Select all

parent = ch.getParent()
print("Parent: " + str(parent))
However, that just provides

Code: Select all

<Phidget22.Phidget.Phidget instance at 0x1011b2ea8>
Attempting to iterate through the object shows a little bit more, but nothing really useful and there do not even appear to be objects for the Parent (like a device handle), etc.

Code: Select all

var:_onError, val:None
var:handle, val:c_void_p(140473406883328)
var:_ErrorFactory, val:<class 'ctypes.CFunctionType'>
var:_PropertyChange, val:None
var:_DetachFactory, val:<class 'ctypes.CFunctionType'>
var:_onDetach, val:None
var:_AttachFactory, val:<class 'ctypes.CFunctionType'>
var:_Attach, val:None
var:_PropertyChangeFactory, val:<class 'ctypes.CFunctionType'>
var:_onAttach, val:None
var:_Detach, val:None
var:_onPropertyChange, val:None
Is there any sample code for using the object reti=urned from getParent()?

Re: getParent()

Posted: Mon Jul 26, 2021 8:52 am
by mparadis
getParent returns a Phidget handle, so rather than trying to use the properties of the object itself, you should use API calls on it, like:

Code: Select all

parent.getDeviceSerialNumber()
parent.getDeviceName()
parent.getDeviceSKU()
I agree the code sample in the API is misleading, so I'll look into getting that changed.

Re: getParent()

Posted: Mon Jul 26, 2021 8:53 am
by berkinet
Thanks!

Re: getParent()

Posted: Tue Aug 03, 2021 12:17 pm
by berkinet
A follow-up question. In Python, do you have an example of walking up the device tree?

Thanks.