Skip to main content
.
Origen Enlace
    from PyQt5 import QtCore
from PyQt5.QtWidgets import QTableWidgetItem
from FirebaseProjectLogin import *
import threading

class Worker(QtCore.QObject):
    started = QtCore.pyqtSignal()
    finished =QtCore.pyqtSignal()



    @QtCore.pyqtSlot()
    def iniciar_conexion(self):
        self.started.emit(1)
        self.Tabla.setRowCount(0)

        totalMatutino = "0"


        ref = db.reference("/")
        ret = ref.get()

        for key in ret.items():

            if key[0][:7]==str(self.Fecha):
                for key1 in key[1].items():
                    if key1[0]==self.Sucursal:
                        for key2 in key1[1].items():
                            if key2[0] == "Matutino":
                                for key3 in key2[1].items():
                                    if key3[0] == "15:00":
                                        for key5 in key3[1].items():
                                            if key5[0]=="total":
                                                totalMatutino = key5[1]

                                                self.Tabla.insertRow(self.currentRow)

                                        self.Tabla.setItem(self.currentRow,5,QTableWidgetItem(totalMatutino))

 

self.finished.emit()

class DatosGeneralesClass():

    def __init__(self,mes,sucursal,ano,tabla,status,boton):

        self.Mes = "01"
        self.Sucursal = "Exxe 1"

        self.Ano = "2018"
        self.Tabla = tabla
        self.currentRow = self.Tabla.rowCount()
        self.Fecha = self.Ano+"-"+self.Mes
        self.Status =status

        ano.currentIndexChanged.connect(lambda:self.updateAno(ano.currentText()))

        self._worker = Worker()
        self._worker.started.connect(self.on_started)
        self.__worker.finished.connect(self.on_finished)
        thread = QtCore.QThread(self)
        self._worker.moveToThread(thread)

    @QtCore.pyqtSlot()
    def on_started(self):
        self.DStatus.setText("Cargando")
    @QtCore.pyqtSlot()
    def on_finished(self):
        self.DStatus.setText("complete")



    @QtCore.pyqtSlot(str)
    def updateAno(self,ano):

        self.Ano = ano
        self.Fecha = self.Ano+"-"+self.Mes

        self.conectar()

    @QtCore.pyqtSlot()
    def conectar(self):
        QtCore.QTimer.singleShot(0,self._worker.iniciar_conexion)
    from PyQt5 import QtCore
from PyQt5.QtWidgets import QTableWidgetItem
from FirebaseProjectLogin import *
import threading

class Worker(QtCore.QObject):
    started = QtCore.pyqtSignal()
    finished =QtCore.pyqtSignal()



    @QtCore.pyqtSlot()
    def iniciar_conexion(self):
        self.started.emit(1)
        self.Tabla.setRowCount(0)

        totalMatutino = "0"


        ref = db.reference("/")
        ret = ref.get()

        for key in ret.items():

            if key[0][:7]==str(self.Fecha):
                for key1 in key[1].items():
                    if key1[0]==self.Sucursal:
                        for key2 in key1[1].items():
                            if key2[0] == "Matutino":
                                for key3 in key2[1].items():
                                    if key3[0] == "15:00":
                                        for key5 in key3[1].items():
                                            if key5[0]=="total":
                                                totalMatutino = key5[1]

                                                self.Tabla.insertRow(self.currentRow)

                                        self.Tabla.setItem(self.currentRow,5,QTableWidgetItem(totalMatutino))

 
class DatosGeneralesClass():

    def __init__(self,mes,sucursal,ano,tabla,status,boton):

        self.Mes = "01"
        self.Sucursal = "Exxe 1"

        self.Ano = "2018"
        self.Tabla = tabla
        self.currentRow = self.Tabla.rowCount()
        self.Fecha = self.Ano+"-"+self.Mes
        self.Status =status

        ano.currentIndexChanged.connect(lambda:self.updateAno(ano.currentText()))

        self._worker = Worker()
        self._worker.started.connect(self.on_started)
        self.__worker.finished.connect(self.on_finished)
        thread = QtCore.QThread(self)
        self._worker.moveToThread(thread)

    @QtCore.pyqtSlot()
    def on_started(self):
        self.DStatus.setText("Cargando")
    @QtCore.pyqtSlot()
    def on_finished(self):
        self.DStatus.setText("complete")



    @QtCore.pyqtSlot(str)
    def updateAno(self,ano):

        self.Ano = ano
        self.Fecha = self.Ano+"-"+self.Mes

        self.conectar()

    @QtCore.pyqtSlot()
    def conectar(self):
        QtCore.QTimer.singleShot(0,self._worker.iniciar_conexion)
    from PyQt5 import QtCore
