class DialogWithImage(QDialog): def __init__(self): QDialog.__init__(self) self.main_widget = QWidget(self) self.main_widget.setMinimumSize(QSize(100, 100)) self.label = QLabel() self.buttonBox = QDialogButtonBox(self.main_widget) self.buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.Apply) # Access the layout of the MessageBox to add the checkbox self.container = QVBoxLayout(self.main_widget) self.container.addWidget(self.label) self.container.addWidget(self.buttonBox) self.container.setAlignment(Qt.AlignCenter) self.container.setSizeConstraint(QLayout.SetFixedSize) self.setLayout(self.container) def Apply(self): self.close()
class DialogWithImage(QDialog): def __init__(self, interface): QDialog.__init__(self, interface.mainWindow()) self.iface = interface self.main_widget = QWidget(self) self.main_widget.setMinimumSize(QSize(100, 100)) self.label = QLabel() self.buttonBox = QDialogButtonBox(self.main_widget) self.buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.Apply) # Access the layout of the MessageBox to add the checkbox self.container = QVBoxLayout(self.main_widget) self.container.addWidget(self.label) self.container.addWidget(self.buttonBox) self.container.setAlignment(Qt.AlignCenter) self.container.setSizeConstraint(QLayout.SetFixedSize) self.setLayout(self.container) def Apply(self): self.close()
def __init__(self, parent): """Small window to define the name of the saved parmeter set.""" QDialog.__init__(self, parent) self.paramData = None self.availableSets = None self.savePath = None self.setname = None self.setWindowTitle(self.tr('Name Parameterset')) main_widget = QWidget(self) # Build gui hbox = QHBoxLayout() setnameLabel = QLabel(self.tr('Bezeichnung Parameterset')) self.setnameField = QLineEdit() self.setnameField.setMinimumWidth(400) self.setnameField.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) hbox.addWidget(setnameLabel) hbox.addWidget(self.setnameField) # Create Ok/Cancel Button and connect signal buttonBox = QDialogButtonBox(main_widget) buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) buttonBox.button(QDialogButtonBox.Ok).setText(self.tr("OK")) buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Abbrechen")) buttonBox.accepted.connect(self.apply) buttonBox.rejected.connect(self.onCancel) # Layout container = QVBoxLayout(main_widget) container.addLayout(hbox) container.addWidget(buttonBox) container.setAlignment(Qt.AlignLeft) self.setLayout(container)
def __init__(self, interface, toolWindow, options): QDialog.__init__(self, interface.mainWindow()) self.iface = interface self.tool = toolWindow self.options = options self.setWindowTitle("Output Optionen") main_widget = QWidget(self) # Build up gui hbox = QHBoxLayout() saveLabel = QLabel("Speicherpfad") self.pathField = QComboBox() self.pathField.setMinimumWidth(400) self.pathField.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) openButton = QPushButton() openButton.setMaximumSize(QSize(27, 27)) icon = QIcon() iconPath = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'icons', 'icon_open.png') icon.addPixmap(QPixmap(iconPath), QIcon.Normal, QIcon.Off) openButton.setIcon(icon) openButton.setIconSize(QSize(24, 24)) openButton.clicked.connect(self.onOpenDialog) hbox.addWidget(saveLabel) hbox.addWidget(self.pathField) hbox.addWidget(openButton) # Create checkboxes questionLabel = \ QLabel(u"Welche Produkte sollen erzeugt werden?") self.checkBoxReport = QCheckBox(u"Technischer Bericht") self.checkBoxPlot = QCheckBox(u"Diagramm") self.checkBoxGeodata = \ QCheckBox(u"Shape-Daten der Stützen und Seillinie") self.checkBoxCoords = \ QCheckBox(u"Koordinaten-Tabellen der Stützen und Seillinie") # Set tick correctly self.checkBoxReport.setChecked(self.options['report']) self.checkBoxPlot.setChecked(self.options['plot']) self.checkBoxGeodata.setChecked(self.options['geodata']) self.checkBoxCoords.setChecked(self.options['coords']) # Create Ok/Cancel Button and connect signal buttonBox = QDialogButtonBox(main_widget) buttonBox.setStandardButtons(QDialogButtonBox.Ok| QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.Apply) buttonBox.rejected.connect(self.Reject) # Layout container = QVBoxLayout(main_widget) container.addLayout(hbox) container.addWidget(QLabel("")) container.addWidget(questionLabel) container.addWidget(self.checkBoxReport) container.addWidget(self.checkBoxPlot) container.addWidget(self.checkBoxGeodata) container.addWidget(self.checkBoxCoords) container.addWidget(buttonBox) container.setAlignment(Qt.AlignLeft) self.setLayout(container)
def init_gui(self): """ """ dlg_layout = QVBoxLayout() params_layout = QVBoxLayout() params_layout.setAlignment(Qt.AlignTop) # Config files groupbox self.config_files_groupbox = QgsCollapsibleGroupBox( u"Fichier de configuration de l'arbre des ressources") config_file_groupbox_layout = QFormLayout(self.config_files_groupbox) # URL of the file self.config_file_url_label = QLabel(u"URL du fichier", self) self.config_file_url_edit = QLineEdit(self) self.config_file_url_edit.editingFinished.connect( self.config_file_url_changed) config_file_groupbox_layout.addRow(self.config_file_url_label, self.config_file_url_edit) # Download the file at startup self.download_cb = QCheckBox( u"Télécharger le fichier à chaque lancement de QGIS", self) self.download_cb.stateChanged.connect(self.download_cb_changed) config_file_groupbox_layout.addRow(self.download_cb) params_layout.addWidget(self.config_files_groupbox) # Download the file now self.download_now_label = QLabel(u"Télécharger le fichier maintenant", self) self.download_now_btnbox = QDialogButtonBox() self.download_now_btnbox.setOrientation(Qt.Horizontal) self.download_now_btnbox.setStandardButtons(QDialogButtonBox.Yes) self.download_now_btnbox.button(QDialogButtonBox.Yes).clicked.connect( self.download_file_now) config_file_groupbox_layout.addRow(self.download_now_label, self.download_now_btnbox) # Content of the resource tree groupbox self.resource_tree_groupbox = QgsCollapsibleGroupBox( u"Contenu de l'arbre des ressources") resource_tree_groupbox_layout = QFormLayout( self.resource_tree_groupbox) # Hide resources with a warn flag self.hide_resources_with_warn_status_cb = QCheckBox( u"Masquer les ressources en cours d'intégration", self) self.hide_resources_with_warn_status_cb.stateChanged.connect( self.hide_resources_with_warn_cb_changed) resource_tree_groupbox_layout.addRow( self.hide_resources_with_warn_status_cb) # Hide empty groups in the resources tree self.hide_empty_groups_cb = QCheckBox( u"Masquer les groupes de ressources vides", self) self.hide_empty_groups_cb.stateChanged.connect( self.hide_empty_groups_cb_changed) resource_tree_groupbox_layout.addRow(self.hide_empty_groups_cb) params_layout.addWidget(self.resource_tree_groupbox) dlg_layout.addLayout(params_layout) # Set values self.set_values_from_qsettings() # Bottom dialog buttons self.button_box = QDialogButtonBox() self.button_box.setOrientation(Qt.Horizontal) self.button_box.setStandardButtons(QDialogButtonBox.RestoreDefaults | QDialogButtonBox.Apply | QDialogButtonBox.Close) self.button_box.button( QDialogButtonBox.RestoreDefaults).clicked.connect( self.restore_defaults_button_clicked) self.button_box.button(QDialogButtonBox.Close).clicked.connect( self.close_button_clicked) self.button_box.button(QDialogButtonBox.Apply).clicked.connect( self.apply_button_clicked) # Dialog box title, layout, size and display title = u"Paramétrage de l'extension GéoSAS…" self.setWindowTitle(title) dlg_layout.addWidget(self.button_box) self.setLayout(dlg_layout) self.setMinimumWidth(500) self.resize(self.sizeHint()) self.setSizeGripEnabled(False) self.setFixedSize(self.size()) self.show() self.setSizeGripEnabled(False)
class ProjectFromOSMDialog(QtWidgets.QDialog, FORM_CLASS): def __init__(self, iface): QtWidgets.QDialog.__init__(self) self.iface = iface self.setupUi(self) self.path = standard_path() self.error = None self.report = [] self.worker_thread = None self.running = False self.bbox = None self.json = [] self.project = None self.logger = logging.getLogger("aequilibrae") self._run_layout = QGridLayout() # Area to import network for self.choose_place = QRadioButton() self.choose_place.setText("Place name") self.choose_place.toggled.connect(self.change_place_type) self.choose_place.setChecked(False) self.choose_canvas = QRadioButton() self.choose_canvas.setText("Current map canvas area") self.choose_canvas.setChecked(True) self.place = QLineEdit() self.place.setVisible(False) self.source_type_frame = QVBoxLayout() self.source_type_frame.setAlignment(Qt.AlignLeft) self.source_type_frame.addWidget(self.choose_place) self.source_type_frame.addWidget(self.choose_canvas) self.source_type_frame.addWidget(self.place) self.source_type_widget = QGroupBox('Target') self.source_type_widget.setLayout(self.source_type_frame) # Buttons and output self.but_choose_output = QPushButton() self.but_choose_output.setText("Choose file output") self.but_choose_output.clicked.connect(self.choose_output) self.output_path = QLineEdit() self.but_run = QPushButton() self.but_run.setText("Import network and create project") self.but_run.clicked.connect(self.run) self.buttons_frame = QVBoxLayout() self.buttons_frame.addWidget(self.but_choose_output) self.buttons_frame.addWidget(self.output_path) self.buttons_frame.addWidget(self.but_run) self.buttons_widget = QWidget() self.buttons_widget.setLayout(self.buttons_frame) self.progressbar = QProgressBar() self.progress_label = QLabel() self.update_widget = QWidget() self.update_frame = QVBoxLayout() self.update_frame.addWidget(self.progressbar) self.update_frame.addWidget(self.progress_label) self.update_widget.setLayout(self.update_frame) self.update_widget.setVisible(False) self._run_layout.addWidget(self.source_type_widget) self._run_layout.addWidget(self.buttons_widget) self._run_layout.addWidget(self.update_widget) self.setLayout(self._run_layout) self.resize(280, 250) def choose_output(self): new_name, file_type = GetOutputFileName(self, '', ["SQLite database(*.sqlite)"], ".sqlite", self.path) if new_name is not None: self.output_path.setText(new_name) def run(self): self.update_widget.setVisible(True) self.resize(280, 300) if self.choose_canvas.isChecked(): self.report.append( reporter('Chose to download network for canvas area')) e = self.iface.mapCanvas().extent() bbox = [e.xMinimum(), e.yMinimum(), e.xMaximum(), e.yMaximum()] else: self.progress_label.setText('Establishing area for download') self.report.append(reporter('Chose to download network for place')) bbox, r = placegetter(self.place.text()) self.report.extend(r) if bbox is None: self.leave() return west, south, east, north = bbox[0], bbox[1], bbox[2], bbox[3] self.report.append( reporter( 'Downloading network for bounding box ({} {}, {}, {})'.format( west, south, east, north))) self.bbox = bbox surveybox = QgsRectangle(QgsPointXY(west, south), QgsPointXY(east, north)) geom = QgsGeometry().fromRect(surveybox) conv = QgsDistanceArea() area = conv.convertAreaMeasurement(conv.measureArea(geom), QgsUnitTypes.AreaSquareMeters) self.report.append( reporter( 'Area for which we will download a network: {:,} km.sq'.format( area / 1000000))) if area <= max_query_area_size: geometries = [[west, south, east, north]] else: parts = math.ceil(area / max_query_area_size) horizontal = math.ceil(math.sqrt(parts)) vertical = math.ceil(parts / horizontal) dx = east - west dy = north - south geometries = [] for i in range(horizontal): xmin = west + i * dx xmax = west + (i + 1) * dx for j in range(vertical): ymin = south + j * dy ymax = south + (j + 1) * dy box = [xmin, ymin, xmax, ymax] geometries.append(box) p = Parameters().parameters modes = [list(k.keys())[0] for k in p['network']['modes']] self.progress_label.setText('Downloading data') self.downloader = OSMDownloader(geometries, modes) self.run_download_thread() def final_steps(self): self.project = Project(self.output_path.text(), True) self.project.network.create_empty_tables() curr = self.project.conn.cursor() curr.execute("""ALTER TABLE links ADD COLUMN osm_id integer""") curr.execute("""ALTER TABLE nodes ADD COLUMN osm_id integer""") self.project.conn.commit() self.project.conn.close() self.builder = OSMBuilder(self.downloader.json, self.project.source) self.run_thread() def run_download_thread(self): self.downloader.downloading.connect(self.signal_downloader_handler) self.downloader.start() self.exec_() def run_thread(self): self.builder.building.connect(self.signal_handler) self.builder.start() self.exec_() def change_place_type(self): if self.choose_place.isChecked(): self.place.setVisible(True) else: self.place.setVisible(False) def leave(self): self.close() dlg2 = ReportDialog(self.iface, self.report) dlg2.show() dlg2.exec_() def signal_downloader_handler(self, val): if val[0] == "Value": self.progressbar.setValue(val[1]) elif val[0] == "maxValue": self.progressbar.setRange(0, val[1]) elif val[0] == "text": self.progress_label.setText(val[1]) elif val[0] == "FinishedDownloading": self.final_steps() def signal_handler(self, val): if val[0] == "Value": self.progressbar.setValue(val[1]) elif val[0] == "maxValue": self.progressbar.setRange(0, val[1]) elif val[0] == "text": self.progress_label.setText(val[1]) elif val[0] == "finished_threaded_procedure": self.project = Project(self.output_path.text()) self.progress_label.setText('Adding spatial indices') self.project.network.add_spatial_index() self.project.network.add_triggers() l = self.project.network.count_links() n = self.project.network.count_nodes() self.report.append(reporter(f'{l:,} links generated')) self.report.append(reporter(f'{n:,} nodes generated')) self.leave()
class QvDocumentacio(QDialog): comencaCarrega = pyqtSignal() acabaCarrega = pyqtSignal() '''Diàleg que mostra la documentació de la carpeta de documentació definida a configuracioQvista Mostra una TreeView amb els documents, i delega en el sistema la tasca d'obrir-los''' def __init__(self, parent: QWidget = None): super().__init__(parent) self.setMinimumSize(750, 500) #Layout principal. Tot aquí self.layout = QVBoxLayout(self) #Layout de la capçalera self.layoutCapcalera = QHBoxLayout() self.lblTitol = QLabel(' Documentació') self.layoutCapcalera.addWidget(self.lblTitol) self.qModel = ElMeuModel(self) self.lblExplicacio = QLabel() if os.path.isdir(carpetaDocuments): self.lblExplicacio.setText( 'Esteu visualitzant la documentació corporativa completa') rootPath = self.qModel.setRootPath(carpetaDocuments) else: self.lblExplicacio.setText( 'No teniu accés a la documentació corporativa. Esteu visualitzant una còpia local que pot no estar actualitzada.' ) rootPath = self.qModel.setRootPath(carpetaDocumentsLocal) self.treeView = QTreeView(self) self.treeView.setModel(self.qModel) self.treeView.setRootIndex(rootPath) self.treeView.clicked.connect(self.clicat) self.treeView.doubleClicked.connect(self.obrir) self.layoutBotonera = QHBoxLayout() self.layoutBotonera.addStretch() self.botoObrir = QvPushButton('Obrir', destacat=True) self.botoObrir.setEnabled(False) self.botoObrir.clicked.connect(self.obrir) self.layoutBotonera.addWidget(self.botoObrir) self.botoDescarregar = QvPushButton('Descarregar') self.botoDescarregar.setEnabled(False) self.botoDescarregar.clicked.connect(self.desar) self.layoutBotonera.addWidget(self.botoDescarregar) self.botoSortir = QvPushButton('Sortir') self.botoSortir.clicked.connect(self.close) self.layoutBotonera.addWidget(self.botoSortir) self.layout.addLayout(self.layoutCapcalera) self.layout.addWidget(self.lblExplicacio) self.layout.addWidget(self.treeView) self.layout.addLayout(self.layoutBotonera) self.formata() def formata(self): self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint) self.layout.setAlignment(Qt.AlignCenter) self.lblTitol.setStyleSheet( 'background-color: %s; color: %s; border: 0px' % (QvConstants.COLORFOSCHTML, QvConstants.COLORBLANCHTML)) self.lblTitol.setFont(QvConstants.FONTCAPCALERES) self.lblTitol.setFixedHeight(40) self.lblExplicacio.setWordWrap(True) self.lblExplicacio.setStyleSheet( f'color: {QvConstants.COLORFOSCHTML}; margin: 20px 20px 0px 20px') for i in range(1, 4): self.treeView.header().hideSection(i) self.treeView.setHeaderHidden(True) self.treeView.adjustSize() self.treeView.setAnimated(True) self.treeView.setStyleSheet( 'QTreeView{margin: 20px 2px 0px 20px; border: none;}') self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.layoutBotonera.setContentsMargins(10, 10, 10, 10) def clicat(self, index: int): path = self.qModel.fileInfo(index).absoluteFilePath() self.index = index if os.path.isfile(path): self.botoObrir.setEnabled(True) self.botoDescarregar.setEnabled(True) else: self.botoObrir.setEnabled(False) self.botoDescarregar.setEnabled(True) def obrir(self): path = self.qModel.fileInfo(self.index).absoluteFilePath() if os.path.isfile(path): self.comencaCarrega.emit() if '.html' in path: self.visor = QvVisorHTML(path, 'Vídeo de documentació') self.visor.setZoomFactor(1) self.visor.show() else: os.startfile(path) time.sleep(1) self.acabaCarrega.emit() def desar(self): path = self.qModel.fileInfo(self.index).absoluteFilePath() if os.path.isfile(path): nfile, _ = QFileDialog.getSaveFileName( None, 'Desar arxiu', os.path.join(QvMemoria().getDirectoriDesar(), Path(path).name)) if nfile != '': shutil.copy(path, nfile) else: nomCarpeta = Path(path).name nfile = str( QFileDialog.getExistingDirectory(self, "Select Directory")) if nfile != '': shutil.copytree(path, os.path.join(nfile, nomCarpeta)) def mousePressEvent(self, event): self.oldPos = event.globalPos() def mouseMoveEvent(self, event): delta = QPoint(event.globalPos() - self.oldPos) self.move(self.x() + delta.x(), self.y() + delta.y()) self.oldPos = event.globalPos() def keyPressEvent(self, event): if event.key() == Qt.Key_Escape: self.close() if event.key() == Qt.Key_Return: self.obrir()
def __init__(self, parent, confHandler): """ :type confHandler: configHandler.ConfigHandler """ QDialog.__init__(self, parent) self.confHandler = confHandler self.doSave = False self.setWindowTitle(self.tr('Output Optionen')) main_widget = QWidget(self) # Build up gui # Project title hbox1 = QHBoxLayout() projectNameLabel = QLabel(self.tr('Projektname')) projectNameLabel.setMinimumWidth(100) self.projectField = QLineEdit() self.projectField.setMinimumWidth(400) self.projectField.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) hbox1.addWidget(projectNameLabel) hbox1.addWidget(self.projectField) # Save path hbox2 = QHBoxLayout() saveLabel = QLabel(self.tr('Speicherpfad')) saveLabel.setMinimumWidth(100) self.pathField = QComboBox() self.pathField.setMinimumWidth(400) self.pathField.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) openButton = QPushButton() openButton.setMaximumSize(QSize(27, 27)) icon = QIcon() iconPath = os.path.join(os.path.dirname(__file__), 'icons', 'icon_open.png') icon.addPixmap(QPixmap(iconPath), QIcon.Normal, QIcon.Off) openButton.setIcon(icon) openButton.setIconSize(QSize(24, 24)) openButton.clicked.connect(self.onOpenDialog) hbox2.addWidget(saveLabel) hbox2.addWidget(self.pathField) hbox2.addWidget(openButton) # Create checkboxes questionLabel = QLabel( self.tr('Welche Produkte sollen erzeugt werden?')) self.checkBoxShortReport = QCheckBox(self.tr('Kurzbericht')) self.checkBoxReport = QCheckBox(self.tr('Technischer Bericht')) self.checkBoxPlot = QCheckBox(self.tr('Diagramm')) self.checkBoxGeodata = QCheckBox( self.tr('Shape-Daten der Stuetzen und Seillinie')) self.checkBoxKML = QCheckBox( self.tr('KML-Daten der Stuetzen und Seillinie')) self.checkBoxCoords = QCheckBox( self.tr('Koordinaten-Tabellen der Stuetzen und Seillinie')) # Set tick correctly self.checkBoxShortReport.setChecked( self.confHandler.outputOptions['shortReport']) self.checkBoxReport.setChecked( self.confHandler.outputOptions['report']) self.checkBoxPlot.setChecked(self.confHandler.outputOptions['plot']) self.checkBoxGeodata.setChecked( self.confHandler.outputOptions['geodata']) self.checkBoxKML.setChecked(self.confHandler.outputOptions['kml']) self.checkBoxCoords.setChecked( self.confHandler.outputOptions['coords']) # Create Ok/Cancel Button and connect signal buttonBox = QDialogButtonBox(main_widget) buttonBox.setStandardButtons(QDialogButtonBox.Save | QDialogButtonBox.Cancel) buttonBox.button(QDialogButtonBox.Save).setText(self.tr("Speichern")) buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Abbrechen")) buttonBox.button(QDialogButtonBox.Cancel).clicked.connect( self.onCancel) buttonBox.button(QDialogButtonBox.Save).clicked.connect(self.onSave) # Layout container = QVBoxLayout(main_widget) container.addLayout(hbox1) container.addLayout(hbox2) container.addWidget(QLabel('')) container.addWidget(questionLabel) container.addWidget(self.checkBoxShortReport) container.addWidget(self.checkBoxReport) container.addWidget(self.checkBoxPlot) container.addWidget(self.checkBoxGeodata) container.addWidget(self.checkBoxKML) container.addWidget(self.checkBoxCoords) container.addWidget(buttonBox) container.setAlignment(Qt.AlignLeft) self.setLayout(container) self.fillInData()