示例#1
0
 def __init__(self, iface):
     QDialog.__init__(self, iface.mainWindow())
     self.workerThread = None
     self.state = False
     self.resultStatus = None
     self.doReRun = False
     self.wasCanceled = False
     self.wasSuccessful = False
     self.savedProj = None
     self.result = None
     self.messageTxt = {
         'msg_optimierung': self.tr('Berechnung der optimalen Stuetzenpositionen...'),
         'msg_seillinie': self.tr('Berechnung der optimale Seillinie...')
     }
     
     # Build GUI Elements
     self.setWindowTitle(self.tr("SEILAPLAN wird ausgefuehrt"))
     self.resize(500, 100)
     self.container = QVBoxLayout()
     self.progressBar = QProgressBar(self)
     self.progressBar.setMinimumWidth(500)
     self.statusLabel = QLabel(self)
     self.hbox = QHBoxLayout()
     self.cancelButton = QDialogButtonBox()
     self.closeButton = QDialogButtonBox()
     self.resultLabel = QLabel(self)
     self.resultLabel.setMaximumWidth(500)
     self.resultLabel.setSizePolicy(
         QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding))
     self.resultLabel.setWordWrap(True)
     spacer1 = QSpacerItem(20, 20, QSizePolicy.Fixed,
                           QSizePolicy.Fixed)
     self.rerunButton = QPushButton(self.tr("zurueck zum Startfenster"))
     self.rerunButton.setVisible(False)
     spacer2 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                          QSizePolicy.Minimum)
     self.cancelButton.setStandardButtons(QDialogButtonBox.Cancel)
     self.cancelButton.button(QDialogButtonBox.Cancel).setText(self.tr("Abbrechen"))
     self.cancelButton.clicked.connect(self.onAbort)
     self.closeButton.setStandardButtons(QDialogButtonBox.Close)
     self.closeButton.button(QDialogButtonBox.Close).setText(self.tr("Schliessen"))
     self.closeButton.clicked.connect(self.onClose)
     self.hbox.addWidget(self.rerunButton)
     self.hbox.addItem(spacer2)
     self.hbox.addWidget(self.cancelButton)
     self.hbox.setAlignment(self.cancelButton, Qt.AlignHCenter)
     self.hbox.addWidget(self.closeButton)
     self.hbox.setAlignment(self.closeButton, Qt.AlignHCenter)
     self.closeButton.hide()
     
     self.container.addWidget(self.progressBar)
     self.container.addWidget(self.statusLabel)
     self.container.addWidget(self.resultLabel)
     self.container.addItem(spacer1)
     self.container.addLayout(self.hbox)
     self.container.setSizeConstraint(QLayout.SetFixedSize)
     self.setLayout(self.container)
    def go2epa_options(self):
        """ Button 23: Open form to set INP, RPT and project """

        # Clear list
        self.epa_options_list = []

        # Create dialog
        self.dlg_options = Go2EpaOptionsUi()
        load_settings(self.dlg_options)

        form = '"formName":"epaoptions"'
        body = create_body(form=form)
        json_result = self.controller.get_json('gw_fct_getconfig', body)
        if not json_result:
            return False

        construct_form_param_user(
            self.dlg_options, json_result['body']['form']['formTabs'], 0, self.epa_options_list)
        grbox_list = self.dlg_options.findChildren(QGroupBox)
        for grbox in grbox_list:
            widget_list = grbox.findChildren(QWidget)
            if len(widget_list) == 0:
                grbox.setVisible(False)
            else:
                gridlist = grbox.findChildren(QGridLayout)
                for grl in gridlist:
                    spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
                    grl.addItem(spacer)

        # Event on change from combo parent
        self.get_event_combo_parent(json_result)
        self.dlg_options.btn_accept.clicked.connect(partial(self.update_values, self.epa_options_list))
        self.dlg_options.btn_cancel.clicked.connect(partial(close_dialog, self.dlg_options))

        open_dialog(self.dlg_options, dlg_name='go2epa_options')