from PyQt5.QtWidgets import QTableWidgetItem
from FirebaseProjectLogin import *
import threading

class Worker(QtCore.QObject):
    started = QtCore.pyqtSignal()
    finished =QtCore.pyqtSignal()



    @QtCore.pyqtSlot()
    def iniciar_conexion(self):
        self.started.emit()
        self.Tabla.setRowCount(0)

        totalMatutino = "0"


        ref = db.reference("/")
        ret = ref.get()

        for key in ret.items():

            if key[0][:7]==str(self.Fecha):
                for key1 in key[1].items():
                    if key1[0]==self.Sucursal:
                        for key2 in key1[1].items():
                            if key2[0] == "Matutino":
                                for key3 in key2[1].items():
                                    if key3[0] == "15:00":
                                        for key5 in key3[1].items():
                                            if key5[0]=="total":
                                                totalMatutino = key5[1]

                                                self.Tabla.insertRow(self.currentRow)

                                        self.Tabla.setItem(self.currentRow,5,QTableWidgetItem(totalMatutino))

self.finished.emit()

class DatosGeneralesClass():

    def __init__(self,mes,sucursal,ano,tabla,status,boton):

        self.Mes = "01"
        self.Sucursal = "Exxe 1"

        self.Ano = "2018"
        self.Tabla = tabla
        self.currentRow = self.Tabla.rowCount()
        self.Fecha = self.Ano+"-"+self.Mes
        self.Status =status

        ano.currentIndexChanged.connect(lambda:self.updateAno(ano.currentText()))

        self._worker = Worker()
        self._worker.started.connect(self.on_started)
        self.__worker.finished.connect(self.on_finished)
        thread = QtCore.QThread(self)
        self._worker.moveToThread(thread)

    @QtCore.pyqtSlot()
    def on_started(self):
        self.DStatus.setText("Cargando")
    @QtCore.pyqtSlot()
    def on_finished(self):
        self.DStatus.setText("complete")



    @QtCore.pyqtSlot(str)
    def updateAno(self,ano):

        self.Ano = ano
        self.Fecha = self.Ano+"-"+self.Mes

        self.conectar()

    @QtCore.pyqtSlot()
    def conectar(self):
        QtCore.QTimer.singleShot(0,self._worker.iniciar_conexion)
nuevo codigo
Origen Enlace
    from PyQt5 import QtCore
from PyQt5.QtWidgets import QTableWidgetItem
from FirebaseProjectLogin import *
import threading

class Worker(QtCore.QObject):
    resultadostarted = QtCore.pyqtSignal(int)

    def __init__(self):
       finished super()=QtCore.__init__pyqtSignal() 



    @QtCore.pyqtSlot()
    def iniciar_conexion(self):
        self.resultadostarted.emit(1)
        self.Tabla.setRowCount(0)

        
       totalMatutino totalMatutino== "0"  


        ref = db.reference("/")
        ret = ref.get()

        for key in ret.items():
    
            if key[0][:7]==str(self.Fecha):
                for key1 in key[1].items():
                    if key1[0]==self.Sucursal:
                        for key2 in key1[1].items():
                            if key2[0] == "Matutino":
                                for key3 in key2[1].items():
                                    if key3[0] == "15:00":
                                        for key5 in key3[1].items():
                                            if key5[0]=="total":
                                                totalMatutino = key5[1]
                                                
                                                self.Tabla.insertRow(self.currentRow)
                                        
                                        self.Tabla.setItem(self.currentRow,5,QTableWidgetItem(totalMatutino))
                                        
                            
        self.resultado.emit(-1)
