def get(self, config): parent_options = dict() child_count = gp.check_result(gp.gp_widget_count_children(config)) if child_count < 1: return parent_options for child in gp.check_result(gp.gp_widget_get_children(config)): label = gp.check_result(gp.gp_widget_get_label(child)) name = gp.check_result(gp.gp_widget_get_name(child)) child_type = gp.check_result(gp.gp_widget_get_type(child)) try: handler_class = handlers[child_type] except KeyError: print('Cannot make widget type %d for %s' % (child_type, label)) child_options = dict() else: handler = handler_class() child_options = handler.get(child) finally: child_options['prototype'] = child_type child_options['label'] = label child_options['name'] = name parent_options[name] = child_options return parent_options
def set(self, config, value): child_count = gp.check_result(gp.gp_widget_count_children(config)) if child_count < 1: return for child in gp.check_result(gp.gp_widget_get_children(config)): name = gp.check_result(gp.gp_widget_get_name(child)) child_type = gp.check_result(gp.gp_widget_get_type(child)) # do we have a config to change? try: child_value = value[name] except KeyError: pass else: # yes, let's change it try: handler_class = handlers[child_type] except KeyError: pass else: handler = handler_class() try: handler.set(child, child_value) except NotImplementedError: pass
def change_iso_setting(self): camera = gp.check_result(gp.gp_camera_new()) gp.check_result(gp.gp_camera_init(camera)) camera_config = gp.check_result(gp.gp_camera_get_config(camera)) for child in gp.check_result(gp.gp_widget_get_children(camera_config)): print(gp.check_result(gp.gp_widget_get_label(child))) gp.check_result(gp.gp_camera_exit(camera))
def __init__(self, config_changed, camera_config, parent=None): QtGui.QWidget.__init__(self, parent) self.setLayout(QtGui.QFormLayout()) if gp.check_result(gp.gp_widget_get_readonly(camera_config)): self.setDisabled(True) child_count = gp.check_result( gp.gp_widget_count_children(camera_config)) if child_count < 1: return tabs = None for child in gp.check_result(gp.gp_widget_get_children(camera_config)): label = gp.check_result(gp.gp_widget_get_label(child)) name = gp.check_result(gp.gp_widget_get_name(child)) label = '{} ({})'.format(label, name) child_type = gp.check_result(gp.gp_widget_get_type(child)) if child_type == gp.GP_WIDGET_SECTION: if not tabs: tabs = QtGui.QTabWidget() self.layout().insertRow(0, tabs) tabs.addTab(SectionWidget(config_changed, child), label) elif child_type == gp.GP_WIDGET_TEXT: self.layout().addRow(label, TextWidget(config_changed, child)) elif child_type == gp.GP_WIDGET_RANGE: self.layout().addRow(label, RangeWidget(config_changed, child)) elif child_type == gp.GP_WIDGET_TOGGLE: self.layout().addRow(label, ToggleWidget(config_changed, child)) elif child_type == gp.GP_WIDGET_RADIO: choice_count = gp.check_result( gp.gp_widget_count_choices(child)) if choice_count > 3: widget = MenuWidget(config_changed, child) else: widget = RadioWidget(config_changed, child) self.layout().addRow(label, widget) elif child_type == gp.GP_WIDGET_MENU: self.layout().addRow(label, MenuWidget(config_changed, child)) elif child_type == gp.GP_WIDGET_DATE: self.layout().addRow(label, DateWidget(config_changed, child)) else: print('Cannot make widget type %d for %s' % (child_type, label))
def __init__(self, config_changed, camera_config, parent=None): QtWidgets.QWidget.__init__(self, parent) self.setLayout(QtWidgets.QFormLayout()) if gp.check_result(gp.gp_widget_get_readonly(camera_config)): self.setDisabled(True) child_count = gp.check_result(gp.gp_widget_count_children(camera_config)) if child_count < 1: return tabs = None for child in gp.check_result(gp.gp_widget_get_children(camera_config)): label = gp.check_result(gp.gp_widget_get_label(child)) name = gp.check_result(gp.gp_widget_get_name(child)) label = '{} ({})'.format(label, name) child_type = gp.check_result(gp.gp_widget_get_type(child)) if child_type == gp.GP_WIDGET_SECTION: if not tabs: tabs = QtWidgets.QTabWidget() self.layout().insertRow(0, tabs) tabs.addTab(SectionWidget(config_changed, child), label) elif child_type == gp.GP_WIDGET_TEXT: self.layout().addRow(label, TextWidget(config_changed, child)) elif child_type == gp.GP_WIDGET_RANGE: self.layout().addRow(label, RangeWidget(config_changed, child)) elif child_type == gp.GP_WIDGET_TOGGLE: self.layout().addRow(label, ToggleWidget(config_changed, child)) elif child_type == gp.GP_WIDGET_RADIO: choice_count = gp.check_result(gp.gp_widget_count_choices( child)) if choice_count > 3: widget = MenuWidget(config_changed, child) else: widget = RadioWidget(config_changed, child) self.layout().addRow(label, widget) elif child_type == gp.GP_WIDGET_MENU: self.layout().addRow(label, MenuWidget(config_changed, child)) elif child_type == gp.GP_WIDGET_DATE: self.layout().addRow(label, DateWidget(config_changed, child)) else: print('Cannot make widget type %d for %s' % (child_type, label))