def __init__(self, s): QDialog.__init__(self) self.setModal(True) self.resize(600, 400) self.setWindowTitle(self.tr('Unit Test')) layout = QVBoxLayout() self.text = QTextEdit() self.text.setFontFamily("monospace") self.text.setEnabled(True) # Add two spaces in front of each text for faster copy/paste self.text.setText(' {}'.format(s.replace('\n', '\n '))) layout.addWidget(self.text) self.setLayout(layout) QMetaObject.connectSlotsByName(self)
def __init__(self, plugIn, parent, size, transparency, windowFlags=Qt.Widget): self.plugIn = plugIn self.size = size self.transparency = transparency QWidget.__init__(self, parent, windowFlags) self.edit1 = QTextEdit(self) self.edit1.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.edit1.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.edit1.insertPlainText("12.3456") self.edit1.setReadOnly(True) self.edit2 = QTextEdit(self) self.edit2.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.edit2.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.edit2.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.edit2.insertPlainText("78.9012") self.edit2.setReadOnly(True)
def __init__(self, item_widget): super().__init__(item_widget) self._item_widget = item_widget self._value_text_edit = QTextEdit() self._value_text_edit.setLineWrapMode(QTextEdit.WidgetWidth) self._value_text_edit.textChanged.connect(self._on_code_value_changed) self._exp_btn = QPushButton(self.tr('Insert expression...')) self._exp_btn.setIcon( QgsApplication.getThemeIcon('/mIconExpression.svg')) self._exp_btn.clicked.connect(self._on_insert_expression) layout = QVBoxLayout() layout.addWidget(self._value_text_edit) layout.addWidget(self._exp_btn) self.setLayout(layout)
def __init__(self): QDialog.__init__(self) self.bar_ = QgsMessageBar() self.bar_.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.setLayout(QGridLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok) self.buttonbox.accepted.connect(self.run) self.text_edit = QTextEdit() self.text_edit.setHtml( "<font color='grey' size='6'><green>PyQGIS PyQt!\nHello</font>") self.layout().addWidget(self.text_edit, 1, 0, -1, 1) self.layout().addWidget(self.buttonbox, 0, 0, 0, 1) self.layout().addWidget(self.bar_, 0, 0, 1, 1)
def get_widget_with_party_info_formatted(self, party_info): widget = QTextEdit() if party_info: html = list() html.append("<b>{}</b>".format( party_info[DICT_KEY_PARTY_T_NAME_F])) html.append("<i>{}</i>: <b>{}</b>".format( party_info[DICT_KEY_PARTY_T_DOCUMENT_TYPE_F], party_info[DICT_KEY_PARTY_T_DOCUMENT_ID_F])) html.append("<i>Derecho</i>: <b>{}</b>".format( party_info[DICT_KEY_PARTY_T_RIGHT])) widget.setHtml("<br>".join(html)) return widget
def setupUi(self): self.valueItems = {} self.dependentItems = {} self.resize(650, 450) self.buttonBox = QDialogButtonBox() self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.infoText = QTextEdit() numbers = self.getAvailableValuesOfType(ParameterNumber, OutputNumber) text = self.tr( 'You can refer to model values in your formula, using ' 'single-letter variables, as follows:\n', 'CalculatorModelerParametersDialog') ichar = 97 if numbers: for number in numbers: text += chr(ichar) + '->' + self.resolveValueDescription( number) + '\n' ichar += 1 else: text += self.tr('\n - No numerical variables are available.', 'CalculatorModelerParametersDialog') self.infoText.setText(text) self.infoText.setEnabled(False) self.formulaText = QLineEdit() if hasattr(self.formulaText, 'setPlaceholderText'): self.formulaText.setPlaceholderText( self.tr('[Enter your formula here]', 'CalculatorModelerParametersDialog')) if self._algName is not None: alg = self.model.algs[self._algName] self.formulaText.setText(alg.params[FORMULA]) self.setWindowTitle( self.tr('Calculator', 'CalculatorModelerParametersDialog')) self.verticalLayout = QVBoxLayout() self.verticalLayout.setSpacing(2) self.verticalLayout.setMargin(0) self.verticalLayout.addWidget(self.infoText) self.verticalLayout.addWidget(self.formulaText) self.verticalLayout.addWidget(self.buttonBox) self.setLayout(self.verticalLayout) self.buttonBox.accepted.connect(self.okPressed) self.buttonBox.rejected.connect(self.cancelPressed) QMetaObject.connectSlotsByName(self)
def __init__(self, text): super(TextEditorDialog, self).__init__() self.text = text self.resize(600, 350) self.setWindowFlags(self.windowFlags() | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint) self.setWindowTitle("Editor") layout = QVBoxLayout() buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.editor = QTextEdit() self.editor.setPlainText(text) layout.addWidget(self.editor) layout.addWidget(buttonBox) self.setLayout(layout) buttonBox.accepted.connect(self.okPressed) buttonBox.rejected.connect(self.cancelPressed)
def setupUi(self): type_metadata = QgsApplication.processingRegistry().parameterType(self.param.type() if self.param else self.paramType) self.setWindowTitle(self.tr('{} Parameter Definition').format(type_metadata.name())) self.mainLayout = QVBoxLayout() self.tab = QTabWidget() self.mainLayout.addWidget(self.tab) self.setMinimumWidth(300) self.verticalLayout = QVBoxLayout() self.label = QLabel(self.tr('Parameter name')) self.verticalLayout.addWidget(self.label) self.nameTextBox = QLineEdit() self.verticalLayout.addWidget(self.nameTextBox) if isinstance(self.param, QgsProcessingParameterDefinition): self.nameTextBox.setText(self.param.description()) if self.paramType == parameters.PARAMETER_TABLE_FIELD or \ isinstance(self.param, QgsProcessingParameterField): self.verticalLayout.addWidget(QLabel(self.tr('Parent layer'))) self.parentCombo = QComboBox() idx = 0 for param in list(self.alg.parameterComponents().values()): definition = self.alg.parameterDefinition(param.parameterName()) if isinstance(definition, (QgsProcessingParameterFeatureSource, QgsProcessingParameterVectorLayer)): self.parentCombo.addItem(definition.description(), definition.name()) if self.param is not None: if self.param.parentLayerParameterName() == definition.name(): self.parentCombo.setCurrentIndex(idx) idx += 1 self.verticalLayout.addWidget(self.parentCombo) # add the datatype selector self.verticalLayout.addWidget(QLabel(self.tr('Allowed data type'))) self.datatypeCombo = QComboBox() self.datatypeCombo.addItem(self.tr('Any'), -1) self.datatypeCombo.addItem(self.tr('Number'), 0) self.datatypeCombo.addItem(self.tr('String'), 1) self.datatypeCombo.addItem(self.tr('Date/time'), 2) self.verticalLayout.addWidget(self.datatypeCombo) if self.param is not None and self.param.dataType() is not None: # QComboBoxes indexes start at 0, # self.param.datatype start with -1 that is why I need to do +1 datatypeIndex = self.param.dataType() + 1 self.datatypeCombo.setCurrentIndex(datatypeIndex) self.multipleCheck = QCheckBox() self.multipleCheck.setText(self.tr('Accept multiple fields')) self.multipleCheck.setChecked(False) if self.param is not None: self.multipleCheck.setChecked(self.param.allowMultiple()) self.verticalLayout.addWidget(self.multipleCheck) self.verticalLayout.addWidget(QLabel(self.tr('Default value'))) self.defaultTextBox = QLineEdit() self.defaultTextBox.setToolTip( self.tr('Default field name, or ; separated list of field names for multiple field parameters')) if self.param is not None: default = self.param.defaultValue() if default is not None: self.defaultTextBox.setText(str(default)) self.verticalLayout.addWidget(self.defaultTextBox) elif self.paramType == parameters.PARAMETER_BAND or \ isinstance(self.param, QgsProcessingParameterBand): self.verticalLayout.addWidget(QLabel(self.tr('Parent layer'))) self.parentCombo = QComboBox() idx = 0 for param in list(self.alg.parameterComponents().values()): definition = self.alg.parameterDefinition(param.parameterName()) if isinstance(definition, (QgsProcessingParameterRasterLayer)): self.parentCombo.addItem(definition.description(), definition.name()) if self.param is not None: if self.param.parentLayerParameterName() == definition.name(): self.parentCombo.setCurrentIndex(idx) idx += 1 self.verticalLayout.addWidget(self.parentCombo) elif (self.paramType in ( parameters.PARAMETER_VECTOR, parameters.PARAMETER_TABLE) or isinstance(self.param, (QgsProcessingParameterFeatureSource, QgsProcessingParameterVectorLayer))): self.verticalLayout.addWidget(QLabel(self.tr('Geometry type'))) self.shapetypeCombo = QComboBox() self.shapetypeCombo.addItem(self.tr('Geometry Not Required'), QgsProcessing.TypeVector) self.shapetypeCombo.addItem(self.tr('Point'), QgsProcessing.TypeVectorPoint) self.shapetypeCombo.addItem(self.tr('Line'), QgsProcessing.TypeVectorLine) self.shapetypeCombo.addItem(self.tr('Polygon'), QgsProcessing.TypeVectorPolygon) self.shapetypeCombo.addItem(self.tr('Any Geometry Type'), QgsProcessing.TypeVectorAnyGeometry) if self.param is not None: self.shapetypeCombo.setCurrentIndex(self.shapetypeCombo.findData(self.param.dataTypes()[0])) self.verticalLayout.addWidget(self.shapetypeCombo) elif (self.paramType == parameters.PARAMETER_MULTIPLE or isinstance(self.param, QgsProcessingParameterMultipleLayers)): self.verticalLayout.addWidget(QLabel(self.tr('Data type'))) self.datatypeCombo = QComboBox() self.datatypeCombo.addItem(self.tr('Any Map Layer'), QgsProcessing.TypeMapLayer) self.datatypeCombo.addItem(self.tr('Vector (No Geometry Required)'), QgsProcessing.TypeVector) self.datatypeCombo.addItem(self.tr('Vector (Point)'), QgsProcessing.TypeVectorPoint) self.datatypeCombo.addItem(self.tr('Vector (Line)'), QgsProcessing.TypeVectorLine) self.datatypeCombo.addItem(self.tr('Vector (Polygon)'), QgsProcessing.TypeVectorPolygon) self.datatypeCombo.addItem(self.tr('Vector (Any Geometry Type)'), QgsProcessing.TypeVectorAnyGeometry) self.datatypeCombo.addItem(self.tr('Raster'), QgsProcessing.TypeRaster) self.datatypeCombo.addItem(self.tr('File'), QgsProcessing.TypeFile) if self.param is not None: self.datatypeCombo.setCurrentIndex(self.datatypeCombo.findData(self.param.layerType())) self.verticalLayout.addWidget(self.datatypeCombo) elif (self.paramType == parameters.PARAMETER_MAP_LAYER or isinstance(self.param, QgsProcessingParameterMapLayer)): self.verticalLayout.addWidget(QLabel(self.tr('Data type'))) self.datatypeCombo = QComboBox() self.datatypeCombo.addItem(self.tr('Any Map Layer'), QgsProcessing.TypeMapLayer) self.datatypeCombo.addItem(self.tr('Vector (Point)'), QgsProcessing.TypeVectorPoint) self.datatypeCombo.addItem(self.tr('Vector (Line)'), QgsProcessing.TypeVectorLine) self.datatypeCombo.addItem(self.tr('Vector (Polygon)'), QgsProcessing.TypeVectorPolygon) self.datatypeCombo.addItem(self.tr('Vector (Any Geometry Type)'), QgsProcessing.TypeVectorAnyGeometry) self.datatypeCombo.addItem(self.tr('Raster'), QgsProcessing.TypeRaster) self.datatypeCombo.addItem(self.tr('Mesh'), QgsProcessing.TypeMesh) if self.param is not None: self.datatypeCombo.setCurrentIndex(self.datatypeCombo.findData(self.param.dataTypes()[0])) self.verticalLayout.addWidget(self.datatypeCombo) elif (self.paramType in (parameters.PARAMETER_NUMBER, parameters.PARAMETER_DISTANCE, parameters.PARAMETER_SCALE) or isinstance(self.param, (QgsProcessingParameterNumber, QgsProcessingParameterDistance, QgsProcessingParameterScale))): if (self.paramType == parameters.PARAMETER_DISTANCE or isinstance(self.param, QgsProcessingParameterDistance)): self.verticalLayout.addWidget(QLabel(self.tr('Linked input'))) self.parentCombo = QComboBox() self.parentCombo.addItem('', '') idx = 1 for param in list(self.alg.parameterComponents().values()): definition = self.alg.parameterDefinition(param.parameterName()) if isinstance(definition, (QgsProcessingParameterFeatureSource, QgsProcessingParameterVectorLayer, QgsProcessingParameterMapLayer, QgsProcessingParameterCrs)): self.parentCombo.addItem(definition.description(), definition.name()) if self.param is not None: if self.param.parentParameterName() == definition.name(): self.parentCombo.setCurrentIndex(idx) idx += 1 self.verticalLayout.addWidget(self.parentCombo) elif (self.paramType != parameters.PARAMETER_SCALE and not isinstance(self.param, QgsProcessingParameterScale)): self.verticalLayout.addWidget(QLabel(self.tr('Number type'))) self.type_combo = QComboBox() self.type_combo.addItem(self.tr('Float'), QgsProcessingParameterNumber.Double) self.type_combo.addItem(self.tr('Integer'), QgsProcessingParameterNumber.Integer) if self.param: self.type_combo.setCurrentIndex(self.type_combo.findData(self.param.dataType())) self.verticalLayout.addWidget(self.type_combo) if (self.paramType != parameters.PARAMETER_SCALE and not isinstance(self.param, QgsProcessingParameterScale)): self.verticalLayout.addWidget(QLabel(self.tr('Min value'))) self.minTextBox = QLineEdit() self.verticalLayout.addWidget(self.minTextBox) self.verticalLayout.addWidget(QLabel(self.tr('Max value'))) self.maxTextBox = QLineEdit() self.verticalLayout.addWidget(self.maxTextBox) if self.param is not None: self.minTextBox.setText(str(self.param.minimum())) self.maxTextBox.setText(str(self.param.maximum())) self.verticalLayout.addWidget(QLabel(self.tr('Default value'))) self.defaultTextBox = QLineEdit() self.defaultTextBox.setText(self.tr('0')) if self.param is not None: default = self.param.defaultValue() if self.param.dataType() == QgsProcessingParameterNumber.Integer: default = int(math.floor(float(default))) if default: self.defaultTextBox.setText(str(default)) self.verticalLayout.addWidget(self.defaultTextBox) elif self.paramType == parameters.PARAMETER_ENUM or \ isinstance(self.param, QgsProcessingParameterEnum): self.widget = EnumModelerWidget(self) if self.param is not None: self.widget.setAllowMultiple(bool(self.param.allowMultiple())) self.widget.setOptions(self.param.options()) self.widget.setDefault(self.param.defaultValue()) self.verticalLayout.addWidget(self.widget) elif self.paramType == parameters.PARAMETER_MATRIX or \ isinstance(self.param, QgsProcessingParameterMatrix): self.widget = MatrixModelerWidget(self) if self.param is not None: self.widget.setValue(self.param.headers(), self.param.defaultValue()) self.widget.setFixedRows(self.param.hasFixedNumberRows()) self.verticalLayout.addWidget(self.widget) elif isinstance(self.param, QgsProcessingDestinationParameter): self.verticalLayout.addWidget(QLabel(self.tr('Default value'))) self.defaultWidget = QgsProcessingLayerOutputDestinationWidget(self.param, defaultSelection=True) self.verticalLayout.addWidget(self.defaultWidget) self.verticalLayout.addSpacing(20) self.requiredCheck = QCheckBox() self.requiredCheck.setText(self.tr('Mandatory')) self.requiredCheck.setChecked(True) if self.param is not None: self.requiredCheck.setChecked(not self.param.flags() & QgsProcessingParameterDefinition.FlagOptional) self.verticalLayout.addWidget(self.requiredCheck) self.advancedCheck = QCheckBox() self.advancedCheck.setText(self.tr('Advanced')) self.advancedCheck.setChecked(False) if self.param is not None: self.advancedCheck.setChecked(self.param.flags() & QgsProcessingParameterDefinition.FlagAdvanced) self.verticalLayout.addWidget(self.advancedCheck) # If child algorithm output is mandatory, disable checkbox if isinstance(self.param, QgsProcessingDestinationParameter): provider_name, child_name, output_name = self.param.name().split(':') child = self.alg.childAlgorithms()['{}:{}'.format(provider_name, child_name)] model_output = child.modelOutput(output_name) param_def = child.algorithm().parameterDefinition(model_output.childOutputName()) if not (param_def.flags() & QgsProcessingParameterDefinition.FlagOptional): self.requiredCheck.setEnabled(False) self.requiredCheck.setChecked(True) self.advancedCheck.setEnabled(False) self.advancedCheck.setChecked(False) self.verticalLayout.addStretch() w = QWidget() w.setLayout(self.verticalLayout) self.tab.addTab(w, self.tr('Properties')) self.commentLayout = QVBoxLayout() self.commentEdit = QTextEdit() self.commentEdit.setAcceptRichText(False) self.commentLayout.addWidget(self.commentEdit) w2 = QWidget() w2.setLayout(self.commentLayout) self.tab.addTab(w2, self.tr('Comments')) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.buttonBox.setObjectName('buttonBox') self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.mainLayout.addWidget(self.buttonBox) self.setLayout(self.mainLayout)
def setupUi(self): type_metadata = QgsApplication.processingRegistry().parameterType( self.param.type() if self.param else self.paramType) self.setWindowTitle( self.tr('{} Parameter Definition').format(type_metadata.name())) self.mainLayout = QVBoxLayout() self.tab = QTabWidget() self.mainLayout.addWidget(self.tab) self.setMinimumWidth(300) self.verticalLayout = QVBoxLayout() self.label = QLabel(self.tr('Parameter name')) self.verticalLayout.addWidget(self.label) self.nameTextBox = QLineEdit() self.verticalLayout.addWidget(self.nameTextBox) if isinstance(self.param, QgsProcessingParameterDefinition): self.nameTextBox.setText(self.param.description()) if isinstance(self.param, QgsProcessingDestinationParameter): self.verticalLayout.addWidget(QLabel(self.tr('Default value'))) self.defaultWidget = QgsProcessingLayerOutputDestinationWidget( self.param, defaultSelection=True) self.verticalLayout.addWidget(self.defaultWidget) self.verticalLayout.addSpacing(20) self.requiredCheck = QCheckBox() self.requiredCheck.setText(self.tr('Mandatory')) self.requiredCheck.setChecked(True) if self.param is not None: self.requiredCheck.setChecked( not self.param.flags() & QgsProcessingParameterDefinition.FlagOptional) self.verticalLayout.addWidget(self.requiredCheck) self.advancedCheck = QCheckBox() self.advancedCheck.setText(self.tr('Advanced')) self.advancedCheck.setChecked(False) if self.param is not None: self.advancedCheck.setChecked( self.param.flags() & QgsProcessingParameterDefinition.FlagAdvanced) self.verticalLayout.addWidget(self.advancedCheck) # If child algorithm output is mandatory, disable checkbox if isinstance(self.param, QgsProcessingDestinationParameter): child = self.alg.childAlgorithms()[self.param.metadata() ['_modelChildId']] model_output = child.modelOutput( self.param.metadata()['_modelChildOutputName']) param_def = child.algorithm().parameterDefinition( model_output.childOutputName()) if not (param_def.flags() & QgsProcessingParameterDefinition.FlagOptional): self.requiredCheck.setEnabled(False) self.requiredCheck.setChecked(True) self.advancedCheck.setEnabled(False) self.advancedCheck.setChecked(False) self.verticalLayout.addStretch() w = QWidget() w.setLayout(self.verticalLayout) self.tab.addTab(w, self.tr('Properties')) self.commentLayout = QVBoxLayout() self.commentEdit = QTextEdit() self.commentEdit.setAcceptRichText(False) self.commentLayout.addWidget(self.commentEdit, 1) hl = QHBoxLayout() hl.setContentsMargins(0, 0, 0, 0) hl.addWidget(QLabel(self.tr('Color'))) self.comment_color_button = QgsColorButton() self.comment_color_button.setAllowOpacity(True) self.comment_color_button.setWindowTitle(self.tr('Comment Color')) self.comment_color_button.setShowNull(True, self.tr('Default')) hl.addWidget(self.comment_color_button) self.commentLayout.addLayout(hl) w2 = QWidget() w2.setLayout(self.commentLayout) self.tab.addTab(w2, self.tr('Comments')) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.buttonBox.setObjectName('buttonBox') self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.mainLayout.addWidget(self.buttonBox) self.setLayout(self.mainLayout)
def construct_form_param_system(self, row, pos): widget = None for field in row[pos]['fields']: if field['label']: lbl = QLabel() lbl.setObjectName('lbl' + field['widgetname']) lbl.setText(field['label']) lbl.setMinimumSize(160, 0) lbl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) lbl.setToolTip(field['tooltip']) if field['widgettype'] == 'text' or field[ 'widgettype'] == 'linetext': widget = QLineEdit() widget.setText(field['value']) widget.editingFinished.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'textarea': widget = QTextEdit() widget.setText(field['value']) widget.editingFinished.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'combo': widget = QComboBox() self.populate_combo(widget, field) widget.currentIndexChanged.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'checkbox' or field[ 'widgettype'] == 'check': widget = QCheckBox() if field['value'].lower() == 'true': widget.setChecked(True) elif field['value'].lower() == 'FALSE': widget.setChecked(False) widget.stateChanged.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) elif field['widgettype'] == 'datepickertime': widget = QDateEdit() widget.setCalendarPopup(True) date = QDate.fromString(field['value'], 'yyyy/MM/dd') widget.setDate(date) widget.dateChanged.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'spinbox': widget = QDoubleSpinBox() if 'value' in field and field['value'] is not None: value = float(str(field['value'])) widget.setValue(value) widget.valueChanged.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) else: pass if widget: widget.setObjectName(field['widgetname']) else: pass # Order Widgets if field['layout_id'] == 1: self.order_widgets_system(field, self.basic_form, lbl, widget) elif field['layout_id'] == 2: self.order_widgets_system(field, self.om_form, lbl, widget) elif field['layout_id'] == 3: self.order_widgets_system(field, self.workcat_form, lbl, widget) elif field['layout_id'] == 4: self.order_widgets_system(field, self.mapzones_form, lbl, widget) elif field['layout_id'] == 5: self.order_widgets_system(field, self.cad_form, lbl, widget) elif field['layout_id'] == 6: self.order_widgets_system(field, self.epa_form, lbl, widget) elif field['layout_id'] == 7: self.order_widgets_system(field, self.masterplan_form, lbl, widget) elif field['layout_id'] == 8: self.order_widgets_system(field, self.other_form, lbl, widget) elif field['layout_id'] == 9: self.order_widgets_system(field, self.node_type_form, lbl, widget) elif field['layout_id'] == 10: self.order_widgets_system(field, self.cat_form, lbl, widget) elif field['layout_id'] == 11: self.order_widgets_system(field, self.utils_form, lbl, widget) elif field['layout_id'] == 12: self.order_widgets_system(field, self.connec_form, lbl, widget) elif field['layout_id'] == 13: self.order_widgets_system(field, self.topology_form, lbl, widget) elif field['layout_id'] == 14: self.order_widgets_system(field, self.builder_form, lbl, widget) elif field['layout_id'] == 15: self.order_widgets_system(field, self.review_form, lbl, widget) elif field['layout_id'] == 16: self.order_widgets_system(field, self.analysis_form, lbl, widget) elif field['layout_id'] == 17: self.order_widgets_system(field, self.system_form, lbl, widget)
def construct_form_param_system(self, row, pos): widget = None for field in row[pos]['fields']: if field['label']: lbl = QLabel() lbl.setObjectName('lbl' + field['widgetname']) lbl.setText(field['label']) lbl.setMinimumSize(160, 0) lbl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) lbl.setToolTip(field['tooltip']) if field['widgettype'] == 'text' or field[ 'widgettype'] == 'linetext': widget = QLineEdit() widget.setText(field['value']) widget.editingFinished.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'textarea': widget = QTextEdit() widget.setText(field['value']) widget.editingFinished.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'combo': widget = QComboBox() self.populate_combo(widget, field) widget.currentIndexChanged.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'checkbox' or field[ 'widgettype'] == 'check': widget = QCheckBox() if field['value'] in ('true', 'True', 'TRUE', True): widget.setChecked(True) elif field['value'] in ('false', 'False', 'FALSE', False): widget.setChecked(False) widget.stateChanged.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) elif field['widgettype'] == 'datetime': widget = QDateEdit() widget.setCalendarPopup(True) if field['value']: field['value'] = field['value'].replace('/', '-') date = QDate.fromString(field['value'], 'yyyy-MM-dd') widget.setDate(date) widget.dateChanged.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'spinbox': widget = QSpinBox() if 'value' in field and field['value'] is not None: value = float(str(field['value'])) widget.setValue(value) widget.valueChanged.connect( partial(self.get_values_changed_param_system, widget)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) else: pass if widget: widget.setObjectName(field['widgetname']) else: pass # Order Widgets if 'layoutname' in field: if field['layoutname'] == 'lyt_topology': self.order_widgets_system(field, self.topology_form, lbl, widget) elif field['layoutname'] == 'lyt_builder': self.order_widgets_system(field, self.builder_form, lbl, widget) elif field['layoutname'] == 'lyt_review': self.order_widgets_system(field, self.review_form, lbl, widget) elif field['layoutname'] == 'lyt_analysis': self.order_widgets_system(field, self.analysis_form, lbl, widget) elif field['layoutname'] == 'lyt_system': self.order_widgets_system(field, self.system_form, lbl, widget)
def construct_form_param_user(self, row, pos): widget = None for field in row[pos]['fields']: if field['label']: lbl = QLabel() lbl.setObjectName('lbl' + field['widgetname']) lbl.setText(field['label']) lbl.setMinimumSize(160, 0) lbl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) lbl.setToolTip(field['tooltip']) chk = QCheckBox() chk.setObjectName('chk_' + field['widgetname']) if field['checked'] in ('true', 'True', 'TRUE', True): chk.setChecked(True) elif field['checked'] in ('false', 'False', 'FALSE', False): chk.setChecked(False) chk.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) if field['widgettype'] == 'text' or field[ 'widgettype'] == 'linetext' or field[ 'widgettype'] == 'typeahead': widget = QLineEdit() widget.setText(field['value']) widget.editingFinished.connect( partial(self.get_values_changed_param_user, chk, widget, field)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) if field['widgettype'] == 'typeahead': completer = QCompleter() if 'dv_querytext' in field or 'dv_querytext_filterc' in field: widget.setProperty('typeahead', True) model = QStringListModel() widget.textChanged.connect( partial(self.populate_typeahead, completer, model, field, self.dlg_config, widget)) elif field['widgettype'] == 'textarea': widget = QTextEdit() widget.setText(field['value']) widget.editingFinished.connect( partial(self.get_values_changed_param_user, chk, widget, field)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'combo': widget = QComboBox() self.populate_combo(widget, field) widget.currentIndexChanged.connect( partial(self.get_values_changed_param_user, chk, widget, field)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'check': widget = chk widget.stateChanged.connect( partial(self.get_values_changed_param_user, chk, chk, field)) widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) elif field['widgettype'] == 'datetime': widget = QgsDateTimeEdit() widget.setAllowNull(True) widget.setCalendarPopup(True) widget.setDisplayFormat('dd/MM/yyyy') if field['value']: field['value'] = field['value'].replace('/', '-') date = QDate.fromString(field['value'], 'yyyy-MM-dd') if date: widget.setDate(date) else: widget.clear() widget.dateChanged.connect( partial(self.get_values_changed_param_user, chk, widget, field)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'spinbox': widget = QDoubleSpinBox() if 'value' in field and field['value'] is not None: value = float(str(field['value'])) widget.setValue(value) widget.valueChanged.connect( partial(self.get_values_changed_param_user, chk, widget, field)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) else: pass widget.setObjectName(field['widgetname']) # Set signals chk.stateChanged.connect( partial(self.get_values_checked_param_user, chk, widget, field)) if field['layoutname'] == 'lyt_basic': self.order_widgets(field, self.basic_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_om': self.order_widgets(field, self.om_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_inventory': self.order_widgets(field, self.inventory_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_mapzones': self.order_widgets(field, self.mapzones_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_edit': self.order_widgets(field, self.cad_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_epa': self.order_widgets(field, self.epa_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_masterplan': self.order_widgets(field, self.masterplan_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_other': self.order_widgets(field, self.other_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_node_vdef': self.order_widgets(field, self.node_type_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_arc_vdef': self.order_widgets(field, self.cat_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_utils_vdef': self.order_widgets(field, self.utils_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_connec_vdef': self.order_widgets(field, self.connec_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_gully_vdef': self.order_widgets(field, self.gully_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_fluid_type': self.order_widgets(field, self.fluid_type_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_location_type': self.order_widgets(field, self.location_type_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_category_type': self.order_widgets(field, self.category_type_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_function_type': self.order_widgets(field, self.function_type_form, lbl, chk, widget) elif field['layoutname'] == 'lyt_addfields': self.order_widgets(field, self.addfields_form, lbl, chk, widget)
def _build_dialog_options(self, row, tab): self.tab = tab for field in row['fields']: try: widget = None self.chk = None if field['label']: lbl = QLabel() lbl.setObjectName('lbl' + field['widgetname']) lbl.setText(field['label']) lbl.setMinimumSize(160, 0) lbl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) lbl.setToolTip(field['tooltip']) if self.tab == 'user': self.chk = QCheckBox() self.chk.setObjectName('chk_' + field['widgetname']) if field['checked'] in ('true', 'True', 'TRUE', True): self.chk.setChecked(True) elif field['checked'] in ('false', 'False', 'FALSE', False): self.chk.setChecked(False) self.chk.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) if field['widgettype'] in ('text', 'linetext', 'typeahead'): widget = QLineEdit() widget.setText(field['value']) widget.editingFinished.connect( partial(self._get_dialog_changed_values, widget, self.tab, self.chk)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) if field['widgettype'] == 'typeahead': completer = QCompleter() if 'dv_querytext' in field: widget.setProperty('typeahead', True) model = QStringListModel() widget.textChanged.connect( partial(self.populate_typeahead, completer, model, field, self.dlg_config, widget)) elif field['widgettype'] == 'textarea': widget = QTextEdit() widget.setText(field['value']) widget.editingFinished.connect( partial(self._get_dialog_changed_values, widget, self.tab, self.chk)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'combo': widget = QComboBox() self._fill_combo(widget, field) widget.currentIndexChanged.connect( partial(self._get_dialog_changed_values, widget, self.tab, self.chk)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'check': self.chk = QCheckBox() self.chk.setObjectName(field['widgetname']) if self.tab == 'user' and field['checked'] in ( 'true', 'True', 'TRUE', True): self.chk.setChecked(True) elif self.tab == 'user' and field['checked'] in ( 'false', 'False', 'FALSE', False): self.chk.setChecked(False) elif field['value'] in ('true', 'True', 'TRUE', True): self.chk.setChecked(True) elif field['value'] in ('false', 'False', 'FALSE', False): self.chk.setChecked(False) self.chk.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.chk.stateChanged.connect( partial(self._get_dialog_changed_values, self.chk, self.tab, self.chk)) elif field['widgettype'] == 'datetime': widget = QgsDateTimeEdit() widget.setAllowNull(True) widget.setCalendarPopup(True) widget.setDisplayFormat('dd/MM/yyyy') if global_vars.date_format in ("dd/MM/yyyy", "dd-MM-yyyy", "yyyy/MM/dd", "yyyy-MM-dd"): widget.setDisplayFormat(global_vars.date_format) if field['value']: field['value'] = field['value'].replace('/', '-') date = QDate.fromString(field['value'], 'yyyy-MM-dd') if date: widget.setDate(date) else: widget.clear() widget.valueChanged.connect( partial(self._get_dialog_changed_values, widget, self.tab, self.chk)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) elif field['widgettype'] == 'spinbox': widget = QDoubleSpinBox() if 'value' in field and field['value'] is not None: value = float(str(field['value'])) widget.setValue(value) widget.valueChanged.connect( partial(self._get_dialog_changed_values, widget, self.tab, self.chk)) widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) if widget: widget.setObjectName(field['widgetname']) # Set signals if self.tab == 'user' and widget is not None: self.chk.stateChanged.connect( partial(self._get_dialog_changed_values, widget, self.tab, self.chk)) if widget is None: widget = self.chk self._order_widgets(field, lbl, widget) except Exception as e: msg = f"{type(e).__name__} {e}. widgetname='{field['widgetname']}' AND widgettype='{field['widgettype']}'" tools_qgis.show_message(msg, 2)
def setupUi(self): self.checkBoxes = {} self.showAdvanced = False self.wrappers = {} self.valueItems = {} self.dependentItems = {} self.algorithmItem = None self.resize(650, 450) self.mainLayout = QVBoxLayout() self.tab = QTabWidget() self.mainLayout.addWidget(self.tab) self.buttonBox = QDialogButtonBox() self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok | QDialogButtonBox.Help) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.verticalLayout = QVBoxLayout() self.verticalLayout.setSpacing(5) self.bar = QgsMessageBar() self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.verticalLayout.addWidget(self.bar) hLayout = QHBoxLayout() hLayout.setSpacing(5) hLayout.setMargin(0) descriptionLabel = QLabel(self.tr("Description")) self.descriptionBox = QLineEdit() self.descriptionBox.setText(self._alg.displayName()) hLayout.addWidget(descriptionLabel) hLayout.addWidget(self.descriptionBox) self.verticalLayout.addLayout(hLayout) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) self.verticalLayout.addWidget(line) widget_context = QgsProcessingParameterWidgetContext() widget_context.setProject(QgsProject.instance()) if iface is not None: widget_context.setMapCanvas(iface.mapCanvas()) widget_context.setModel(self.model) widget_context.setModelChildAlgorithmId(self.childId) self.algorithmItem = QgsGui.instance().processingGuiRegistry().algorithmConfigurationWidget(self._alg) if self.algorithmItem: self.algorithmItem.setWidgetContext(widget_context) self.algorithmItem.registerProcessingContextGenerator(self.context_generator) if self.configuration: self.algorithmItem.setConfiguration(self.configuration) self.verticalLayout.addWidget(self.algorithmItem) for param in self._alg.parameterDefinitions(): if param.flags() & QgsProcessingParameterDefinition.FlagAdvanced: self.advancedButton = QPushButton() self.advancedButton.setText(self.tr('Show advanced parameters')) self.advancedButton.clicked.connect( self.showAdvancedParametersClicked) advancedButtonHLayout = QHBoxLayout() advancedButtonHLayout.addWidget(self.advancedButton) advancedButtonHLayout.addStretch() self.verticalLayout.addLayout(advancedButtonHLayout) break for param in self._alg.parameterDefinitions(): if param.isDestination() or param.flags() & QgsProcessingParameterDefinition.FlagHidden: continue wrapper = WidgetWrapperFactory.create_wrapper(param, self) self.wrappers[param.name()] = wrapper wrapper.setWidgetContext(widget_context) wrapper.registerProcessingContextGenerator(self.context_generator) if issubclass(wrapper.__class__, QgsProcessingModelerParameterWidget): widget = wrapper else: widget = wrapper.widget if widget is not None: self.valueItems[param.name()] = widget if issubclass(wrapper.__class__, QgsProcessingModelerParameterWidget): label = wrapper.createLabel() else: tooltip = param.description() widget.setToolTip(tooltip) label = wrapper.label self.widget_labels[param.name()] = label if param.flags() & QgsProcessingParameterDefinition.FlagAdvanced: label.setVisible(self.showAdvanced) widget.setVisible(self.showAdvanced) self.verticalLayout.addWidget(label) self.verticalLayout.addWidget(widget) for dest in self._alg.destinationParameterDefinitions(): if dest.flags() & QgsProcessingParameterDefinition.FlagHidden: continue if isinstance(dest, (QgsProcessingParameterRasterDestination, QgsProcessingParameterVectorDestination, QgsProcessingParameterFeatureSink, QgsProcessingParameterFileDestination, QgsProcessingParameterFolderDestination)): label = QLabel(dest.description()) item = QgsFilterLineEdit() if hasattr(item, 'setPlaceholderText'): item.setPlaceholderText(self.tr('[Enter name if this is a final result]')) self.verticalLayout.addWidget(label) self.verticalLayout.addWidget(item) self.valueItems[dest.name()] = item label = QLabel(' ') self.verticalLayout.addWidget(label) label = QLabel(self.tr('Parent algorithms')) self.dependenciesPanel = self.getDependenciesPanel() self.verticalLayout.addWidget(label) self.verticalLayout.addWidget(self.dependenciesPanel) self.verticalLayout.addStretch(1000) self.setPreviousValues() self.setWindowTitle(self._alg.displayName()) self.verticalLayout2 = QVBoxLayout() self.verticalLayout2.setSpacing(2) self.verticalLayout2.setMargin(0) self.paramPanel = QWidget() self.paramPanel.setLayout(self.verticalLayout) self.scrollArea = QgsScrollArea() self.scrollArea.setWidget(self.paramPanel) self.scrollArea.setWidgetResizable(True) self.verticalLayout2.addWidget(self.scrollArea) self.buttonBox.accepted.connect(self.okPressed) self.buttonBox.rejected.connect(self.cancelPressed) self.buttonBox.helpRequested.connect(self.openHelp) w = QWidget() w.setLayout(self.verticalLayout2) self.tab.addTab(w, self.tr('Properties')) self.commentLayout = QVBoxLayout() self.commentEdit = QTextEdit() self.commentEdit.setAcceptRichText(False) self.commentLayout.addWidget(self.commentEdit) w2 = QWidget() w2.setLayout(self.commentLayout) self.tab.addTab(w2, self.tr('Comments')) self.mainLayout.addWidget(self.buttonBox) self.setLayout(self.mainLayout) QMetaObject.connectSlotsByName(self)
def __init__(self, url_base): QMainWindow.__init__(self) # creating map canvas, which draws the maplayers # setting up features like canvas color self.canvas = QgsMapCanvas() self.canvas.setMinimumSize(550, 700) self.canvas.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.canvas.setCanvasColor(Qt.white) #self.canvas.enableAntiAliasing(True) self.url_base = url_base # Qmainwindow requires a central widget. Canvas is placed self.setCentralWidget(self.canvas) """'tile widths' refer to the Map proxy WMTS server's settings for displaying data of different resolutions. If I understood correctly, these values (got by examining properties of a layer from that server in QGIS) are the thresholds at which a different resolution is loaded on the GRIDI-FIN tileset. The values represent the tile size in map units (meters). Each tile widths is tied to the corresponding resolution, which is used to get the correct resolution legend info. The method is only an estimation, but ought to produce good enough results for this purpose. Smallest resolutions (1, 2, 5) are omitted since only some layers have them. """ self.tile_widths = { 2560: 10, 5120: 20, 12800: 50, 25600: 100, 51200: 200, 128000: 500, 256000: 1000 } # get all keys i.e. widths self.all_widths = [i for i in self.tile_widths] # creating background layer box and housing it with the hardcoded options self.bg_layer_box = QComboBox() # if ortokuva ever updates to newer versions, just change the year here bg_layers = ['Taustakartta', 'Ortokuva_2018', 'No reference layer'] # set 'No reference layer' as the default option self.bg_layer_box.addItems(layer for layer in bg_layers) self.bg_layer_box.setCurrentIndex(2) self.bg_layer_box.currentIndexChanged.connect(self.addBackgroundLayer) # initialize the slider that will control BG layer opacity/transparency self.opacity_slider = QSlider(Qt.Horizontal) self.opacity_slider.setMinimum(0) self.opacity_slider.setMaximum(100) self.opacity_slider.setSingleStep(1) self.opacity_slider.setMaximumWidth(100) self.opacity_slider.valueChanged.connect(self.setBackgroundMapOpacity) self.legend_checkbox = QCheckBox("Get attribute info on all layers") # explanatory texts for the different widgets are stored as label widgets bg_layer_label = QLabel(" Background: ") bg_opacity_label = QLabel(" BG opacity: ") data_label = QLabel("Data: ") spacing = QLabel(" ") # all of the data layers are housed in this combobox self.layer_box = QComboBox() self.layer_box.currentIndexChanged.connect(self.addLayer) # creating each desired action self.actionPan = QAction("Pan tool", self) self.actionLegend = QAction("Attribute info tool", self) self.actionCancel = QAction("Close window", self) self.actionZoom = QAction("Zoom to full extent", self) # these two work as on/off. the rest are clickable self.actionPan.setCheckable(True) self.actionLegend.setCheckable(True) # when actions are clicked, do corresponding function self.actionPan.triggered.connect(self.pan) self.actionLegend.triggered.connect(self.info) self.actionCancel.triggered.connect(self.cancel) self.actionZoom.triggered.connect(self.zoomToExtent) # defining two toolbars: first one houses layer and opacity selection # the other has all the tools and functions self.layers_toolbar = self.addToolBar("Select layers") self.layers_toolbar.setContextMenuPolicy(Qt.PreventContextMenu) self.layers_toolbar.setMovable(False) self.addToolBarBreak() self.tools_toolbar = self.addToolBar("Tools") self.tools_toolbar.setContextMenuPolicy(Qt.PreventContextMenu) self.tools_toolbar.setMovable(False) # change order here to change their placement on window # starting with the layer widgets and the corresponding label texts self.layers_toolbar.addWidget(data_label) self.layers_toolbar.addWidget(self.layer_box) self.layers_toolbar.addWidget(bg_layer_label) self.layers_toolbar.addWidget(self.bg_layer_box) self.layers_toolbar.addWidget(bg_opacity_label) self.layers_toolbar.addWidget(self.opacity_slider) self.layers_toolbar.addWidget(spacing) self.layers_toolbar.addWidget(self.legend_checkbox) # then setting all the canvas tools on the second toolbar self.tools_toolbar.addAction(self.actionLegend) self.tools_toolbar.addAction(self.actionPan) self.tools_toolbar.addAction(self.actionZoom) self.tools_toolbar.addAction(self.actionCancel) # a large text box that will house the legend info self.text_browser = QTextEdit("Legend will be shown here") self.text_browser.setReadOnly(True) # a dock widget is required for the text browser. Docked to main window dock_widget = QDockWidget() dock_widget.setFeatures(QDockWidget.NoDockWidgetFeatures) dock_widget.setWindowTitle("Legend") dock_widget.setWidget(self.text_browser) self.addDockWidget(Qt.RightDockWidgetArea, dock_widget) # link actions to premade map tools self.toolPan = QgsMapToolPan(self.canvas) self.toolPan.setAction(self.actionPan) self.toolClick = QgsMapToolEmitPoint(self.canvas) self.toolClick.canvasClicked.connect(self.getLegendInfo) # this is to ensure that the map isn't zoomed out everytime the layer changes self.first_start = True # this boolean is true while there is no active background layer # needed to ensure that e.g. opacity isn't attempted to be set on a nonexisting layer self.no_bg_layer_flag = True # set pantool as default self.pan()
def _create_widget(cls, c, parent, host=None): te = QTextEdit(parent) te.setObjectName('{0}_{1}'.format(cls._TYPE_PREFIX, c.name)) return te