示例#3
0
    def __init__(self, parent=None):
        """Constructor."""
        super(TheWidgetItem, self).__init__(parent)

        self.setupUi(self)

        self.labels = [
            self.lblPlt1, self.lblPlt2, self.lblPlt3, self.lblPlt4,
            self.lblPlt5, self.lblPlt6
        ]

        self.textQVBoxLayout = QVBoxLayout()
        self.allQHBoxLayout = QHBoxLayout()
        verticalSpacer = QSpacerItem(0, 70, QSizePolicy.Minimum,
                                     QSizePolicy.Expanding)
        self.textQVBoxLayout.addItem(verticalSpacer)
        self.allQHBoxLayout.addLayout(self.textQVBoxLayout)
        self.route_id = -1
        self.setLayout(self.allQHBoxLayout)
        if sys.platform == "linux2":
            for label in self.labels:
                label.setFont(QtGui.QFont('SansSerif', 10))
        if sys.platform == "win32":
            for label in self.labels:
                label.setFont(QtGui.QFont('Arial', 9))
    def open_form(self, new_feature=None, layer=None, new_feature_id=None):
        self.dlg_dim = ApiDimensioningUi()
        self.load_settings(self.dlg_dim)

        # Set signals
        actionSnapping = self.dlg_dim.findChild(QAction, "actionSnapping")
        actionSnapping.triggered.connect(partial(self.snapping, actionSnapping))
        self.set_icon(actionSnapping, "103")

        actionOrientation = self.dlg_dim.findChild(QAction, "actionOrientation")
        actionOrientation.triggered.connect(partial(self.orientation, actionOrientation))
        self.set_icon(actionOrientation, "133")

        self.dlg_dim.btn_accept.clicked.connect(partial(self.save_dimensioning, new_feature, layer))
        self.dlg_dim.btn_cancel.clicked.connect(partial(self.cancel_dimensioning))
        self.dlg_dim.dlg_closed.connect(partial(self.cancel_dimensioning))
        self.dlg_dim.dlg_closed.connect(partial(self.save_settings, self.dlg_dim))

        # Set layers dimensions, node and connec
        self.layer_dimensions = self.controller.get_layer_by_tablename("v_edit_dimensions")
        self.layer_node = self.controller.get_layer_by_tablename("v_edit_node")
        self.layer_connec = self.controller.get_layer_by_tablename("v_edit_connec")

        self.create_map_tips()
        body = self.create_body()
        # Get layers under mouse clicked
        sql = f"SELECT gw_api_getdimensioning($${{{body}}}$$)::text"
        row = self.controller.get_row(sql, log_sql=True, commit=True)

        if row is None or row[0] is None:
            self.controller.show_message("NOT ROW FOR: " + sql, 2)
            return False
        # Parse string to order dict into List
        complet_result = [json.loads(row[0],  object_pairs_hook=OrderedDict)]

        layout_list = []
        for field in complet_result[0]['body']['data']['fields']:
            label, widget = self.set_widgets(self.dlg_dim, complet_result, field)

            if widget.objectName() == 'id':
                utils_giswater.setWidgetText(self.dlg_dim, widget, new_feature_id)
            layout = self.dlg_dim.findChild(QGridLayout, field['layoutname'])
           # Take the QGridLayout with the intention of adding a QSpacerItem later
            if layout not in layout_list and layout.objectName() not in ('top_layout', 'bot_layout_1', 'bot_layout_2'):
                layout_list.append(layout)

            # Add widgets into layout
            if field['layoutname'] in ('top_layout', 'bot_layout_1', 'bot_layout_2'):
                layout.addWidget(label, 0, field['layout_order'])
                layout.addWidget(widget, 1, field['layout_order'])
            else:
                self.put_widgets(self.dlg_dim, field, label, widget)

        # Add a QSpacerItem into each QGridLayout of the list
        for layout in layout_list:
            vertical_spacer1 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
            layout.addItem(vertical_spacer1)

        self.open_dialog(self.dlg_dim)
        return False, False
示例#5
0
    def __init__(self, options, multiple, columns=2, parent=None):
        super(CheckboxesPanel, self).__init__(parent)

        self._options = []
        for i, option in enumerate(options):
            if isinstance(option, str):
                self._options.append((i, option))
            else:
                self.options.append(option)
        self._multiple = multiple
        self._buttons = []
        rows = len(options) / columns

        self._buttonGroup = QButtonGroup()
        self._buttonGroup.setExclusive(not multiple)
        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setMargin(0)
        for i, (v, t) in enumerate(self._options):
            if multiple:
                button = QCheckBox(t)
            else:
                button = QRadioButton(t)
            self._buttons.append((v, button))
            self._buttonGroup.addButton(button, i)
            layout.addWidget(button, i % rows, i / rows)
        layout.addItem(
            QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum), 0,
            columns)
        self.setLayout(layout)

        if multiple:
            self.setContextMenuPolicy(Qt.CustomContextMenu)
            self.customContextMenuRequested.connect(self.showPopupMenu)
示例#6
0
    def __init__(self, parent=None):
        super(ShellOutputScintilla, self).__init__(parent)
        self.parent = parent
        self.shell = self.parent.shell

        self.settings = QgsSettings()

        # Creates layout for message bar
        self.layout = QGridLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)
        spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        self.layout.addItem(spacerItem, 1, 0, 1, 1)
        # messageBar instance
        self.infoBar = QgsMessageBar()
        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.infoBar.setSizePolicy(sizePolicy)
        self.layout.addWidget(self.infoBar, 0, 0, 1, 1)

        # Enable non-ascii chars for editor
        self.setUtf8(True)

        sys.stdout = writeOut(self, sys.stdout)
        sys.stderr = writeOut(self, sys.stderr, "_traceback")

        self.insertInitText()
        self.refreshSettingsOutput()
        self.setReadOnly(True)

        # Set the default font
        font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.setFont(font)
        self.setMarginsFont(font)
        # Margin 0 is used for line numbers
        self.setMarginWidth(0, 0)
        self.setMarginWidth(1, 0)
        self.setMarginWidth(2, 0)
        #fm = QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(1, "00000")
        self.setMarginLineNumbers(1, True)
        self.setMarginsForegroundColor(QColor("#3E3EE3"))
        self.setMarginsBackgroundColor(QColor("#f9f9f9"))
        self.setCaretLineVisible(True)
        self.setCaretWidth(0)

        self.setMinimumHeight(120)

        self.setWrapMode(QsciScintilla.WrapCharacter)
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

        self.runScut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
        self.runScut.setContext(Qt.WidgetShortcut)
        self.runScut.activated.connect(self.enteredSelected)
        # Reimplemented copy action to prevent paste prompt (>>>,...) in command view
        self.copyShortcut = QShortcut(QKeySequence.Copy, self)
        self.copyShortcut.activated.connect(self.copy)
        self.selectAllShortcut = QShortcut(QKeySequence.SelectAll, self)
        self.selectAllShortcut.activated.connect(self.selectAll)
