def addSetting(self, owner, name, label=None, updateCallback=None): """ :param owner: setting owner :type owner: OWWidget or OWComponent :param name: setting name :type name: str :param label: setting label :type label: str or None """ # Label if label is None: label = '{}:'.format(name) # Field value = getdeepattr(owner, name) if isinstance(value, str): field = QtWidgets.QLineEdit() field.setText(value) if updateCallback: field.textChanged.connect(updateCallback) elif isinstance(value, numbers.Number): if isinstance(value, numbers.Integral): field = QtWidgets.QSpinBox() ma = sys.maxsize field.setRange(-ma - 1, ma) else: field = QtWidgets.QDoubleSpinBox() field.setValue(value) if updateCallback: field.valueChanged.connect(updateCallback) else: raise ValueError('{} does not have a Qt widget'.format( repr(type(value).__qualname__))) # Append policy = QtWidgets.QSizePolicy.Expanding field.setSizePolicy(policy, policy) self.layout().addRow(label, field) return field
def _init_layout(self): """Initialize widget layout.""" # Control area info_box = gui.widgetBox(self.controlArea, "Info", addSpace=True) self._info_label = gui.widgetLabel(info_box, "Initializing\n\n") indicator_filter_box = gui.widgetBox(self.controlArea, "Indicators", addSpace=True) gui.radioButtonsInBox(indicator_filter_box, self, "indicator_list_selection", self.indicator_list_map.values(), "Rows", callback=self.indicator_list_selected) self.indicator_list_selection = 2 gui.separator(indicator_filter_box) output_box = gui.widgetBox(self.controlArea, "Output", addSpace=True) gui.radioButtonsInBox(output_box, self, "output_type", ["Countries", "Time Series"], "Rows", callback=self.output_type_selected) self.output_type = 0 gui.separator(output_box) # pylint: disable=duplicate-code gui.auto_commit(self.controlArea, self, "auto_commit", "Commit", box="Commit") gui.rubber(self.controlArea) # Main area gui.widgetLabel(self.mainArea, "Filter") self.filter_text = QtWidgets.QLineEdit( textChanged=self.filter_indicator_list) self.completer = QtWidgets.QCompleter( caseSensitivity=QtCore.Qt.CaseInsensitive) self.completer.setModel(QtCore.QStringListModel(self)) self.filter_text.setCompleter(self.completer) spliter_v = QtWidgets.QSplitter(QtCore.Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.filter_text) self.mainArea.layout().addWidget(spliter_v) self.indicator_widget = IndicatorsTreeView(spliter_v, main_widget=self) splitter_h = QtWidgets.QSplitter(QtCore.Qt.Horizontal, spliter_v) self.description_box = gui.widgetBox(splitter_h, "Description") self.indicator_description = QtWidgets.QTextEdit() self.indicator_description.setReadOnly(True) self.description_box.layout().addWidget(self.indicator_description) box = gui.widgetBox(splitter_h, "Countries and Regions") self.country_tree = CountryTreeWidget( splitter_h, self.country_selection, default_select=True, default_colapse=True, ) box.layout().addWidget(self.country_tree) self.country_tree.set_data(countries.get_countries_regions_dict()) self.splitters = spliter_v, splitter_h for splitter, setting in zip(self.splitters, self.splitterSettings): splitter.splitterMoved.connect(self._splitter_moved) splitter.restoreState(setting) # self.resize(2000, 600) # why does this not work self.progressBarInit()