1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
| # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'download.ui'
#
# Created: Tue Aug 12 16:01:29 2014
# by: PyQt4 UI code generator 4.10.2
#
# WARNING! All changes made in this file will be lost!
import sys
from PyQt4 import QtCore
from PyQt4 import QtGui
from PyQt4.QtGui import QMessageBox
from PyQt4.QtCore import SIGNAL
import psycopg2
import importation
import sriddialog
import ui_srid
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Importation(QtGui.QWidget):
def setupUi(self, UiImportation):
UiImportation.setObjectName(_fromUtf8("UiImportation"))
UiImportation.resize(651, 251)
self.gridLayoutWidget = QtGui.QWidget(UiImportation)
self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 10, 631, 231))
self.gridLayoutWidget.setObjectName(_fromUtf8("gridLayoutWidget"))
self.gridLayout = QtGui.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setMargin(0)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.label_sheet = QtGui.QLabel(self.gridLayoutWidget)
self.label_sheet.setObjectName(_fromUtf8("label_sheet"))
self.gridLayout.addWidget(self.label_sheet, 5, 0, 1, 1)
self.r1 = QtGui.QRadioButton(self.gridLayoutWidget)
self.r1.setObjectName(_fromUtf8("r1"))
self.gridLayout.addWidget(self.r1, 5, 1, 1, 1)
self.r2 = QtGui.QRadioButton(self.gridLayoutWidget)
self.r2.setObjectName(_fromUtf8("r2"))
self.gridLayout.addWidget(self.r2, 5, 2, 1, 1)
self.label_titre = QtGui.QLabel(self.gridLayoutWidget)
font = QtGui.QFont()
font.setFamily(_fromUtf8("Calibri"))
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_titre.setFont(font)
self.label_titre.setObjectName(_fromUtf8("label_titre"))
self.gridLayout.addWidget(self.label_titre, 0, 0, 1, 1)
self.pushButton_Browse = QtGui.QPushButton(self.gridLayoutWidget)
self.pushButton_Browse.setObjectName(_fromUtf8("pushButton_Browse"))
self.gridLayout.addWidget(self.pushButton_Browse, 2, 0, 1, 1)
self.pushButton_srid = QtGui.QPushButton(self.gridLayoutWidget)
self.pushButton_srid.setObjectName(_fromUtf8("pushButton_srid"))
self.gridLayout.addWidget(self.pushButton_srid, 4, 0, 1, 1)
self.pushButton_Import = QtGui.QPushButton(self.gridLayoutWidget)
self.pushButton_Import.setObjectName(_fromUtf8("pushButton_Import"))
self.gridLayout.addWidget(self.pushButton_Import, 7, 4, 1, 1)
self.label_file = QtGui.QLabel(self.gridLayoutWidget)
self.label_file.setObjectName(_fromUtf8("label_file"))
self.gridLayout.addWidget(self.label_file, 1, 0, 1, 1)
self.label_srid = QtGui.QLabel(self.gridLayoutWidget)
self.label_srid.setObjectName(_fromUtf8("label_srid"))
self.gridLayout.addWidget(self.label_srid, 3, 0, 1, 1)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 0, 4, 1, 1)
self.r3 = QtGui.QRadioButton(self.gridLayoutWidget)
self.r3.setObjectName(_fromUtf8("r3"))
self.gridLayout.addWidget(self.r3, 5, 3, 1, 1)
self.lineEdit_pathfile = QtGui.QLineEdit(self.gridLayoutWidget)
self.lineEdit_pathfile.setObjectName(_fromUtf8("lineEdit_pathfile"))
self.gridLayout.addWidget(self.lineEdit_pathfile, 2, 1, 1, 4)
self.lineEdit_srid = QtGui.QLineEdit(self.gridLayoutWidget)
self.lineEdit_srid.setObjectName(_fromUtf8("lineEdit_srid"))
self.gridLayout.addWidget(self.lineEdit_srid, 4, 1, 1, 4)
self.retranslateUi(UiImportation)
QtCore.QMetaObject.connectSlotsByName(UiImportation)
#Connections
self.pushButton_Browse.clicked.connect(self.browseDialog)
self.pushButton_srid.clicked.connect(self.sridDialog)
self.r1.toggled.connect(self.sheetDialog)
self.r2.toggled.connect(self.sheetDialog)
self.r3.toggled.connect(self.sheetDialog)
self.pushButton_Import.clicked.connect(self.validation)
#QtCore.QObject.connect(self.pushButton_Import, QtCore.SIGNAL("clicked()"),UiImportation.close))
#self.lineEdit_srid.textEdited.connect(self.srid)# Code directement entré par l'utilisateur
def retranslateUi(self, UiImportation):
UiImportation.setWindowTitle(_translate("UiImportation", "UiImportation", None))
self.label_titre.setText(_translate("UiImportation", "Data Download", None))
self.pushButton_Browse.setText(_translate("UiImportation", "Browse", None))
self.pushButton_srid.setText(_translate("UiImportation", "SRID", None))
self.pushButton_Import.setText(_translate("UiImportation", "Import", None))
self.label_file.setText(_translate("UiImportation", "Chose a file to import :", None))
self.label_srid.setText(_translate("UiImportation", "Chose a srid :", None))
self.label_sheet.setText(_translate("UiImportation", "Select a sheet", None))
self.r1.setText(_translate("UiImportation", "1", None))
self.r2.setText(_translate("UiImportation", "2", None))
self.r3.setText(_translate("UiImportation", "3", None))
def browseDialog(self):
"""Selection du fichier et affichage du chemin d'accès"""
self.pathfile = QtGui.QFileDialog.getOpenFileName(self, 'Open file', '/home')
self.correctedpathfile= self.pathfile.replace('\\', '/') #Version du chemin pour les requêtes postgresql + xrl
self.lineEdit_pathfile.setText(str(self.correctedpathfile))
return self.correctedpathfile
def sridDialog(self, UiImportation):
"""Ouvre la fentre de selection du code srid """
self.dlg_srid = sriddialog.SridDialog()
self.dlg_srid.show()
result_srid =self.dlg_srid.exec_()
"""Retrun le srid """
self.uisrid = ui_srid.Ui_Srid()
self.srid_selected =self.uisrid.returnSRID
self.lineEdit_srid.setText(str(self.srid_selected))
return self.srid_selected
#return <bound method Ui_Srid.returnSRID of <PostgisConnection.ui_srid.Ui_Srid object at 0x000000000ECEB1E0>>
def sheetDialog( self, UiImportation) :
self.index =0
if self.r1.isChecked():
self.index=1
elif self.r2.isChecked():
self.index=2
elif self.r3.isChecked():
self.index=3
return self.index
def validation(self, UiImportation):
"""Lance le processus d'importation si les champs sont correctement remplis"""
if self.lineEdit_pathfile.text()=='' or self.lineEdit_srid.text()=='':
QMessageBox.information(self, "Error Box", "Some required fields are missing, Please complete the form.")
elif self.r1.isChecked() or self.r2.isChecked() or self.r3.isChecked() :
self.dlg_import= importation.Importation()
else:
QMessageBox.information(self, "Error Box", "Select a sheet please") |
Partager