示例#7
0
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(
            QtCore.QSize(QtCore.QRect(0, 0, 440, 660).size()).expandedTo(
                Dialog.minimumSizeHint()))

        self.gridlayout = QGridLayout(Dialog)
        self.gridlayout.setObjectName("gridlayout")

        font = QFont()
        font.setPointSize(15)
        font.setWeight(50)
        font.setBold(True)

        self.label_2 = QLabel(Dialog)
        self.label_2.setFont(font)
        self.label_2.setTextFormat(QtCore.Qt.RichText)
        self.label_2.setObjectName("label_2")
        self.gridlayout.addWidget(self.label_2, 1, 1, 1, 2)

        self.textEdit = QTextEdit(Dialog)

        palette = QPalette()

        brush = QBrush(QColor(0, 0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Base, brush)

        brush = QBrush(QColor(0, 0, 0, 0))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QPalette.Inactive, QPalette.Base, brush)

        brush = QBrush(QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QPalette.Disabled, QPalette.Base, brush)
        self.textEdit.setPalette(palette)
        self.textEdit.setAutoFillBackground(True)
        self.textEdit.width = 320
        self.textEdit.height = 360
        self.textEdit.setFrameShape(QFrame.NoFrame)
        self.textEdit.setFrameShadow(QFrame.Plain)
        self.textEdit.setReadOnly(True)
        self.textEdit.setObjectName("textEdit")
        self.textEdit.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)

        self.gridlayout.addWidget(self.textEdit, 2, 1, 5, 2)

        self.pushButton = QPushButton(Dialog)
        self.pushButton.setObjectName("pushButton")
        self.gridlayout.addWidget(self.pushButton, 4, 2, 1, 1)

        spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        self.gridlayout.addItem(spacerItem, 3, 1, 1, 1)

        self.retranslateUi(Dialog)
        self.pushButton.clicked.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
示例#8
0
    def setupUi(self):
        '''
        set up the user interface
        '''
        self.setMinimumWidth(500)
        self.setWindowTitle('Neues Projekt erstellen')

        project_manager = ProjectManager()
        self.project_names = [p.name for p in project_manager.projects]

        layout = QVBoxLayout(self)

        label = QLabel('Name des Projekts')
        self.name_edit = QLineEdit()
        self.name_edit.textChanged.connect(self.validate)
        layout.addWidget(label)
        layout.addWidget(self.name_edit)
        self.path = os.path.join(project_manager.settings.TEMPLATE_PATH,
                                 'projektflaechen')

        hlayout = QHBoxLayout(self)
        label = QLabel('Import der (Teil-)Flächen des Plangebiets')
        self.layer_combo = QgsMapLayerComboBox()
        self.layer_combo.setFilters(QgsMapLayerProxyModel.VectorLayer)

        self.source = None

        self.layer_combo.layerChanged.connect(self.set_layer)
        self.layer_combo.layerChanged.connect(self.validate)
        browse_button = QPushButton('...')
        browse_button.clicked.connect(self.browse_path)
        browse_button.setMaximumWidth(30)
        hlayout.addWidget(self.layer_combo)
        hlayout.addWidget(browse_button)
        layout.addWidget(label)
        layout.addLayout(hlayout)

        self.status_label = QLabel()
        layout.addWidget(self.status_label)

        spacer = QSpacerItem(
            20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        layout.addItem(spacer)

        buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
            Qt.Horizontal, self)
        self.ok_button = buttons.button(QDialogButtonBox.Ok)
        self.ok_button.setEnabled(False)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)

        if len(self.layer_combo) > 0:
            self.set_layer(self.layer_combo.currentLayer())
        self.layer_combo.setCurrentIndex(0)
示例#9
0
    def draw(self, layout: QBoxLayout):
        '''
        draw seperator in given layout (appended)

        Parameters
        ----------
        layout : QBoxLayout
            layout to append the drawn parameter to
        '''
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        if self.margin:
            layout.addItem(QSpacerItem(0, self.margin, QSizePolicy.Fixed,
                                       QSizePolicy.Minimum))
        layout.addWidget(line)
        if self.margin:
            layout.addItem(QSpacerItem(0, self.margin, QSizePolicy.Fixed,
                                       QSizePolicy.Minimum))
