jim-easterbrook / python-gphoto2

Python interface to libgphoto2
GNU Lesser General Public License v3.0
357 stars 59 forks source link

gp_camera_get_single_config #151

Closed rawexp closed 1 year ago

rawexp commented 1 year ago

Hi Jim,

Thanks for all of your help and the work you have put into this. I am having trouble figuring out how to use this function gp_camera_get_single_config - probably because my python experience is limited!

I would like to use the function to retrieve and print a camera setting, for example, something along these lines:

camera = gp.Camera()
camera.init()
print('Exposure Mode ' + gp.gp_camera_get_single_config(camera, "/main/capturesettings/autoexposuremode"))

I might then also want to set a single value using a function like:

gp.gp_camera_set_single_config(camera, "/main/capturesettings/aperture", "6.3"))

Can you give me a pointer or two or let me know if there are any examples that I can refer to? Many thanks.

jim-easterbrook commented 1 year ago

As you will have seen from the API documentation, gp_camera_get_single_config returns a CameraWidget object. (In the C API it's an "output" parameter, in the Python interface it's appended to the int status that's returned by almost every function, as described in the README.)

The CameraWidget object has methods to get and set its value. After changing the value you write it back to the camera with gp_camera_set_single_config.

The "object oriented" versions Camera.get_single_config and Camera.set_single_config are easier to use as the returned status is checked for errors and removed from the return value.

I don't use any of these functions myself as I usually want to set several config values. I think you don't need the full widget path, just the last part of it, but I could be wrong.

Finally, this is not the place to ask for help with using libgphoto2, it's for reporting bugs in the Python interface.

rawexp commented 1 year ago

Hi Jim, thanks for the response. That set me off in the right direction and I have it working now. I also found the pointers in these threads helpful: https://github.com/jim-easterbrook/python-gphoto2/issues/116 https://github.com/jim-easterbrook/python-gphoto2/issues/137