class DatosGeneralesClass():
    
    def __init__(self,mes,sucursal,ano,tabla,status,boton):
        
        self.Mes = "01"
        self.Sucursal = "Exxe 1"
        
        self.Ano = "2018"
        self.Tabla = tabla
        self.currentRow = self.Tabla.rowCount()
        self.Fecha = self.Ano+"-"+self.Mes
        self.Status =status

        ano.currentIndexChanged.connect(lambda:self.updateAno(ano.currentText()))

    @QtCore.pyqtSlot(str)
    def updateAno(self,ano):
        
        self.Ano_worker = anoWorker()
        self.Fecha = self_worker.Ano+"-"+selfstarted.Mes
        connect(self.on_started)
        self._thread = QtCore__worker.QThreadfinished.connect(self.on_finished)
        self._workerthread = WorkerQtCore.QThread(self)
        self._thread.started.connect(self._worker.iniciar_conexionmoveToThread(thread)
     
    self._worker@QtCore.moveToThreadpyqtSlot(self._thread)
       def self._worker.resultado.connecton_started(self._estado):
        self._threadDStatus.startsetText("Cargando")
        
    @QtCore.pyqtSlot(int)
    def _estadoon_finished(self,resultado):
        if resultado == 1:
            self.DStatus.setText("Cargando...""complete")
            return
  

    @QtCore.pyqtSlot(str)
   elif resultadodef ==0updateAno(self,ano):
     
        self.DStatus.setText("complete")
Ano = ano
        self.Fecha = self._threadAno+"-"+self.quit()Mes
     
        self._thread.waitconectar()
        else:
            print@QtCore.pyqtSlot("error")
       def self._thread.quitconectar(self):
        selfQtCore._threadQTimer.waitsingleShot(0,self._worker.iniciar_conexion)
from PyQt5 import QtCore
from PyQt5.QtWidgets import QTableWidgetItem
from FirebaseProjectLogin import *
import threading

class Worker(QtCore.QObject):
    resultado = QtCore.pyqtSignal(int)

    def __init__(self):
        super().__init__()

    @QtCore.pyqtSlot()
    def iniciar_conexion(self):
        self.resultado.emit(1)
        self.Tabla.setRowCount(0)

        
        totalMatutino= "0" 

        ref = db.reference("/")
        ret = ref.get()

        for key in ret.items():
    
            if key[0][:7]==str(self.Fecha):
                for key1 in key[1].items():
                    if key1[0]==self.Sucursal:
                        for key2 in key1[1].items():
                            if key2[0] == "Matutino":
                                for key3 in key2[1].items():
                                    if key3[0] == "15:00":
                                        for key5 in key3[1].items():
                                            if key5[0]=="total":
                                                totalMatutino = key5[1]
                                                
                                                self.Tabla.insertRow(self.currentRow)
                                        
                                        self.Tabla.setItem(self.currentRow,5,QTableWidgetItem(totalMatutino))
                                        
                            
        self.resultado.emit(-1)
class DatosGeneralesClass():
    
    def __init__(self,mes,sucursal,ano,tabla,status):
        
        self.Mes = "01"
        self.Sucursal = "Exxe 1"
        
        self.Ano = "2018"
        self.Tabla = tabla
        self.currentRow = self.Tabla.rowCount()
        self.Fecha = self.Ano+"-"+self.Mes
        self.Status =status

        ano.currentIndexChanged.connect(lambda:self.updateAno(ano.currentText()))

    @QtCore.pyqtSlot(str)
    def updateAno(self,ano):
        
        self.Ano = ano
        self.Fecha = self.Ano+"-"+self.Mes
        
        self._thread = QtCore.QThread()
        self._worker = Worker()
        self._thread.started.connect(self._worker.iniciar_conexion)
        self._worker.moveToThread(self._thread)
        self._worker.resultado.connect(self._estado)
        self._thread.start()
        
    @QtCore.pyqtSlot(int)
    def _estado(self,resultado):
        if resultado == 1:
            self.DStatus.setText("Cargando...")
            return
        elif resultado ==0:
            self.DStatus.setText("complete")
            self._thread.quit()
            self._thread.wait()
        else:
            print("error")
        self._thread.quit()
        self._thread.wait()
    from PyQt5 import QtCore
from PyQt5.QtWidgets import QTableWidgetItem
from FirebaseProjectLogin import *
import threading

class Worker(QtCore.QObject):
    started = QtCore.pyqtSignal()
    finished =QtCore.pyqtSignal() 



    @QtCore.pyqtSlot()
    def iniciar_conexion(self):
        self.started.emit(1)
        self.Tabla.setRowCount(0)

        totalMatutino = "0" 


        ref = db.reference("/")
        ret = ref.get()

        for key in ret.items():

            if key[0][:7]==str(self.Fecha):
                for key1 in key[1].items():
                    if key1[0]==self.Sucursal:
                        for key2 in key1[1].items():
                            if key2[0] == "Matutino":
                                for key3 in key2[1].items():
                                    if key3[0] == "15:00":
                                        for key5 in key3[1].items():
                                            if key5[0]=="total":
                                                totalMatutino = key5[1]

                                                self.Tabla.insertRow(self.currentRow)

                                        self.Tabla.setItem(self.currentRow,5,QTableWidgetItem(totalMatutino))


class DatosGeneralesClass():

    def __init__(self,mes,sucursal,ano,tabla,status,boton):

        self.Mes = "01"
        self.Sucursal = "Exxe 1"

        self.Ano = "2018"
        self.Tabla = tabla
        self.currentRow = self.Tabla.rowCount()
        self.Fecha = self.Ano+"-"+self.Mes
        self.Status =status

        ano.currentIndexChanged.connect(lambda:self.updateAno(ano.currentText()))

        self._worker = Worker()
        self._worker.started.connect(self.on_started)
        self.__worker.finished.connect(self.on_finished)
        thread = QtCore.QThread(self)
        self._worker.moveToThread(thread)
 
    @QtCore.pyqtSlot()
    def on_started(self):
        self.DStatus.setText("Cargando")
    @QtCore.pyqtSlot()
    def on_finished(self):
        self.DStatus.setText("complete")

 

    @QtCore.pyqtSlot(str)
    def updateAno(self,ano):
 
        self.Ano = ano
        self.Fecha = self.Ano+"-"+self.Mes
 
        self.conectar()

    @QtCore.pyqtSlot()
    def conectar(self):
        QtCore.QTimer.singleShot(0,self._worker.iniciar_conexion)
codigo nuevo
Origen Enlace

en este escodigo agrege las corecciones que me señalaron, mediante un QComboBox detono el código:hilo para que actualice el texto del qlabel y dentro de la clase worker el metodo iniciar_conexion detona lo que se realizara utilizando firebse

Nuevo codigo

from PyQt5.QtWidgets import QMainWindow,QApplication,QTableWidget,QTableWidgetItemQtCore
from PyQt5.QtWidgets import QtCoreQTableWidgetItem
from PyQt5FirebaseProjectLogin import uic*
import firebase_adminthreading
from
class firebase_adminWorker(QtCore.QObject):
 import   resultado = QtCore.pyqtSignal(int)

    def __init__(self):
        super().__init__()

    @QtCore.pyqtSlot()
    def iniciar_conexion(self):
        self.resultado.emit(1)
        self.Tabla.setRowCount(0)

        
        totalMatutino= "0" 

        ref = db,credentials.reference("/")
import threading       ret = ref.get()

class Principal       for key in ret.items(QMainWindow):
    def 
 __init__           if key[0][:7]==str(self.Fecha):
        QMainWindow        for key1 in key[1].__init__items():
                    if key1[0]==self.Sucursal:
                        for key2 in key1[1].items():
                            if key2[0] == "Matutino":
                                for key3 in key2[1].items():
                                    if key3[0] == "15:00":
                                        for key5 in key3[1].items():
                                            if key5[0]=="total":
                                                totalMatutino = key5[1]
                                                
                                                self.Tabla.insertRow(self.currentRow)
        uic                                
                                        self.loadUiTabla.setItem("prubeaself.ui"currentRow,5,QTableWidgetItem(totalMatutino))
                                        
                            
        self.resultado.emit(-1)
class DatosGeneralesClass():
    
    def __init__(self,mes,sucursal,ano,tabla,status):
        
        self.Mes = "01"
        self.Sucursal = "Exxe 1"
        
        self.TablaAno = "2018"
        self.Tabla = tabla
        self.currentRow = self.Tabla.rowCount()
        self.Fecha = self.Ano+"-"+self.Mes
        self.comboBoxStatus =status

        ano.currentIndexChanged.connect(lambda:self.accessupdateAno(4ano.currentText())) 

    @QtCore.pyqtSlot(intstr)
    def accessupdateAno(self,mesano):
        t= 
 threading       self.Thread(target=selfAno = ano
        self.labelFecha = self.setText("cargando"))Ano+"-"+self.start()
Mes
        
        credself._thread = credentialsQtCore.CertificateQThread("accesFire)
        self.json"_worker = Worker()
        firebase_adminself.initialize_app_thread.started.connect(cred,{self._worker.iniciar_conexion)
        self._worker.moveToThread(self._thread)
    'databaseURL':'https://exe-tablas    self.firebaseio_worker.com/'resultado.connect(self._estado)
        }self._thread.start()
        ref 
 = db  @QtCore.referencepyqtSlot("/"int)
    def _estado(self,resultado):
        retif =resultado ref== 1:
            self.getDStatus.setText("Cargando...")
        
     return
        elif resultado ==0:
            self.DStatus.setText("complete")
            self._thread.quit()
app = QApplication          self._thread.wait([])
p = Principal      else:
            print("error")
p        self.show_thread.quit()
app        self.exec__thread.wait()

este es el código:

from PyQt5.QtWidgets import QMainWindow,QApplication,QTableWidget,QTableWidgetItem
from PyQt5 import QtCore
from PyQt5 import uic
import firebase_admin
from firebase_admin import db,credentials
import threading

class Principal(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        uic.loadUi("prubea.ui",self)

        

        self.Tabla = self.tabla
        self.currentRow = self.Tabla.rowCount()

        self.comboBox.currentIndexChanged.connect(lambda:self.access(4))
    @QtCore.pyqtSlot(int)
    def access(self,mes):
        t= threading.Thread(target=self.label.setText("cargando")).start()


        cred = credentials.Certificate("accesFire.json")
        firebase_admin.initialize_app(cred,{
            'databaseURL':'https://exe-tablas.firebaseio.com/'
        })
        ref = db.reference("/")
        ret = ref.get()
        
             

        
app = QApplication([])
p = Principal()
p.show()
app.exec_()

en este codigo agrege las corecciones que me señalaron, mediante un QComboBox detono el hilo para que actualice el texto del qlabel y dentro de la clase worker el metodo iniciar_conexion detona lo que se realizara utilizando firebse

Nuevo codigo

from PyQt5 import QtCore
from PyQt5.QtWidgets import QTableWidgetItem
from FirebaseProjectLogin import *
import threading

class Worker(QtCore.QObject):
    resultado = QtCore.pyqtSignal(int)

    def __init__(self):
        super().__init__()

    @QtCore.pyqtSlot()
    def iniciar_conexion(self):
        self.resultado.emit(1)
        self.Tabla.setRowCount(0)

        
        totalMatutino= "0" 

        ref = db.reference("/")
        ret = ref.get()

        for key in ret.items():
     
            if key[0][:7]==str(self.Fecha):
                for key1 in key[1].items():
                    if key1[0]==self.Sucursal:
                        for key2 in key1[1].items():
                            if key2[0] == "Matutino":
                                for key3 in key2[1].items():
                                    if key3[0] == "15:00":
                                        for key5 in key3[1].items():
                                            if key5[0]=="total":
                                                totalMatutino = key5[1]
                                                
                                                self.Tabla.insertRow(self.currentRow)
                                        
                                        self.Tabla.setItem(self.currentRow,5,QTableWidgetItem(totalMatutino))
                                        
                            
        self.resultado.emit(-1)
class DatosGeneralesClass():
    
    def __init__(self,mes,sucursal,ano,tabla,status):
        
        self.Mes = "01"
        self.Sucursal = "Exxe 1"
        
        self.Ano = "2018"
        self.Tabla = tabla
        self.currentRow = self.Tabla.rowCount()
        self.Fecha = self.Ano+"-"+self.Mes
        self.Status =status

        ano.currentIndexChanged.connect(lambda:self.updateAno(ano.currentText())) 

    @QtCore.pyqtSlot(str)
    def updateAno(self,ano):
         
        self.Ano = ano
        self.Fecha = self.Ano+"-"+self.Mes
        
        self._thread = QtCore.QThread()
        self._worker = Worker()
        self._thread.started.connect(self._worker.iniciar_conexion)
        self._worker.moveToThread(self._thread)
        self._worker.resultado.connect(self._estado)
        self._thread.start()
         
    @QtCore.pyqtSlot(int)
    def _estado(self,resultado):
        if resultado == 1:
            self.DStatus.setText("Cargando...")
            return
        elif resultado ==0:
            self.DStatus.setText("complete")
            self._thread.quit()
            self._thread.wait()
        else:
            print("error")
        self._thread.quit()
        self._thread.wait()
etiquetas editadas
Enlace
FJSevilla
  • 62.1k
  • 7
  • 43
  • 68
Loading
se añadieron 2 caracteres en el cuerpo; título editado
Origen Enlace
alo Malbarez
  • 9.7k
  • 3
  • 12
  • 29
Loading
Origen Enlace
Loading