示例#10
0
    def buildPoleHeader(self):
        headerRow = QHBoxLayout()
        spacerItemA = QSpacerItem(60, 20, QSizePolicy.Fixed,
                                 QSizePolicy.Minimum)
        spacerItemE = QSpacerItem(60, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        headername = QLabel(self.tr('Stuetzenbezeichnung'))
        headername.setMinimumSize(QSize(180, 30))
        headerDist = QLabel(self.tr('Hori.distanz'))
        headerDist.setMinimumSize(QSize(95, 30))
        headerHeight = QLabel(self.tr('Hoehe'))
        headerHeight.setMinimumSize(QSize(85, 30))

        headerRow.addItem(spacerItemA)
        headerRow.addWidget(headername)
        headerRow.addWidget(headerDist)
        headerRow.addWidget(headerHeight)
        headerRow.addItem(spacerItemE)
        self.outerLayout.addLayout(headerRow)
示例#11
0
    def setup_sessions(self, configuration, sessions):
        new_sessions = []

        for key in sessions:
            models = sessions[key]["models"] if "models" in sessions[key] else []
            datasets = (
                sessions[key]["datasets"] if "datasets" in sessions[key] else None
            )
            baskets = sessions[key]["baskets"] if "baskets" in sessions[key] else None

            skipped_session_widget = self._find_skipped_session_widget(
                (
                    key,
                    models,
                    datasets,
                    baskets,
                    db_utils.get_schema_identificator_from_configuration(configuration),
                )
            )
            if skipped_session_widget:
                new_sessions.append(skipped_session_widget)
            else:
                session = SessionPanel(
                    copy.deepcopy(configuration),
                    key,
                    models,
                    datasets,
                    baskets,
                    self.db_action_type,
                )
                session.on_done_or_skipped.connect(self._on_done_or_skipped_received)
                session.print_info.connect(self.workflow_wizard.log_panel.print_info)
                session.on_stderr.connect(self.workflow_wizard.log_panel.on_stderr)
                session.on_process_started.connect(self._on_process_started)
                session.on_process_finished.connect(self._on_process_finished)
                new_sessions.append(session)

        self.session_widget_list = new_sessions

        session_layout = QVBoxLayout()
        content = QWidget()
        for session_widget in self.session_widget_list:
            session_layout.addWidget(session_widget)
        session_layout.addSpacerItem(
            QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Expanding)
        )
        content.setLayout(session_layout)
        self.scroll_area.setWidget(content)

        self.pending_sessions = [
            session.id
            for session in self.session_widget_list
            if not session.is_skipped_or_done
        ]
        self.setComplete(not self.pending_sessions)
示例#12
0
 def setupFields(self):
     """
     Setups up all fields and fill up with available data on the attribute
     map.
     """
     utils = Utils()
     row = 0  # in case no fields are provided
     for row, f in enumerate(self.fields):
         fName = f.name()
         fMap = self.attributeMap[fName] if fName in self.attributeMap \
                     else None
         if fName in self.attributeMap:
             fMap = self.attributeMap[fName]
             if fMap["ignored"]:
                 w = QLineEdit()
                 w.setText(self.tr("Field is set to be ignored"))
                 value = None
                 enabled = False
             else:
                 value = fMap["value"]
                 enabled = fMap["editable"]
             if fMap["isPk"]:
                 # visually identify primary key attributes
                 text = '<p>{0} <img src=":/plugins/DsgTools/icons/key.png" '\
                        'width="16" height="16"></p>'.format(fName)
             else:
                 text = fName
         else:
             value = None
             enabled = True
             text = fName
         if fName in self.attributeMap and self.attributeMap[fName][
                 "ignored"]:
             pass
         elif utils.fieldIsFloat(f):
             w = QDoubleSpinBox()
             w.setValue(0 if value is None else value)
         elif utils.fieldIsInt(f):
             w = QSpinBox()
             w.setValue(0 if value is None else value)
         else:
             w = QLineEdit()
             w.setText("" if value is None else value)
         w.setEnabled(enabled)
         # also to make easier to read data
         self._fieldsWidgets[fName] = w
         label = QLabel(text)
         label.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
         w.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
         self.widgetsLayout.addWidget(label, row, 0)
         self.widgetsLayout.addWidget(w, row, 1)
     self.widgetsLayout.addItem(
         QSpacerItem(20, 40, QSizePolicy.Expanding, QSizePolicy.Expanding),
         row + 1, 1, 1, 2)  # row, col, rowSpan, colSpan
示例#13
0
    def fill_row(self, receiver_name, parcel_count, row):
        # First add a spacer between previoud data row (could be the title) and the next row data
        v_spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Preferred)
        self.grb_summary.layout().addItem(v_spacer, row, 0)

        # Now, let's add a row of data
        w = QLabel(receiver_name)
        self.grb_summary.layout().addWidget(w, row+1, 0)
        w = QLabel(str(parcel_count))
        w.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.grb_summary.layout().addWidget(w, row+1, 2)
