flake8 pagerender

This commit is contained in:
Tom LAVEILLE 2025-07-29 14:34:32 +02:00
parent 3564209574
commit e503423e49
5 changed files with 405 additions and 294 deletions

View File

@ -4,9 +4,9 @@ __email__ = "info@3liz.org"
from qgis.core import QgsApplication
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl
from qgis.PyQt.QtCore import QUrl, QSettings
from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtWidgets import QAction, QMessageBox
from qgis.PyQt.QtWidgets import QAction
from qgis.utils import iface
import qgis
@ -25,15 +25,13 @@ from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
'''
import os
from .tools.resources import (
plugin_path,
# plugin_path,
resources_path,
maj_verif,
)
from .canvas_editor import PageRender_Editor
from .about_form import AboutDialog
from qgis.PyQt.QtCore import *
class PgPageRender:
def __init__(self):
@ -74,7 +72,6 @@ class PgPageRender:
if not self.canvas_editor:
self.canvas_editor = PageRender_Editor()
self.pagerender_action = QAction(icon, 'CenRa_PAGERENDER', None)
self.toolBar.addAction(self.pagerender_action)
self.pagerender_action.triggered.connect(self.open_editor)
@ -117,6 +114,7 @@ class PgPageRender:
"""
dialog = AboutDialog(iface)
dialog.exec()
def open_help():
""" Open the online help. """
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))

View File

@ -3,7 +3,7 @@ import os.path
from pathlib import Path
from qgis.PyQt import uic
from qgis.PyQt.QtGui import QPixmap
# from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog
from .tools.resources import devlog

View File

@ -1,76 +1,37 @@
import logging
import os
from collections import namedtuple
from enum import Enum
from functools import partial
from pathlib import Path
from xml.dom.minidom import parseString
from qgis.gui import *
import qgis
from qgis.core import (
NULL,
QgsApplication,
QgsScaleBarSettings,
QgsDataSourceUri,
QgsProject,
QgsProviderConnectionException,
QgsProviderRegistry,
QgsRasterLayer,
QgsSettings,
QgsVectorLayer,
QgsGeometry,
QgsPrintLayout,
QgsReadWriteContext,
QgsLayoutItemMap,
QgsLayoutItemPage,
QgsLayoutSize,
QgsUnitTypes,
QgsLayoutPoint,
QgsLayoutItemLabel,
QgsLayoutItemPicture,
QgsLayoutItemLegend,
QgsLegendStyle,
QgsLayoutItemScaleBar,
QgsLayerTreeGroup,
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QgsLayerTree,
QgsLayoutTableColumn,
QgsRectangle,
QgsLayoutItemMapOverviewStack,
QgsLayoutItemHtml,
)
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime, Qt
from qgis.PyQt.QtGui import QDesktopServices, QIcon, QColor, QFont, QMovie
from qgis.PyQt.QtPrintSupport import QPrinter
# from collections import namedtuple
# from enum import Enum
# from functools import partial
# from pathlib import Path
# from xml.dom.minidom import parseString
# from qgis.gui import *
# import qgis
from qgis.core import QgsSettings
from qgis.PyQt.QtCore import Qt
# from qgis.PyQt.QtPrintSupport import QPrinter
# from qgis.PyQt.QtWebKitWidgets import QWebPage
from qgis.PyQt.QtWidgets import (
QDialog,
QAction,
QDockWidget,
QFileDialog,
QInputDialog,
QMenu,
QToolButton,
QTableWidget,
QTableWidgetItem,
QVBoxLayout,
)
from qgis.PyQt import QtGui
from qgis.PyQt.QtWidgets import QApplication
from qgis.PyQt.QtCore import QSettings,QPointF
from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtXml import QDomDocument
from qgis.utils import iface
import glob
# from qgis.PyQt.QtXml import QDomDocument
# from qgis.utils import iface
# import glob
from .tools.resources import (
load_ui,
resources_path,
send_issues,
# send_issues,
)
from .issues import CenRa_Issues
from datetime import date
# from .issues import CenRa_Issues
# from datetime import date
last_select = None
maxV = 210
maxH = 296
@ -80,31 +41,10 @@ url_osm = 'https://osm.datagrandest.fr/mapcache/?crs=EPSG:2154&featureCount=10&f
url_ortho = 'http://tiles.craig.fr/ortho/service/?crs=EPSG:2154&featureCount=10&format=image/jpeg&layers=ortho&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/ortho/service'
url_mnt = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=relief&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
url_pente = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=pente&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
data_source = [
'CENRA',
'IGN',
'CRAIG',
'OpenStreetMap',
'Sandre',
'BRGM',
'MUSÉUM NATIONAL DHISTOIRE NATURELLE',
"Muséum national d'Histoire naturelle",
'ONF',
'20xx LPO',
'ofb.gouv.fr',
'Stamen Design',
'MTES',
'MTES',
'FEDER',
'DREAL Auvergne-Rhône-Alpes',
'INSEE',
'DGFiP',
'Fédération des Conservatoires despaces naturels',
'Plan cadastral informatisé - Etalab - juillet 202X',
'Parcellaire Express - IGN - 202X',
]
class PageRender_Editor(QDialog, EDITOR_CLASS):
data_source = ['CENRA', 'IGN', 'CRAIG', 'OpenStreetMap', 'Sandre', 'BRGM', 'MUSÉUM NATIONAL DHISTOIRE NATURELLE', "Muséum national d'Histoire naturelle", 'ONF', '20xx LPO', 'ofb.gouv.fr', 'Stamen Design', 'MTES', 'MTES', 'FEDER', 'DREAL Auvergne-Rhône-Alpes', 'INSEE', 'DGFiP', 'Fédération des Conservatoires despaces naturels', 'Plan cadastral informatisé - Etalab - juillet 202X', 'Parcellaire Express - IGN - 202X']
class PageRender_Editor(QDialog, EDITOR_CLASS):
def __init__(self, parent=None):
_ = parent
super().__init__()
@ -127,7 +67,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
'Credit': 0,
'Source': 0,
'Echelle_2': 0,
'Logo_2':0,}
'Logo_2': 0}
path = ''
ix = 0
@ -158,8 +98,9 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
self.activateWindow()
self.setNavigator()
self.verticalScrollBar.setValue(self.frame.y())
def mousePressEvent(self, event):
if self.tableWidget.currentItem() != None:
if self.tableWidget.currentItem() is not None:
QApplication.setOverrideCursor(Qt.CursorShape(18))
global lastPos
lastPos = {'x': event.pos().x(), 'y': event.pos().y()}
@ -178,7 +119,6 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
if event.key() == Qt.Key(0x01000012):
self.horizontalSlider.setValue(self.spinBox.value() - 1)
def wheelEvent(self, event):
if (event.angleDelta().y() >= 1):
vsb = self.verticalScrollBar.value() + 50
@ -188,7 +128,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
def mouseMoveEvent(self, event):
updated_cursor_position = event.pos()
if self.tableWidget.currentItem() != None:
if self.tableWidget.currentItem() is not None:
selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children()
selection = 0
@ -204,14 +144,14 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
orig_position_w = selection.width()
orig_position_h = selection.height()
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() == True):
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() is True):
updated_cursor_position_x = orig_position_w + (round(updated_cursor_position.x() - lastPos['x']))
lastPos['x'] = event.pos().x()
selection.resize(updated_cursor_position_x, orig_position_h)
self.horizontalSlider.setValue(round(updated_cursor_position_x / 3.5))
orig_position_w = selection.width()
orig_position_h = selection.height()
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() == True):
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() is True):
updated_cursor_position_y = orig_position_h + (round(updated_cursor_position.y() - lastPos['y']))
lastPos['y'] = event.pos().y()
selection.resize(orig_position_w, updated_cursor_position_y)
@ -219,7 +159,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
orig_position_x = selection.pos().x()
orig_position_y = selection.pos().y()
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() == False):
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() is False):
updated_cursor_position_x = orig_position_x + (round(updated_cursor_position.x() - lastPos['x']))
lastPos['x'] = event.pos().x()
# print(updated_cursor_position_x)
@ -228,7 +168,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
orig_position_x = selection.pos().x()
orig_position_y = selection.pos().y()
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() == False):
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() is False):
updated_cursor_position_y = orig_position_y + (round(updated_cursor_position.y() - lastPos['y']))
lastPos['y'] = event.pos().y()
# print(updated_cursor_position_y)
@ -237,7 +177,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
def mouseReleaseEvent(self, event):
# print('x: {0}, y: {1}'.format(event.pos().x(), event.pos().y()))
if self.tableWidget.currentItem() != None:
if self.tableWidget.currentItem() is not None:
QApplication.restoreOverrideCursor()
def select_file(self):
@ -248,6 +188,7 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
return folder[0]
else:
return ''
def load(self):
folder = self.select_file()
logopath = folder
@ -317,12 +258,13 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
self.tableWidget.removeRow(0)
xR = xR + 1
self.tableWidget.clear()
id=0
# id = 0
for children in all_children:
position = self.tableWidget.rowCount()
self.tableWidget.insertRow(position)
self.tableWidget.setItem(position, 0, QTableWidgetItem(children.objectName()))
# print(children.objectName())
def export(self):
self.type_page()
self.type_page()
@ -412,6 +354,7 @@ def fletch_canvas(self):
sourceFile = open(self.path, 'w')
print(export_str, file=sourceFile)
sourceFile.close()
def type_page(self):
all_children = self.frame.children()
if self.toolButton_2.text() == 'Landscape':
@ -462,8 +405,9 @@ def fletch_canvas(self):
frame_x = round(frame_w / 3)
frame_y = self.frame.y()
self.frame.move(frame_x, frame_y)
def setSlider(self):
if self.tableWidget.currentItem() != None:
if self.tableWidget.currentItem() is not None:
print(self.tableWidget.tabKeyNavigation())
selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children()
@ -476,7 +420,7 @@ def fletch_canvas(self):
selection = children
if selection != 0:
self.rotate_color(selection, last_children)
if self.radioButton.isChecked() == False:
if self.radioButton.isChecked() is False:
xx = round(selection.x() / 3.5)
yy = round(selection.y() / 3.5)
else:
@ -490,7 +434,7 @@ def fletch_canvas(self):
def rotate_color(self, selection, last_children):
global last_select
if self.radioButton.isChecked() == False:
if self.radioButton.isChecked() is False:
ColorCode = "10, 10, 80, 50"
else:
ColorCode = "249, 238, 148, 50"
@ -509,7 +453,7 @@ def fletch_canvas(self):
last_select = selection.objectName()
def rotate(self):
if self.tableWidget.currentItem() != None:
if self.tableWidget.currentItem() is not None:
selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children()
selection = 0
@ -523,7 +467,7 @@ def fletch_canvas(self):
xx = round(selection.size().width())
yy = round(selection.size().height())
selection.resize(round(yy), round(xx))
if self.radioButton.isChecked() == True:
if self.radioButton.isChecked() is True:
self.spinBox.setValue(yy)
self.spinBox_2.setValue(xx)
self.horizontalSlider.setValue(round(yy / 3.5))
@ -536,7 +480,7 @@ def fletch_canvas(self):
self.rotate_color(selection, last_children)
def vertical(self):
if self.tableWidget.currentItem() != None:
if self.tableWidget.currentItem() is not None:
selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children()
selection = 0
@ -544,7 +488,7 @@ def fletch_canvas(self):
if selection_name == children.objectName():
selection = children
if selection != 0:
if self.radioButton.isChecked() == False:
if self.radioButton.isChecked() is False:
selection.move(round(self.horizontalSlider.value() * 3.5), round(self.verticalSlider.value() * 3.5))
else:
selection.resize(round(self.horizontalSlider.value() * 3.5), round(self.verticalSlider.value() * 3.5))
@ -552,7 +496,7 @@ def fletch_canvas(self):
self.spinBox_2.setValue(round(self.verticalSlider.value()))
def horizontal(self):
if self.tableWidget.currentItem() != None:
if self.tableWidget.currentItem() is not None:
selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children()
selection = 0
@ -560,10 +504,9 @@ def fletch_canvas(self):
if selection_name == children.objectName():
selection = children
if selection != 0:
if self.radioButton.isChecked() == False:
if self.radioButton.isChecked() is False:
selection.move(round(self.horizontalSlider.value() * 3.5), round(self.verticalSlider.value() * 3.5))
else:
selection.resize(round(self.horizontalSlider.value() * 3.5), round(self.verticalSlider.value() * 3.5))
self.spinBox.setValue(round(self.horizontalSlider.value()))
self.spinBox_2.setValue(round(self.verticalSlider.value()))

167
CenRa_PAGERENDER/demoV2.py Normal file
View File

@ -0,0 +1,167 @@
from qgis.core import (
QgsLayoutSize,
QgsUnitTypes,
QgsLayoutPoint,
)
def fletch_canvas(self):
if self.radioButton_6.isChecked():
values_page = 'A4'
else:
values_page = 'A3'
if self.radioButton_7.isChecked():
page_rotate = 'Portrait'
else:
page_rotate = 'Landscape'
if page_rotate == 'Portrait':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571,69, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(140.0,147, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(41, 110, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(121,97, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(197,207, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(58, 156, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if page_rotate == 'Landscape':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571,69, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(140.0,147, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(49, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(121,97, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(197,207, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(69, 21, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
return self.template_parameters

View File

@ -3,9 +3,9 @@
import configparser
import shutil
import tempfile
import base64
import psycopg2
import psycopg2.extras
# import base64
# import psycopg2
# import psycopg2.extras
from os.path import abspath, join, pardir, dirname
from qgis.PyQt.QtWidgets import QApplication
from qgis.PyQt import uic
@ -107,37 +107,38 @@ def load_ui(*args):
return ui_class
def send_issues(url, titre, body, labels):
import requests
import urllib.request
import json
import os
import qgis
# import os
usr = os.environ['USERNAME']
# usr = os.environ['USERNAME']
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
url = url + '?token=' + token
headers = {'Authorization': 'token ' + token, 'accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'title': titre, 'body': body, 'labels': labels}
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
except urllib.requests.URLError:
binar = False
r = ''
if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers)
return r
def maj_verif(NAME):
import qgis
import urllib.request
iface = qgis.utils.iface
from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository')
# url = qgis.utils.pluginMetadata(NAME, 'repository')
# URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL)
@ -146,7 +147,7 @@ def maj_verif(NAME):
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
except urllib.requests.URLError:
binar = False
if binar:
try:
@ -156,14 +157,16 @@ def maj_verif(NAME):
version_plugin = version_web[valeur_version_web:valeur_version_web + len_version]
if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
except:
except urllib.requests.URLError:
print("error gitea version ssl")
else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
def tr(text, context="@default"):
return QApplication.translate(context, text)
def devlog(NAME):
import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'