How to use the gphoto2.gp_widget_get_child_by_name function in gphoto2

To help you get started, we’ve selected a few gphoto2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jim-easterbrook / python-gphoto2 / examples / get-capture-target.py View on Github external
def main():
    # use Python logging
    logging.basicConfig(
        format='%(levelname)s: %(name)s: %(message)s', level=logging.WARNING)
    callback_obj = gp.check_result(gp.use_python_logging())
    # open camera connection
    camera = gp.check_result(gp.gp_camera_new())
    gp.check_result(gp.gp_camera_init(camera))
    # get configuration tree
    config = gp.check_result(gp.gp_camera_get_config(camera))
    # find the capture target config item
    capture_target = gp.check_result(
        gp.gp_widget_get_child_by_name(config, 'capturetarget'))
    # print current setting
    value = gp.check_result(gp.gp_widget_get_value(capture_target))
    print('Current setting:', value)
    # print possible settings
    for n in range(gp.check_result(gp.gp_widget_count_choices(capture_target))):
        choice = gp.check_result(gp.gp_widget_get_choice(capture_target, n))
        print('Choice:', n, choice)
    # clean up
    gp.check_result(gp.gp_camera_exit(camera))
    return 0
github greiginsydney / Intervalometerator / Raspberry Pi / www / intvlm8r.py View on Github external
def readValue ( camera, attribute ):
    """ Reads a simple attribute in the camera and returns the value """
    try:
        object = gp.check_result(gp.gp_widget_get_child_by_name(camera, attribute))
        value = gp.check_result(gp.gp_widget_get_value(object))
    except:
        value = ''
    return value
github jim-easterbrook / python-gphoto2 / examples / cam-conf-view-gui.py View on Github external
def put_camera_capture_preview_mirror(camera, camera_config, camera_model):
    if camera_model == 'unknown':
        # find the capture size class config item
        # need to set this on my Canon 350d to get preview to work at all
        OK, capture_size_class = gp.gp_widget_get_child_by_name(
            camera_config, 'capturesizeclass')
        if OK >= gp.GP_OK:
            # set value
            value = capture_size_class.get_choice(2)
            capture_size_class.set_value(value)
            # set config
            camera.set_config(camera_config)
    else:
        # put camera into preview mode to raise mirror
        ret = gp.gp_camera_capture_preview(camera) # OK, camera_file
        #print(ret) # [0, ]
github jim-easterbrook / python-gphoto2 / examples / cam-conf-view-gui.py View on Github external
def _reset_config(self):
        if self.hasCamInited:
            if self.old_capturetarget is not None:
                # find the capture target item
                OK, capture_target = gp.gp_widget_get_child_by_name(
                    self.camera_config, 'capturetarget')
                if OK >= gp.GP_OK:
                    # set config
                    capture_target.set_value(self.old_capturetarget)
                    self.camera.set_config(self.camera_config)
                    self.old_capturetarget = None
github jim-easterbrook / python-gphoto2 / examples / cam-conf-view-gui.py View on Github external
def get_camera_model(camera_config):
    # get the camera model
    OK, camera_model = gp.gp_widget_get_child_by_name(
        camera_config, 'cameramodel')
    if OK < gp.GP_OK:
        OK, camera_model = gp.gp_widget_get_child_by_name(
            camera_config, 'model')
    if OK >= gp.GP_OK:
        camera_model = camera_model.get_value()
    else:
        camera_model = ''
    return camera_model
github jim-easterbrook / python-gphoto2 / examples / focus-gui.py View on Github external
def _set_config(self):
        # find the capture target item
        OK, capture_target = gp.gp_widget_get_child_by_name(
            self.config, 'capturetarget')
        if OK >= gp.GP_OK:
            if self.old_capturetarget is None:
                self.old_capturetarget = capture_target.get_value()
            choice_count = capture_target.count_choices()
            for n in range(choice_count):
                choice = capture_target.get_choice(n)
                if 'internal' in choice.lower():
                    # set config
                    capture_target.set_value(choice)
                    self.camera.set_config(self.config)
                    break
        # find the image format config item
        # camera dependent - 'imageformat' is 'imagequality' on some
        OK, image_format = gp.gp_widget_get_child_by_name(
            self.config, 'imageformat')
github greiginsydney / Intervalometerator / Raspberry Pi / intvlm8r.py View on Github external
def getPreviewImage(camera, context, config):
    """ Straight out of Jim's examples """
    OK, image_format = gp.gp_widget_get_child_by_name(config, 'imageformat')
    if OK >= gp.GP_OK:
        # get current setting
        value = gp.check_result(gp.gp_widget_get_value(image_format))
        # make sure it's not raw
        if 'raw' in value.lower():
            app.logger.debug('Cannot preview raw images')
            return 1
    # find the capture size class config item
    # need to set this on my Canon 350d to get preview to work at all
    OK, capture_size_class = gp.gp_widget_get_child_by_name(
        config, 'capturesizeclass')
    if OK >= gp.GP_OK:
        # set value
        value = gp.check_result(gp.gp_widget_get_choice(capture_size_class, 2))
        gp.check_result(gp.gp_widget_set_value(capture_size_class, value))
        # set config
github jim-easterbrook / python-gphoto2 / examples / focus-gui.py View on Github external
def _reset_config(self):
        if self.old_capturetarget is not None:
            # find the capture target item
            OK, capture_target = gp.gp_widget_get_child_by_name(
                self.config, 'capturetarget')
            if OK >= gp.GP_OK:
                # set config
                capture_target.set_value(self.old_capturetarget)
                self.camera.set_config(self.config)
                self.old_capturetarget = None