示例#14
0
    def api_search(self):

        # Dialog
        self.dlg_search = ApiSearchUi()
        self.load_settings(self.dlg_search)
        self.dlg_search.lbl_msg.setStyleSheet("QLabel{color:red;}")
        self.dlg_search.lbl_msg.setVisible(False)

        # Make it dockable in left dock widget area
        self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dlg_search)

        body = self.create_body()
        function_name = "gw_api_getsearch"
        row = self.controller.execute_api_function(function_name, body)
        if not row:
            return False

        complet_list = [json.loads(row[0], object_pairs_hook=OrderedDict)]

        main_tab = self.dlg_search.findChild(QTabWidget, 'main_tab')
        first_tab = None
        self.lineedit_list = []
        for tab in complet_list[0]["form"]:
            if first_tab is None:
                first_tab = tab['tabName']
            tab_widget = QWidget(main_tab)
            tab_widget.setObjectName(tab['tabName'])
            main_tab.addTab(tab_widget, tab['tabtext'])
            gridlayout = QGridLayout()
            tab_widget.setLayout(gridlayout)
            x = 0

            for field in tab['fields']:
                label = QLabel()
                label.setObjectName('lbl_' + field['label'])
                label.setText(field['label'].capitalize())
                if field['widgettype'] == 'typeahead':
                    completer = QCompleter()
                    widget = self.add_lineedit(field)
                    widget = self.set_completer(widget, completer)
                    self.lineedit_list.append(widget)
                elif field['widgettype'] == 'combo':
                    widget = self.add_combobox(field)

                gridlayout.addWidget(label, x, 0)
                gridlayout.addWidget(widget, x, 1)
                x += 1

            vertical_spacer1 = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                           QSizePolicy.Expanding)
            gridlayout.addItem(vertical_spacer1)

        self.dlg_search.dlg_closed.connect(self.rubber_polygon.reset)
    def __init__(self, parent=None):
        """Constructor."""
        super(ErrorWidgetItem, self).__init__(parent)

        self.setupUi(self)

        self.textQVBoxLayout = QVBoxLayout()
        self.allQHBoxLayout = QHBoxLayout()
        verticalSpacer = QSpacerItem(0, 70, QSizePolicy.Minimum,
                                     QSizePolicy.Expanding)
        self.textQVBoxLayout.addItem(verticalSpacer)
        self.allQHBoxLayout.addLayout(self.textQVBoxLayout)
        self.route_id = -1
        self.setLayout(self.allQHBoxLayout)
示例#16
0
    def initGui(self):
        self.combo = ExtendedComboBox()
        self.fillCombo()

        self.combo.setEditable(True)
        self.label = QLabel('Enter command:')
        self.errorLabel = QLabel('Enter command:')
        self.vlayout = QVBoxLayout()
        self.vlayout.setSpacing(2)
        self.vlayout.setMargin(0)
        self.vlayout.addSpacerItem(
            QSpacerItem(0, OFFSET, QSizePolicy.Maximum, QSizePolicy.Expanding))
        self.hlayout = QHBoxLayout()
        self.hlayout.addWidget(self.label)
        self.vlayout.addLayout(self.hlayout)
        self.hlayout2 = QHBoxLayout()
        self.hlayout2.addWidget(self.combo)
        self.vlayout.addLayout(self.hlayout2)
        self.vlayout.addSpacerItem(
            QSpacerItem(0, OFFSET, QSizePolicy.Maximum, QSizePolicy.Expanding))
        self.setLayout(self.vlayout)
        self.combo.lineEdit().returnPressed.connect(self.run)
        self.prepareGui()
    def __init__(self, layer):
        super().__init__()
        self.layer = layer
        # Is legend a png file?
        self.my_img = os.path.splitext(layer.source())[0] + '.legend.png'
        if not os.path.exists(self.my_img):
            # No, is it a jpg?
            self.my_img = os.path.splitext(layer.source())[0] + '.legend.jpg'
            if not os.path.exists(self.my_img):
                # No: is this raster using a common legend?
                pwd = os.getcwd()
                compath = os.path.split(layer.source())[0]
                os.chdir(compath)
                englob = glob.glob("*.legendcommon.*")
                if len(englob) > 0:
                    # Yes
                    self.my_img = os.path.join(compath, self.getMy_Img())
                else:
                    # No: abort
                    os.chdir(pwd)
                    return
                #
                os.chdir(pwd)

        im = Image.open(self.my_img)
        w, h = im.size

        self.setAutoFillBackground(False)
        self.my_pix = QPixmap(self.my_img)
        self.imgleg = QPushButton()
        self.imgleg.setIcon(QIcon(self.my_pix))
        self.imgleg.setCheckable(False)
        self.imgleg.setFlat(True)
        if w >= h:
            self.imgleg.setIconSize(QSize(200, int(200 * h / w)))
        else:
            self.imgleg.setIconSize(QSize(int(200 * w / h), 200))
        self.imgleg.setSizePolicy(QSizePolicy.MinimumExpanding,
                                  QSizePolicy.MinimumExpanding)

        layout = QHBoxLayout()
        spacer = QSpacerItem(1, 0, QSizePolicy.MinimumExpanding,
                             QSizePolicy.Minimum)
        layout.addWidget(self.imgleg)
        layout.addItem(spacer)
        self.setLayout(layout)

        if self.layer.type() == QgsMapLayer.RasterLayer:
            self.imgleg.released.connect(self.showLegend)
    def populateScaleChoices(self):
        """ When the template type combo is initialised or changes, update the
        layout of scales for the various map elements in layout. """

        # Clear previous
        for i in reversed(list(range(self.ui.scalesGridLayout.count()))):
            item = self.ui.scalesGridLayout.itemAt(i)
            if type(item) == QSpacerItem:
                self.ui.scalesGridLayout.removeItem(item)
            else:
                item.widget().setParent(None)

        print_layout = self.get_print_layout()
        map_elements = [
            item for item in print_layout.items()
            if isinstance(item, QgsLayoutItemMap)
        ]
        i = 0
        for elem in map_elements:
            label_1 = QLabel(elem.displayName())
            self.ui.scalesGridLayout.addWidget(label_1, i, 0)

            spacer = QSpacerItem(0, 0, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
            self.ui.scalesGridLayout.addItem(spacer, i, 1)

            label_2 = QLabel('1:')
            self.ui.scalesGridLayout.addWidget(label_2, i, 2)

            comboBox = QComboBox()
            comboBox.setEditable(True)
            # Add current canvas scale
            locale.setlocale(locale.LC_ALL, '')
            currentMapCanvasScale = self.iface.mapCanvas().scale()
            scaleString = locale.format_string('%d',
                                               currentMapCanvasScale,
                                               grouping=True)
            comboBox.addItem(f'{scaleString} (Current map canvas)')
            for scale in self.presetScales:
                comboBox.addItem(str(scale))
            self.ui.scalesGridLayout.addWidget(comboBox, i, 3)

            i += 1

        if len(map_elements) == 0:
            label = QLabel('No layout map elements found. Limited usability.')
            self.ui.scalesGridLayout.addWidget(label, i, 1)
示例#19
0
    def __init__(self, layer):
        super().__init__()
        self.layer = layer

        self.setAutoFillBackground(False)
        self.checkbox = QCheckBox(self.tr("Show Labels"))
        layout = QHBoxLayout()
        spacer = QSpacerItem(1, 0, QSizePolicy.MinimumExpanding,
                             QSizePolicy.Minimum)
        layout.addWidget(self.checkbox)
        layout.addItem(spacer)
        self.setLayout(layout)

        # init from layer
        if self.layer.type() == QgsMapLayer.VectorLayer:
            self.checkbox.toggled.connect(self.toggled)
            self.checkbox.setChecked(self.layer.labelsEnabled())
示例#20
0
 def _create_labels(self):
     for i in range(len(self.steps)):
         if i != 0:
             spacer = QSpacerItem(
                 self.label_spacing_width,
                 0,
                 QSizePolicy.Expanding,
                 QSizePolicy.Minimum,
             )
             self.layout_labels.addItem(spacer)
         label = QLabel(self.steps[i])
         label.font_size = 11
         label.setWordWrap(True)
         label.setAlignment(Qt.AlignCenter)
         label.setFixedWidth(self.label_width)
         self.layout_labels.addWidget(label)
         self.widgets[i].append(label)
示例#21
0
    def init_spatial_unit_entity_combo(self):
        """
        Creates the party entity combobox.
        """
        self.entity_combo_label = QLabel()
        combo_text = QApplication.translate('SpatialUnitForeignKeyMapper',
                                            'Select a spatial unit entity')
        self.entity_combo_label.setText(combo_text)

        self.entity_combo = QComboBox()
        self.spacer_item = QSpacerItem(288, 20, QSizePolicy.Expanding,
                                       QSizePolicy.Minimum)
        self.grid_layout.addItem(self.spacer_item, 0, 4, 1, 1)

        self.grid_layout.addWidget(self.entity_combo_label, 0, 5, 1, 1)
        self.grid_layout.addWidget(self.entity_combo, 0, 6, 1, 1)

        self.populate_spatial_units()
示例#22
0
    def fill_data(self):
        summary_data = self._controller.get_summary_data()
        row = 1
        for row_data in summary_data:
            receiver_name, parcel_count = row_data
            self.fill_row(receiver_name, parcel_count, row)
            row += 2  # v_spacer + label

        # After the real data, we add a new spacer that expands itself to shrink content upwards
        v_spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.grb_summary.layout().addItem(v_spacer, row, 0)

        # Show/hide warning depending on if there are not allocated parcels
        not_allocated_parcels = self._controller.get_count_of_not_allocated_parcels()
        self.lbl_warning.setVisible(not_allocated_parcels)
        self.lbl_not_allocated_parcels.setVisible(not_allocated_parcels)
        self.lbl_not_allocated_parcels.setText(QCoreApplication.translate("BaseSplitDataForReceiversPanelWidget",
                                               "{} parcels have not been yet allocated!").format(not_allocated_parcels))
    def setup_ui(self, dock_widget):
        """
        initiate main Qt building blocks of interface
        :param dock_widget: QDockWidget instance
        """

        dock_widget.setObjectName("dock_widget")
        dock_widget.setAttribute(Qt.WA_DeleteOnClose)

        self.dockWidgetContent = QWidget(self)
        self.dockWidgetContent.setObjectName("dockWidgetContent")

        self.mainVLayout = QVBoxLayout(self.dockWidgetContent)
        self.dockWidgetContent.setLayout(self.mainVLayout)

        # add button to add objects to graphs
        self.buttonBarHLayout = QHBoxLayout(self)
        self.addSelectedObjectButton = QPushButton(self.dockWidgetContent)
        self.addSelectedObjectButton.setObjectName("addSelectedObjectButton")
        self.checkbox = QCheckBox("Absolute", parent=self.dockWidgetContent)
        self.checkbox.setChecked(False)
        self.checkbox.stateChanged.connect(self.on_btnstate)
        self.buttonBarHLayout.addWidget(self.addSelectedObjectButton)
        self.buttonBarHLayout.addWidget(self.checkbox)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.buttonBarHLayout.addItem(spacerItem)
        self.mainVLayout.addItem(self.buttonBarHLayout)

        # add tabWidget for graphWidgets
        self.graphTabWidget = QTabWidget(self.dockWidgetContent)
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(6)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.graphTabWidget.sizePolicy().hasHeightForWidth())
        self.graphTabWidget.setSizePolicy(sizePolicy)
        self.graphTabWidget.setObjectName("graphTabWidget")
        self.mainVLayout.addWidget(self.graphTabWidget)

        # add dockwidget
        dock_widget.setWidget(self.dockWidgetContent)
        self.retranslate_ui(dock_widget)
        QMetaObject.connectSlotsByName(dock_widget)
    def go2epa_options(self):
        """ Button 23: Open form to set INP, RPT and project """

        # Clear list
        self.epa_options_list = []

        # Create dialog
        self.dlg_options = ApiEpaOptions()
        self.load_settings(self.dlg_options)

        form = '"formName":"epaoptions"'
        body = self.create_body(form=form)
        # Get layers under mouse clicked
        sql = f"SELECT gw_api_getconfig($${{{body}}}$$)::text"
        row = self.controller.get_row(sql, log_sql=True, commit=True)
        if not row:
            self.controller.show_message("NOT ROW FOR: " + sql, 2)
            return False
        complet_result = [json.loads(row[0], object_pairs_hook=OrderedDict)]

        self.construct_form_param_user(
            self.dlg_options, complet_result[0]['body']['form']['formTabs'], 0,
            self.epa_options_list)
        grbox_list = self.dlg_options.findChildren(QGroupBox)
        for grbox in grbox_list:
            widget_list = grbox.findChildren(QWidget)
            if len(widget_list) == 0:
                grbox.setVisible(False)
            else:
                gridlist = grbox.findChildren(QGridLayout)
                for grl in gridlist:
                    spacer = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                         QSizePolicy.Expanding)
                    grl.addItem(spacer)

        # Event on change from combo parent
        self.get_event_combo_parent(complet_result)
        self.dlg_options.btn_accept.clicked.connect(
            partial(self.update_values, self.epa_options_list))
        self.dlg_options.btn_cancel.clicked.connect(
            partial(self.close_dialog, self.dlg_options))

        self.open_dialog(self.dlg_options)
