getParent()

Supporting 2.7 and 3.2+
Post Reply
berkinet
Phidget Mastermind
Posts: 212
Joined: Thu Sep 17, 2009 12:17 pm
Contact:

getParent()

Post 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()?
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: getParent()

Post 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.
berkinet
Phidget Mastermind
Posts: 212
Joined: Thu Sep 17, 2009 12:17 pm
Contact:

Re: getParent()

Post by berkinet »

Thanks!
berkinet
Phidget Mastermind
Posts: 212
Joined: Thu Sep 17, 2009 12:17 pm
Contact:

Re: getParent()

Post by berkinet »

A follow-up question. In Python, do you have an example of walking up the device tree?

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests