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 n in range(child_count): child = gp.check_result(gp.gp_widget_get_child(camera_config, n)) 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: self.layout().addRow(label, RadioWidget(config_changed, child)) 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): print "init AstroCamCanon" gp.check_result(gp.use_python_logging()) self.context = gp.gp_context_new() self.camera = gp.check_result(gp.gp_camera_new()) print "config" camera_config = gp.check_result(gp.gp_camera_get_config(self.camera, self.context)) child_count = gp.check_result(gp.gp_widget_count_children(camera_config)) print child_count for n in range(child_count): try: print "============" child = gp.check_result(gp.gp_widget_get_child(camera_config, n)) name = gp.check_result(gp.gp_widget_get_name(child)) print name chtype = gp.check_result(gp.gp_widget_get_type(child)) print chtype ro = gp.check_result(gp.gp_widget_get_readonly(child)) print ro cdildcen = gp.check_result(gp.gp_widget_count_children(child)) print cdildcen except Exception, e: print e
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 n in range(child_count): child = gp.check_result(gp.gp_widget_get_child(camera_config, n)) label = gp.check_result(gp.gp_widget_get_label(child)) 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: self.layout().addRow(label, RadioWidget(config_changed, child)) 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, config, parent=None): QtGui.QCheckBox.__init__(self, parent) self.config_changed = config_changed self.config = config if gp.check_result(gp.gp_widget_get_readonly(config)): self.setDisabled(True) assert gp.check_result(gp.gp_widget_count_children(config)) == 0 value = gp.check_result(gp.gp_widget_get_value(config)) self.setChecked(value != 0) self.clicked.connect(self.new_value)
def __init__(self, config_changed, config, parent=None): QtGui.QLineEdit.__init__(self, parent) self.config_changed = config_changed self.config = config if gp.check_result(gp.gp_widget_get_readonly(config)): self.setDisabled(True) assert gp.check_result(gp.gp_widget_count_children(config)) == 0 value = gp.check_result(gp.gp_widget_get_value(config)) if value: self.setText(value) self.editingFinished.connect(self.new_value)
def __init__(self, config_changed, config, parent=None): QtGui.QDateTimeEdit.__init__(self, parent) self.config_changed = config_changed self.config = config if gp.check_result(gp.gp_widget_get_readonly(config)): self.setDisabled(True) assert gp.check_result(gp.gp_widget_count_children(config)) == 0 value = gp.check_result(gp.gp_widget_get_value(config)) if value: self.setDateTime(datetime.fromtimestamp(value)) self.dateTimeChanged.connect(self.new_value) self.setDisplayFormat('yyyy-MM-dd hh:mm:ss')
def __init__(self, config_changed, config, parent=None): QtGui.QSlider.__init__(self, Qt.Horizontal, parent) self.config_changed = config_changed self.config = config if gp.check_result(gp.gp_widget_get_readonly(config)): self.setDisabled(True) assert gp.check_result(gp.gp_widget_count_children(config)) == 0 lo, hi, self.inc = gp.check_result(gp.gp_widget_get_range(config)) value = gp.check_result(gp.gp_widget_get_value(config)) self.setRange(int(lo * self.inc), int(hi * self.inc)) self.setValue(int(value * self.inc)) self.sliderReleased.connect(self.new_value)
def __init__(self, config_changed, config, parent=None): QtWidgets.QLineEdit.__init__(self, parent) self.config_changed = config_changed self.config = config if gp.check_result(gp.gp_widget_get_readonly(config)): self.setDisabled(True) assert gp.check_result(gp.gp_widget_count_children(config)) == 0 value = gp.check_result(gp.gp_widget_get_value(config)) if value: if sys.version_info[0] < 3: value = value.decode('utf-8') self.setText(value) self.editingFinished.connect(self.new_value)
def __init__(self, config_changed, config, parent=None): QtGui.QComboBox.__init__(self, parent) self.config_changed = config_changed self.config = config if gp.check_result(gp.gp_widget_get_readonly(config)): self.setDisabled(True) assert gp.check_result(gp.gp_widget_count_children(config)) == 0 value = gp.check_result(gp.gp_widget_get_value(config)) choice_count = gp.check_result(gp.gp_widget_count_choices(config)) for n in range(choice_count): choice = gp.check_result(gp.gp_widget_get_choice(config, n)) if choice: self.addItem(choice) if choice == value: self.setCurrentIndex(n) self.currentIndexChanged.connect(self.new_value)
def __init__(self, config_changed, config, parent=None): QtWidgets.QWidget.__init__(self, parent) self.config_changed = config_changed self.config = config if gp.check_result(gp.gp_widget_get_readonly(config)): self.setDisabled(True) assert gp.check_result(gp.gp_widget_count_children(config)) == 0 self.setLayout(QtWidgets.QHBoxLayout()) value = gp.check_result(gp.gp_widget_get_value(config)) self.buttons = [] for choice in gp.check_result(gp.gp_widget_get_choices(config)): if choice: button = QtWidgets.QRadioButton(choice) self.layout().addWidget(button) if choice == value: button.setChecked(True) self.buttons.append((button, choice)) button.clicked.connect(self.new_value)
def __init__(self, config_changed, config, parent=None): QtGui.QWidget.__init__(self, parent) self.config_changed = config_changed self.config = config if gp.check_result(gp.gp_widget_get_readonly(config)): self.setDisabled(True) assert gp.check_result(gp.gp_widget_count_children(config)) == 0 self.setLayout(QtGui.QHBoxLayout()) value = gp.check_result(gp.gp_widget_get_value(config)) self.buttons = [] for choice in gp.check_result(gp.gp_widget_get_choices(config)): if choice: button = QtGui.QRadioButton(choice) self.layout().addWidget(button) if choice == value: button.setChecked(True) self.buttons.append((button, choice)) button.clicked.connect(self.new_value)
def getConfig(child): global config_all new_object = {} label = gp.check_result(gp.gp_widget_get_label(child)) name = gp.check_result(gp.gp_widget_get_name(child)) label = '{} ({})'.format(label, name) new_object['name'] = name new_object['label'] = label config_all[name] = child child_type = gp.check_result(gp.gp_widget_get_type(child)) if child_type == gp.GP_WIDGET_SECTION: new_object['type'] = "SECTION" new_object['children'] = [] child_count = gp.check_result(gp.gp_widget_count_children(child)) for n in range(child_count): grand_child = gp.check_result(gp.gp_widget_get_child(child, n)) new_object['children'].append(getConfig(grand_child)) elif child_type == gp.GP_WIDGET_TEXT: new_object['type'] = "TEXT" if gp.check_result(gp.gp_widget_get_readonly(child)): new_object['disabled'] = True value = gp.check_result(gp.gp_widget_get_value(child)) new_object['value'] = value elif child_type == gp.GP_WIDGET_RANGE: new_object['type'] = "RANGE" if gp.check_result(gp.gp_widget_get_readonly(child)): new_object['disabled'] = True value = gp.check_result(gp.gp_widget_get_value(child)) new_object['value'] = value lo, hi, inc = gp.check_result(gp.gp_widget_get_range(child)) new_object['low'] = lo new_object['high'] = hi new_object['increment'] = inc elif child_type == gp.GP_WIDGET_TOGGLE: new_object['type'] = "TOGGLE" if gp.check_result(gp.gp_widget_get_readonly(child)): new_object['disabled'] = True value = gp.check_result(gp.gp_widget_get_value(child)) new_object['value'] = value elif child_type == gp.GP_WIDGET_RADIO: new_object['type'] = "RADIO" if gp.check_result(gp.gp_widget_get_readonly(child)): new_object['disabled'] = True value = gp.check_result(gp.gp_widget_get_value(child)) new_object['value'] = value choice_count = gp.check_result(gp.gp_widget_count_choices(child)) new_object['choices'] = [] for j in range(choice_count): choice = gp.check_result(gp.gp_widget_get_choice(child, j)) if choice: new_object['choices'].append(choice) elif child_type == gp.GP_WIDGET_MENU: new_object['type'] = "MENU" if gp.check_result(gp.gp_widget_get_readonly(child)): new_object['disabled'] = True elif child_type == gp.GP_WIDGET_DATE: new_object['type'] = "DATE" if gp.check_result(gp.gp_widget_get_readonly(child)): new_object['disabled'] = True value = gp.check_result(gp.gp_widget_get_value(child)) new_object['value'] = value else: print('Cannot make widget type %d for %s' % (child_type, label)) return new_object