示例#25
0
    def __init__(self, parent=None):
        super(ShellOutputScintilla, self).__init__(parent)
        self.parent = parent
        self.shell = self.parent.shell

        self.settings = QgsSettings()

        # Creates layout for message bar
        self.layout = QGridLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)
        spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        self.layout.addItem(spacerItem, 1, 0, 1, 1)
        # messageBar instance
        self.infoBar = QgsMessageBar()
        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.infoBar.setSizePolicy(sizePolicy)
        self.layout.addWidget(self.infoBar, 0, 0, 1, 1)

        sys.stdout = writeOut(self, sys.stdout)
        sys.stderr = writeOut(self, sys.stderr, "_traceback")

        self.insertInitText()
        self.refreshSettingsOutput()
        self.setReadOnly(True)

        self.setCaretWidth(0)  # NO (blinking) caret in the output

        self.setMinimumHeight(120)

        self.setWrapMode(QsciScintilla.WrapCharacter)
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

        self.runScut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
        self.runScut.setContext(Qt.WidgetShortcut)
        self.runScut.activated.connect(self.enteredSelected)
        # Reimplemented copy action to prevent paste prompt (>>>,...) in command view
        self.copyShortcut = QShortcut(QKeySequence.Copy, self)
        self.copyShortcut.setContext(Qt.WidgetWithChildrenShortcut)
        self.copyShortcut.activated.connect(self.copy)
        self.selectAllShortcut = QShortcut(QKeySequence.SelectAll, self)
        self.selectAllShortcut.setContext(Qt.WidgetWithChildrenShortcut)
        self.selectAllShortcut.activated.connect(self.selectAll)
