def Home(self): from Home import Main self.ventana = Main() self.ventana.show() self.ventana.setWindowState(Qt.WindowNoState)
class Main_DB(QMainWindow): pathFileName = "" nombre_BD = "Base.db" nombre_tabla = "" def __init__(self, parent=None): super(Main_DB, self).__init__(parent) self.setWindowTitle("EXADATA") self.setFixedSize(800, 600) self.setWindowIcon(QIcon("icono.jpg")) self.centralwidget = QtWidgets.QWidget(self) self.centralwidget.setObjectName("centralwidget") # FRAME paleta = QPalette() paleta.setColor(QPalette.Background, QColor(51, 0, 102)) frame = QFrame(self) frame.setFrameShape(QFrame.NoFrame) frame.setFrameShadow(QFrame.Sunken) frame.setAutoFillBackground(True) frame.setPalette(paleta) frame.setFixedWidth(800) frame.setFixedHeight(100) frame.move(0, 0) labelIcono = QLabel(frame) labelIcono.setFixedWidth(65) labelIcono.setFixedHeight(65) labelIcono.setPixmap( QPixmap("icono.jpg").scaled(65, 65, Qt.KeepAspectRatio, Qt.SmoothTransformation)) labelIcono.move(10, 28) fuenteTitulo = QFont() fuenteTitulo.setPointSize(25) fuenteTitulo.setBold(True) labelTitulo = QLabel("<font color='white'>EXADATA</font>", frame) labelTitulo.setFont(fuenteTitulo) labelTitulo.move(85, 30) fuenteSubtitulo = QFont() fuenteSubtitulo.setPointSize(13) labelSubtitulo = QLabel("<font color='white'>Análisis de Tweets ", frame) labelSubtitulo.setFont(fuenteSubtitulo) labelSubtitulo.move(85, 68) #BARRA self.progressBar = QtWidgets.QProgressBar(self.centralwidget) self.progressBar.setGeometry(QtCore.QRect(10, 400, 375, 23)) self.progressBar.setProperty("value", 24) self.progressBar.setTextVisible(False) self.progressBar.setObjectName("progressBar") #inicio tabla self.tabla = QtWidgets.QTableWidget(self.centralwidget) self.tabla.setGeometry(QtCore.QRect(10, 110, 500, 400)) self.tabla.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.tabla.setSizeAdjustPolicy( QtWidgets.QAbstractScrollArea.AdjustToContents) self.tabla.setColumnCount(3) self.tabla.setObjectName("tabla") self.tabla.setRowCount(0) item = QtWidgets.QTableWidgetItem() self.tabla.setHorizontalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() self.tabla.setHorizontalHeaderItem(1, item) item = QtWidgets.QTableWidgetItem() self.tabla.setHorizontalHeaderItem(2, item) self.tabla.horizontalHeader().setDefaultSectionSize(165) self.tabla.horizontalHeader().setStretchLastSection(True) self.tabla.verticalHeader().setStretchLastSection(False) self.tabla.cellClicked.connect(self.clic) #fin tabla self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(510, 70, 151, 16)) self.label.setObjectName("label") #qlineedit nombre base self.input_nombre_bd = QtWidgets.QLineEdit(self.centralwidget) self.input_nombre_bd.setGeometry(QtCore.QRect(550, 130, 170, 20)) self.input_nombre_bd.setObjectName("input_nombre_bd") # label #label nombre_bd self.label_nombre_base = QtWidgets.QLabel(self.centralwidget) self.label_nombre_base.setGeometry(QtCore.QRect(550, 110, 180, 20)) self.label_nombre_base.setObjectName("label_nombre_base") # label editar_bd self.label_editar_bd = QtWidgets.QLabel(self.centralwidget) self.label_editar_bd.setGeometry(QtCore.QRect(550, 230, 180, 16)) self.label_editar_bd.setObjectName("label_editar_bd") # BOTONES #boton importar self.bt_importar = QtWidgets.QPushButton(self.centralwidget) self.bt_importar.setGeometry(QtCore.QRect(550, 160, 170, 21)) self.bt_importar.setObjectName("bt_importar") # boton agregar_bd self.bt_agregar_bd = QtWidgets.QPushButton(self.centralwidget) self.bt_agregar_bd.setGeometry(QtCore.QRect(550, 260, 170, 21)) self.bt_agregar_bd.setObjectName("bt_agregar_bd") self.bt_agregar_bd.clicked.connect(self.Anadir) # boton eliminar_bd self.bt_eliminar_bt = QtWidgets.QPushButton(self.centralwidget) self.bt_eliminar_bt.setGeometry(QtCore.QRect(550, 290, 170, 21)) self.bt_eliminar_bt.setObjectName("bt_eliminar_bt") self.bt_eliminar_bt.clicked.connect(self.BorrarTabla) # boton exportar_bd self.bt_exportar_bd = QtWidgets.QPushButton(self.centralwidget) self.bt_exportar_bd.setGeometry(QtCore.QRect(550, 320, 170, 21)) self.bt_exportar_bd.setObjectName("bt_exportar_bd") self.bt_exportar_bd.clicked.connect(self.ExportarBase) # boton recarga_bd self.bt_recarga_bd = QtWidgets.QPushButton(self.centralwidget) self.bt_recarga_bd.setGeometry(QtCore.QRect(10, 520, 500, 21)) self.bt_recarga_bd.setObjectName("bt_recarga_bd") self.bt_recarga_bd.clicked.connect(self.CargarTabla) #================================================================================= self.setCentralWidget(self.centralwidget) # BARRA MENU self.menubar = QtWidgets.QMenuBar(self) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21)) self.menubar.setObjectName("menubar") self.Programas = QtWidgets.QMenu(self.menubar) self.BaseDeDatos = QtWidgets.QAction(self) self.menubar.addAction(self.Programas.menuAction()) self.Programas.addAction(self.BaseDeDatos) self.Ayuda = QtWidgets.QMenu(self.menubar) self.SobreQue = QtWidgets.QAction(self) self.menubar.addAction(self.Ayuda.menuAction()) self.Ayuda.addAction(self.SobreQue) self.retranslateUi() self.tabla_master() self.CargarTabla() self.progressBar.hide() def retranslateUi(self): _translate = QtCore.QCoreApplication.translate #MainBD.setWindowTitle(_translate("MainBD", "Base De Datos")) # BARRA MENU self.Programas.setTitle(_translate("MainBD", "Programas")) self.BaseDeDatos.setText(_translate("MainBD", "Salir")) self.Ayuda.setTitle(_translate("MainBD", "Ayuda")) self.SobreQue.setText(_translate("MainBD", "Sobre Que")) self.SobreQue.triggered.connect(self.AYUDA) self.BaseDeDatos.triggered.connect(self.close) #inicio tabla item = self.tabla.horizontalHeaderItem(0) item.setText(_translate("MainBD", "NOMBRE")) item = self.tabla.horizontalHeaderItem(1) item.setText(_translate("MainBD", "FECHA DESDE")) item = self.tabla.horizontalHeaderItem(2) item.setText(_translate("MainBD", "FECHA HASTA")) #fin tabla self.label.setText(_translate("MainBD", "CREACIÓN DE BASE DE DATOS")) self.label_nombre_base.setText( _translate("MainBD", "NOMBRE DE LA NUEVA BASE:")) self.bt_importar.setText(_translate("MainBD", "IMPORTAR")) self.bt_importar.clicked.connect(self.CargarCSV) self.label_editar_bd.setText( _translate("MainBD", "EDITAR BASE DE DATOS")) self.bt_agregar_bd.setText(_translate("MainBD", "AGREGAR BASE")) self.bt_eliminar_bt.setText(_translate("MainBD", "ELIMINAR BASE")) self.bt_exportar_bd.setText(_translate("MainBD", "EXPORTAR")) self.bt_recarga_bd.setText(_translate("MainBD", "RECARGAR TABLA")) def clic(self): a = self.tabla.currentRow() self.tabla.selectRow(a) def Comprobar_texto(self, texto): #return 0 incorrecto #return 1 correcto if texto == "": #print("vacio") return 0 self.alerta_tabla() elif texto == "Union" or texto == "UNION" or texto == "union": return 0 self.alerta_tabla() elif texto != "": if texto.isalnum( ) and len(texto) <= 30: # Comprobemos que es valida return 1 else: return 0 def CargarCSV(self): nombre_tabla = self.input_nombre_bd.text() dir = "" try: if self.Comprobar_texto(nombre_tabla) == 0: self.alerta_tabla() else: query = 'SELECT min(created_at), max(created_at),count(*) from ' + nombre_tabla print(query) db_rows = self.run_query(query) print("TABLA EXISTENTE") buttonReply = QMessageBox.question( self, 'BASE YA EXISTENTE', "Quieres añadir la base agregada a la base ya existente?", QMessageBox.Yes | QMessageBox.No) if buttonReply == QMessageBox.Yes: print('Si clicked.') dir, _ = QtWidgets.QFileDialog.getOpenFileName( None, 'Seleccionar archivo', '', 'csv(*.csv)') if dir: f = open(dir, 'rb') return dir print(nombre_tabla) self.hiloagrega = Hiloagregar(nombre_tabla, self.nombre_BD, dir) self.hiloagrega.start() self.hiloagrega.taskFinished.connect(self.Cargado) self.hiloagrega.taskFinished.connect(self.CargarTabla) if buttonReply == QMessageBox.No: print('No clicked.') except: print("NO EXISTE") if self.Comprobar_texto(nombre_tabla) == 0: self.alerta_tabla() else: try: dir, _ = QtWidgets.QFileDialog.getOpenFileName( None, 'Seleccionar archivo', '', 'csv(*.csv)') if dir: f = open(dir, 'rb') print(dir) buttonReply = QMessageBox.question( self, 'GUARDAR BASE', "Quieres guardar la base de " + nombre_tabla + "?", QMessageBox.Yes | QMessageBox.No) if buttonReply == QMessageBox.Yes: print('Si clicked.') self.progressBar.show() self.progressBar.setRange(0, 0) self.BLOQUEO() self.hilocarga = Hilocargar( nombre_tabla, self.nombre_BD, dir) self.hilocarga.start() self.hilocarga.taskFinished.connect(self.Importado) self.hilocarga.taskFinished.connect( self.CargarTabla) self.hilocarga.taskFinishedBarra.connect( self.STOPBARRA) if buttonReply == QMessageBox.No: print('No clicked.') print(dir) else: print("CANCELADO") except: print("") def Importado(self): QMessageBox.warning(self.centralwidget, "IMPORTACION CORRECTA", "IMPORTACION DE BASE TERMINADA.") def Exportado(self): QMessageBox.warning(self.centralwidget, "EXPORTACION CORRECTA", "EXPORTACION DE BASE TERMINADA.") def Eliminado(self): QMessageBox.warning(self.centralwidget, "ELIMINACION DE BASE COMPLETADA", "ELIMINACION DE BASE COMPLETADA.") def ALERTA(self): QMessageBox.warning(self.centralwidget, "BASE NO SELECCIONADA", "POR FAVOR, SELECCIONE LA BASE A TRABAJAR.") def Cargado(self): QMessageBox.warning(self.centralwidget, "CARGA BASE CORRECTA", "CARGA DE BASE TERMINADA.") def tabla_master(self): table = "Master" query = '''CREATE TABLE IF NOT EXISTS ''' + table + ''' (tabla text, fecha_inicio text , fecha_termino text, cantidad text)''' self.run_query(query) def run_query(self, query, parameters=()): with sqlite3.connect(self.nombre_BD) as conn: cursor = conn.cursor() result = cursor.execute(query, parameters) conn.commit() return result def CargarTabla(self): index = 0 query = 'SELECT tabla,fecha_inicio,fecha_termino FROM Master' print(query) db_rows = self.run_query(query) for row in db_rows: self.tabla.setRowCount(index + 1) self.tabla.setItem(index, 0, QTableWidgetItem(row[0])) self.tabla.setItem(index, 1, QTableWidgetItem(row[1])) self.tabla.setItem(index, 2, QTableWidgetItem(row[2])) index += 1 def BorrarTabla(self): try: #a = self.tabla.currentRow() #self.tabla.selectRow(a) selected = self.tabla.currentIndex() nombre = self.tabla.selectedItems()[0].text() print(nombre) buttonReply = QMessageBox.question( self, 'ELIMINAR BASE', "QUIERES BORRAR LA BASE " + nombre + "?", QMessageBox.Yes | QMessageBox.No) if buttonReply == QMessageBox.Yes: print('Si clicked.') self.progressBar.show() self.progressBar.setRange(0, 0) self.BLOQUEO() self.hiloeliminar = Hiloeliminar(nombre, self.nombre_BD) self.hiloeliminar.start() self.tabla.removeRow(selected.row()) self.hiloeliminar.taskFinished.connect(self.Eliminado) self.hiloeliminar.taskFinishedBarra.connect(self.STOPBARRA) if buttonReply == QMessageBox.No: print('No clicked.') except: self.ALERTA() def ExportarBase(self): try: base = self.tabla.selectedItems()[0].text() dir, _ = QtWidgets.QFileDialog.getSaveFileName( None, 'Guardar archivo', '', 'csv(*.csv)') print(dir) if dir: self.progressBar.show() self.progressBar.setRange(0, 0) self.BLOQUEO() self.thread = Hiloexportar(base, self.nombre_BD, dir) self.thread.start() self.thread.taskFinished.connect(self.Exportado) self.thread.taskFinishedBarra.connect(self.STOPBARRA) else: print("CANCELADO") except: self.ALERTA() def Anadir(self): dir = "" try: base = self.tabla.selectedItems()[0].text() print(base) dir, _ = QtWidgets.QFileDialog.getOpenFileName( None, 'Seleccionar archivo', '', 'csv(*.csv)') if dir: f = open(dir, 'rb') print(dir) self.progressBar.show() self.progressBar.setRange(0, 0) self.BLOQUEO() self.hiloagrega = Hiloagregar(base, self.nombre_BD, dir) self.hiloagrega.start() self.hiloagrega.taskFinished.connect(self.Cargado) self.hiloagrega.taskFinishedBarra.connect(self.STOPBARRA) self.hiloagrega.taskFinished.connect(self.CargarTabla) except: self.ALERTA() def Home(self): from Home import Main self.ventana = Main() self.ventana.show() self.ventana.setWindowState(Qt.WindowNoState) def closeEvent(self, event): close = QMessageBox.question( self, "Salir", "Estas seguro que quieres salir de la Ayuda?", QMessageBox.Yes | QMessageBox.No) if close == QMessageBox.Yes: print("cerro") self.Home() else: print("") def alerta_tabla(self): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("Campo de texto no valido") msg.setWindowTitle("Error") msg.setStandardButtons(QMessageBox.Ok) msg.exec() def AYUDA(self): from Ayuda import Main_Ayuda self.ayuda = Main_Ayuda() self.ayuda.show() self.hide() def STOPBARRA(self): self.progressBar.setRange(0, 1) self.progressBar.hide() self.bt_recarga_bd.setEnabled(True) self.bt_exportar_bd.setEnabled(True) self.bt_agregar_bd.setEnabled(True) self.bt_eliminar_bt.setEnabled(True) self.bt_importar.setEnabled(True) def BLOQUEO(self): self.bt_recarga_bd.setEnabled(False) self.bt_exportar_bd.setEnabled(False) self.bt_agregar_bd.setEnabled(False) self.bt_eliminar_bt.setEnabled(False) self.bt_importar.setEnabled(False)
class Main_Cortar(QMainWindow): pathFileName = "" nombre_BD = "Base.db" nombre_tabla = "" def __init__(self, parent=None): super(Main_Cortar, self).__init__(parent) self.setWindowTitle("EXADATA") self.setFixedSize(800, 600) self.setWindowIcon(QIcon("icono.jpg")) self.centralwidget = QtWidgets.QWidget(self) self.centralwidget.setObjectName("centralwidget") # FRAME paleta = QPalette() paleta.setColor(QPalette.Background, QColor(51, 0, 102)) frame = QFrame(self) frame.setFrameShape(QFrame.NoFrame) frame.setFrameShadow(QFrame.Sunken) frame.setAutoFillBackground(True) frame.setPalette(paleta) frame.setFixedWidth(800) frame.setFixedHeight(100) frame.move(0, 0) labelIcono = QLabel(frame) labelIcono.setFixedWidth(65) labelIcono.setFixedHeight(65) labelIcono.setPixmap(QPixmap("icono.jpg").scaled(65, 65, Qt.KeepAspectRatio, Qt.SmoothTransformation)) labelIcono.move(10, 28) fuenteTitulo = QFont() fuenteTitulo.setPointSize(25) fuenteTitulo.setBold(True) labelTitulo = QLabel("<font color='white'>EXADATA</font>", frame) labelTitulo.setFont(fuenteTitulo) labelTitulo.move(85, 30) fuenteSubtitulo = QFont() fuenteSubtitulo.setPointSize(13) labelSubtitulo = QLabel("<font color='white'>Análisis de Tweets " , frame) labelSubtitulo.setFont(fuenteSubtitulo) labelSubtitulo.move(85, 68) # BARRA self.progressBar = QtWidgets.QProgressBar(self.centralwidget) self.progressBar.setGeometry(QtCore.QRect(10, 480, 510, 23)) self.progressBar.setProperty("value", 24) self.progressBar.setTextVisible(False) self.progressBar.setObjectName("progressBar") #inicio tabla self.tabla = QtWidgets.QTableWidget(self.centralwidget) # formato tabla posx,posy,tamx,tamy self.tabla.setGeometry(QtCore.QRect(10, 110, 500, 400)) self.tabla.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.tabla.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents) self.tabla.setColumnCount(4) self.tabla.setObjectName("tabla") self.tabla.setRowCount(0) item = QtWidgets.QTableWidgetItem() self.tabla.setHorizontalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() self.tabla.setHorizontalHeaderItem(1, item) item = QtWidgets.QTableWidgetItem() self.tabla.setHorizontalHeaderItem(2, item) item = QtWidgets.QTableWidgetItem() self.tabla.setHorizontalHeaderItem(3, item) self.tabla.horizontalHeader().setDefaultSectionSize(120) self.tabla.horizontalHeader().setStretchLastSection(True) self.tabla.verticalHeader().setStretchLastSection(False) self.tabla.cellClicked.connect(self.ConsultarFecha) #fin tabla # BOTONES # boton exportar self.bt_exportar_bd = QtWidgets.QPushButton(self.centralwidget) self.bt_exportar_bd.setGeometry(QtCore.QRect(525, 360, 120, 20)) self.bt_exportar_bd.setObjectName("bt_exportar_bd") self.bt_exportar_bd.clicked.connect(self.Exportar_Fecha) # boton recarga self.bt_recarga_bd = QtWidgets.QPushButton(self.centralwidget) self.bt_recarga_bd.setGeometry(QtCore.QRect(10, 520, 500, 20)) self.bt_recarga_bd.setObjectName("bt_recarga_bd") self.bt_recarga_bd.clicked.connect(self.CargarTabla) #================================================================================= self.setCentralWidget(self.centralwidget) #CALENDARIO # formato tabla posx,posy,tamx,tamy self.calendario = QtWidgets.QCalendarWidget(self.centralwidget) self.calendario.setGeometry(QtCore.QRect(525, 110, 255, 155)) self.calendario.setStyleSheet("") self.calendario.setStyleSheet("alternate-background-color: rgb(118, 148, 255);") self.calendario.setObjectName("calendario") #LABEL MUESTRA POR FECHA self.label_muestraFecha = QtWidgets.QLabel(self.centralwidget) self.label_muestraFecha.setGeometry(QtCore.QRect(525, 280, 120, 20)) self.label_muestraFecha.setObjectName("label_muestraFecha") # QdateEdit desde - hasta self.fechaInicio = QtWidgets.QDateEdit(self.centralwidget) self.fechaInicio.setGeometry(QtCore.QRect(525, 325, 120, 22)) self.fechaInicio.setObjectName("fechaInicio") self.fechaInicio.setCalendarPopup(True) self.fechaTermino = QtWidgets.QDateEdit(self.centralwidget) self.fechaTermino.setGeometry(QtCore.QRect(670, 325, 120, 22)) self.fechaTermino.setObjectName("fechaTermino") self.fechaTermino.setCalendarPopup(True) self.fechaInicio.setDate(QtCore.QDate.currentDate()) self.fechaTermino.setDate(QtCore.QDate.currentDate()) # label fecha desde - hasta self.incioLetra = QtWidgets.QLabel(self.centralwidget) self.incioLetra.setGeometry(QtCore.QRect(525, 300, 120, 20)) self.incioLetra.setObjectName("incioLetra") self.terminoLetra = QtWidgets.QLabel(self.centralwidget) self.terminoLetra.setGeometry(QtCore.QRect(670, 300, 120, 20)) self.terminoLetra.setObjectName("terminoLetra") # BARRA MENU self.menubar = QtWidgets.QMenuBar(self) self.menubar.setGeometry(QtCore.QRect(0, 0, 1000, 21)) self.menubar.setObjectName("menubar") self.Programas = QtWidgets.QMenu(self.menubar) self.BaseDeDatos = QtWidgets.QAction(self) self.menubar.addAction(self.Programas.menuAction()) self.Programas.addAction(self.BaseDeDatos) self.BaseDeDatos.triggered.connect(self.close) self.Ayuda = QtWidgets.QMenu(self.menubar) self.SobreQue = QtWidgets.QAction(self) self.menubar.addAction(self.Ayuda.menuAction()) self.Ayuda.addAction(self.SobreQue) self.SobreQue.triggered.connect(self.AYUDA) self.retranslateUi(self) QtCore.QMetaObject.connectSlotsByName(self) #new table self.tabla_master() self.CargarTabla() self.progressBar.hide() def retranslateUi(self, MainBD): _translate = QtCore.QCoreApplication.translate MainBD.setWindowTitle(_translate("MainBD", "Cortar Fecha")) # BARRA MENU self.Programas.setTitle(_translate("MainBD", "Programas")) self.BaseDeDatos.setText(_translate("MainBD", "Salir")) self.Ayuda.setTitle(_translate("MainBD", "Ayuda")) self.SobreQue.setText(_translate("MainBD", "Sobre Que")) #inicio tabla item = self.tabla.horizontalHeaderItem(0) item.setText(_translate("MainBD", "NOMBRE")) item = self.tabla.horizontalHeaderItem(1) item.setText(_translate("MainBD", "FECHA DESDE")) item = self.tabla.horizontalHeaderItem(2) item.setText(_translate("MainBD", "FECHA HASTA")) item = self.tabla.horizontalHeaderItem(3) item.setText(_translate("MainBD", "TWEETS")) self.incioLetra.setText(_translate("MainBD", "FECHA INICIO")) self.terminoLetra.setText(_translate("MainBD", "FECHA TERMINO")) #fin tabla #LABEL self.label_muestraFecha.setText(_translate("MainBD", "CORTAR POR FECHA")) #self.label_muestraToda.setText(_translate("MainBD", "MUESTRA POR CANTIDAD DE TWEETS")) self.bt_exportar_bd.setText(_translate("MainBD", "EXPORTAR")) self.bt_recarga_bd.setText(_translate("MainBD", "RECARGAR TABLA")) def run_query(self, query, parameters=()): with sqlite3.connect(self.nombre_BD) as conn: cursor = conn.cursor() result = cursor.execute(query, parameters) conn.commit() return result def CargarTabla(self): index = 0 query = 'SELECT tabla,strftime("%d-%m-%Y",(fecha_inicio)),strftime("%d-%m-%Y",(fecha_termino)), cantidad FROM Master' print(query) db_rows = self.run_query(query) for row in db_rows: self.tabla.setRowCount(index + 1) self.tabla.setItem(index, 0, QTableWidgetItem(row[0])) self.tabla.setItem(index, 1, QTableWidgetItem(row[1])) self.tabla.setItem(index, 2, QTableWidgetItem(row[2])) self.tabla.setItem(index, 3, QTableWidgetItem(str(row[3]))) index += 1 def ConsultarFecha(self): #tabla = self.tabla.selectedItems()[0].text() #tabla = self.tabla.selectedItems()[3].text() a = self.tabla.currentRow() self.tabla.selectRow(a) #b = self.tabla.currentColumn() f_desde = self.tabla.item(a,1).text() f_hasta = self.tabla.item(a,2).text() year = f_desde[6:10] day = f_desde[0:2] month = f_desde[3:5] #print(month) self.fechaInicio.setDate(QtCore.QDate(int(year),int(month),int(day))) year = f_hasta[6:10] day = f_hasta[0:2] month = f_hasta[3:5] # print(month) self.fechaTermino.setDate(QtCore.QDate(int(year), int(month), int(day))) def Exportar_Fecha(self): base = self.tabla.selectedItems()[0].text() fecha_inicio = self.fechaInicio.date().toString("yyyy-MM-dd") fecha_termino = self.fechaTermino.date().toString("yyyy-MM-dd") dir, _ = QtWidgets.QFileDialog.getSaveFileName(None, 'Guardar archivo', base, 'csv(*.csv)') print(dir) self.progressBar.show() self.progressBar.setRange(0, 0) self.BLOQUEO() self.thread = HiloexportarFecha(base, fecha_inicio, fecha_termino, self.nombre_BD, dir) self.thread.start() self.thread.taskFinished.connect(self.Exportado) self.thread.taskFinishedBarra.connect(self.STOPBARRA) def Exportado(self): QMessageBox.warning(self.centralwidget, "EXPORTACION CORRECTA", "EXPORTACION DE BASE TERMINADA.") def closeEvent(self, event): close = QMessageBox.question(self, "Salir", "Estas seguro que quieres salir?", QMessageBox.Yes | QMessageBox.No) if close == QMessageBox.Yes: self.Home() else: event.ignore() def AYUDA(self): from Ayuda import Main_Ayuda self.ventana = Main_Ayuda() self.ventana.show() self.hide() def Home(self): from Home import Main self.ventana = Main() self.ventana.show() self.ventana.setWindowState(Qt.WindowNoState) def tabla_master(self): table = "Master" query = '''CREATE TABLE IF NOT EXISTS ''' + table + ''' (tabla text, fecha_inicio text , fecha_termino text, cantidad text)''' self.run_query(query) def STOPBARRA(self): self.progressBar.setRange(0,1) self.progressBar.hide() self.bt_exportar_bd.setEnabled(True) self.bt_recarga_bd.setEnabled(True) def BLOQUEO(self): self.bt_exportar_bd.setEnabled(False) self.bt_recarga_bd.setEnabled(False)
class Main_Ayuda(QMainWindow): def __init__(self, parent=None): super(Main_Ayuda, self).__init__(parent) self.setWindowTitle("EXADATA (AYUDA)") self.setFixedSize(800, 600) self.setWindowIcon(QIcon("icono.jpg")) # FRAME paleta = QPalette() paleta.setColor(QPalette.Background, QColor(51, 0, 102)) frame = QFrame(self) frame.setFrameShape(QFrame.NoFrame) frame.setFrameShadow(QFrame.Sunken) frame.setAutoFillBackground(True) frame.setPalette(paleta) frame.setFixedWidth(800) frame.setFixedHeight(100) frame.move(0, 0) labelIcono = QLabel(frame) labelIcono.setFixedWidth(65) labelIcono.setFixedHeight(65) labelIcono.setPixmap( QPixmap("icono.jpg").scaled(65, 65, Qt.KeepAspectRatio, Qt.SmoothTransformation)) labelIcono.move(10, 28) fuenteTitulo = QFont() fuenteTitulo.setPointSize(25) fuenteTitulo.setBold(True) labelTitulo = QLabel("<font color='white'>EXADATA</font>", frame) labelTitulo.setFont(fuenteTitulo) labelTitulo.move(85, 30) fuenteSubtitulo = QFont() fuenteSubtitulo.setPointSize(13) labelSubtitulo = QLabel("<font color='white'>Análisis de Tweets ", frame) labelSubtitulo.setFont(fuenteSubtitulo) labelSubtitulo.move(85, 68) # LOGO self.centralwidget = QtWidgets.QWidget(self) self.setCentralWidget(self.centralwidget) # CUADRO TEXTO self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget) self.textBrowser.setGeometry(QtCore.QRect(10, 110, 780, 480)) def Home(self): from Home import Main self.ventana = Main() self.ventana.show() self.ventana.setWindowState(Qt.WindowNoState) def closeEvent(self, event): close = QMessageBox.question( self, "Salir", "Estas seguro que quieres salir de la Ayuda?", QMessageBox.Yes | QMessageBox.No) if close == QMessageBox.Yes: print("cerro") self.Home() else: print("") def retranslateUi(self, MainBD): _translate = QtCore.QCoreApplication.translate def CUADROTEXTO(self): self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget) self.textBrowser.setHtml(( "MainBD", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p align=\"justify\" style=\" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt; font-weight:600;\">Ayuda de EXADATA</span><span style=\" font-size:8pt;\"> </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> </span></p>\n" "<p align=\"justify\" style=\" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt; font-weight:600;\">¿Cómo cambiar el tema de EXADATA?</span><span style=\" font-size:8pt;\"> </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">El tema oscuro permite disminuir el brillo de la pantalla, para utilizar EXADATA con un fondo oscuro. Pero además posee la opción de utilizar un fondo claro, y se realiza de la siguiente forma: </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 1.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Seleccionar la pestaña configuración. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 2.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Posicionar el mouse sobre la pestaña apariencia. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 3.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Escoger entre el tema oscuro y claro del programa. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> </span></p>\n" "<p align=\"justify\" style=\" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt; font-weight:600;\">¿Cómo limpiar una base?</span><span style=\" font-size:8pt;\"> </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Cuando hablamos de limpiar una base, nos referimos a quitar de un CSV todos aquellos tweets (líneas de la base) que se repitan. Para esto no es necesario utilizar ninguna de las aplicaciones, puesto que EXADATA posee la capacidad de limpiar la base cuando la subimos/importamos al programa. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> </span></p>\n" "<p align=\"justify\" style=\" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt; font-weight:600;\">Subir/Importar bases de datos (CSV) a la aplicación</span><span style=\" font-size:8pt;\"> </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Para poder subir una base de datos a EXADATA debemos tener en consideración, que el programa solo acepta archivos en formato CSV. Para poder hacerlo debemos seguir los siguientes pasos: </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 1.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Seleccionamos la pestaña programas. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 2.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Una vez se despliegue el menú de programas, elegimos Base de datos donde se despliega una nueva ventana. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 3.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Para subir un archivo CSV y visualizarlo en la tabla de EXADATA, nos ubicamos en la parte superior derecha en donde debemos escribir el nombre con el que queremos guardar la base. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 4.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Una vez escrito el nombre, podemos seleccionar el botón importar desde donde podremos seleccionar el archivo CSV desde nuestro computador. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 5.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">El programa nos pregunta si queremos guardar la base con dicho nombre, para que aparezca en el programa, debemos seleccionar 'Yes'. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 6.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Si el archivo se ha subido correctamente nos muestra una alerta a la que debemos poner ok. </span></p>\n" "<p align=\"justify\" style=\"-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><br /></p>\n" "<p align=\"justify\" style=\" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt; font-weight:600;\">¿Cómo eliminar una base de la tabla de EXADATA?</span><span style=\" font-size:8pt;\"> </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Eliminar base nos sirve para despejar la tabla del programa cuando no necesitemos utilizar las bases que ya se encuentran almacenadas, para hacerlo debemos seguir estos pasos: </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 1.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Seleccionar el nombre de la tabla que deseamos eliminar, pinchando sobre su nombre. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 2.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Presionamos el botón Eliminar base que se encuentra en la esquina inferior derecha. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 3.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Nos aparece una alerta que nos avisa si estamos seguros o no de borrar la base en cuestión. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 4.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Si la respuesta es YES, la base es quitada de la tabla de EXADATA. </span></p>\n" "<p align=\"justify\" style=\" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt; font-weight:600;\"> </span><span style=\" font-size:8pt;\"> </span></p>\n" "<p align=\"justify\" style=\" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt; font-weight:600;\">¿Cómo unir dos o más bases? </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> EXADATA posee la capacidad de juntar distintas bases en una sola, para poder realizar un análisis de bases afines, es por eso que posee una función extra de unión de bases. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Esto se realiza de la siguiente forma: </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 1.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Subimos la base la cual queremos sea la base raíz a la cual se unirán las otras bases, si es que no tenemos la base en EXADATA. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 2.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">La seleccionamos, y la opción Agregar base </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 3.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Se despliega una ventana para seleccionar la base que queremos pegar. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 4.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Seleccionamos el archivo y se debe seleccionar Abrir. </span></p>\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> 5.</span><span style=\" font-family:\'Times New Roman\'; font-size:7pt;\"> </span><span style=\" font-size:8pt;\">Ahora la base raíz puede trabajarse como cualquier otra dentro de la aplicación, además tenemos la opción de exportarla. </span></p>\n" "<p align=\"justify\" style=\"-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><br /></p></body></html>" ))
def AYUDA(self): from Ayuda import Main_Ayuda self.ventana = Main_Ayuda() self.ventana.show() self.hide()