示例#26
0
    def draw(self, layout: QLayout, edit: bool = False):
        '''
        draw parameter in given layout

        Parameters
        ----------
        layout : QBoxLayout
            layout to append the drawn parameter to
        edit : bool, optional
            edit mode displaying the label and input of parameter if True,
            else label and (uneditable) value, by default False
        '''
        if edit and not self.input:
            return
        self.row = QHBoxLayout()
        label = QLabel(self.label)
        spacer = QFrame()
        spacer_layout = QHBoxLayout()
        spacer_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding))
        spacer.setLayout(spacer_layout)
        # dotted line in preview
        if not edit:
            spacer.setFrameShape(QFrame.StyledPanel)
            spacer.setStyleSheet('border-width: 1px; border-style: none; '
                                 'border-bottom-style: dotted;'
                                 'border-color: grey;')
        if isinstance(layout, QGridLayout):
            n_rows = layout.rowCount()
            layout.addWidget(label, n_rows, 0)
            layout.addWidget(spacer, n_rows, 1)
            layout.addLayout(self.row, n_rows, 2)
        else:
            self.row.addWidget(label)
            self.row.addWidget(spacer)
            layout.addLayout(self.row)
        if edit:
            self.input.draw(self.row, unit=self.unit)
        else:
            self.row.addWidget(self._value_label)
            if self.unit:
                unit_label = QLabel(self.unit)
                self.row.addWidget(unit_label)
示例#27
0
    def _go2epa_options(self):
        """ Button 23: Open form to set INP, RPT and project """

        # Clear list
        self.epa_options_list = []

        # Create dialog
        self.dlg_go2epa_options = GwGo2EpaOptionsUi()
        tools_gw.load_settings(self.dlg_go2epa_options)

        form = '"formName":"epaoptions"'
        body = tools_gw.create_body(form=form)
        json_result = tools_gw.execute_procedure('gw_fct_getconfig', body)
        if not json_result or json_result['status'] == 'Failed':
            return False

        tools_gw.build_dialog_options(self.dlg_go2epa_options,
                                      json_result['body']['form']['formTabs'],
                                      0, self.epa_options_list)
        grbox_list = self.dlg_go2epa_options.findChildren(QGroupBox)
        for grbox in grbox_list:
            widget_list = grbox.findChildren(QWidget)
            if len(widget_list) == 0:
                grbox.setVisible(False)
            else:
                layout_list = grbox.findChildren(QGridLayout)
                for lyt in layout_list:
                    spacer = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                         QSizePolicy.Expanding)
                    lyt.addItem(spacer)

        # Event on change from combo parent
        self._get_event_combo_parent(json_result)
        self.dlg_go2epa_options.btn_accept.clicked.connect(
            partial(self._update_values, self.epa_options_list))
        self.dlg_go2epa_options.btn_cancel.clicked.connect(
            partial(tools_gw.close_dialog, self.dlg_go2epa_options))
        self.dlg_go2epa_options.rejected.connect(
            partial(tools_gw.close_dialog, self.dlg_go2epa_options))

        tools_gw.open_dialog(self.dlg_go2epa_options,
                             dlg_name='go2epa_options')
示例#28
0
    def loadprojects(self, projects):
        # root = self.synctree.invisibleRootItem()
        self.load_application_sync()
        for project in projects:
            providers = list(project.syncprovders())
            if not providers:
                continue

            actionwidget = ActionPickerWidget()
            actionwidget.setTile(project.name)
            for provider in providers:
                action = QAction(None)
                action.setText(provider.name)
                action.setIcon(QIcon(":/icons/sync"))
                action.triggered.connect(partial(self.run, action, provider))
                actionwidget.addAction(action)
            self.syncwidgets.layout().addWidget(actionwidget)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Expanding)
        self.syncwidgets.layout().addItem(spacerItem)
示例#29
0
文件: QgsUtils.py 项目: tlh22/QGISFMV
    def CustomMessage(title, msg, informative="", icon="Critical"):
        ''' Custom Informative Message '''
        d = QMessageBox()
        d.setTextFormat(Qt.RichText)
        d.setWindowTitle(title)
        d.setWindowIcon(QIcon(QPixmap(":/imgFMV/images/icon.png")))
        d.setText(msg)
        d.setInformativeText(informative)
        d.setIconPixmap(QgsUtils.GetIcon(icon))
        d.addButton(QMessageBox.Yes)
        d.addButton(QMessageBox.No)
        d.setDefaultButton(QMessageBox.No)

        # Trick resize QMessageBox
        horizontalSpacer = QSpacerItem(500, 0, QSizePolicy.Minimum,
                                       QSizePolicy.Expanding)
        layout = d.layout()
        layout.addItem(horizontalSpacer, layout.rowCount(), 0, 1,
                       layout.columnCount())

        ret = d.exec_()
        return ret
    def __init__(self, expression, options):
        super(PredefinedExpressionDialog, self).__init__()
        self.setupUi(self)

        self.filledExpression = None
        self.options = options
        self.expression = expression
        self.variables = set(re.findall('\[.*?\]', expression))
        self.comboBoxes = {}
        for variable in self.variables:
            label = QLabel(variable[1:-1])
            combo = QComboBox()
            for opt in self.options.keys():
                combo.addItem(opt)
            self.comboBoxes[variable] = combo
            self.groupBox.layout().addWidget(label)
            self.groupBox.layout().addWidget(combo)

        verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.groupBox.layout().addItem(verticalSpacer)

        self.buttonBox.rejected.connect(self.cancelPressed)
        self.buttonBox.accepted.connect(self.okPressed)