Esempio n. 1
0
 def load(self, data, editable=False):
     if isinstance(data, str):
         unistr = data
     else:
         codec = QTextCodec.codecForHtml(data)
         unistr = codec.toUnicode(data)
     if Qt.mightBeRichText(unistr):
         self.textEdit.setHtml(unistr)
     else:
         self.textEdit.setPlainText(unistr)
     self.textEdit.setReadOnly(not editable)
Esempio n. 2
0
    def load(self, f):
        if not QFile.exists(f):
            return False

        fh = QFile(f)
        if not fh.open(QFile.ReadOnly):
            return False

        data = fh.readAll()
        codec = QTextCodec.codecForHtml(data)
        unistr = codec.toUnicode(data)

        if Qt.mightBeRichText(unistr):
            self.textEdit.setHtml(unistr)
        else:
            self.textEdit.setPlainText(unistr)

        self.setCurrentFileName(f)
        return True
Esempio n. 3
0
    def load(self, f):
        if not QFile.exists(f):
            return False

        fh = QFile(f)
        if not fh.open(QFile.ReadOnly):
            return False

        data = fh.readAll()
        codec = QTextCodec.codecForHtml(data)
        unistr = codec.toUnicode(data)

        if Qt.mightBeRichText(unistr):
            self.textEdit.setHtml(unistr)
        else:
            self.textEdit.setPlainText(unistr)

        self.setCurrentFileName(f)
        return True
Esempio n. 4
0
    def data (self):
    #Mostrar datos y objeto document

        data = [("1", "March", "Arnt", "Disabled", "10/23/2010"),
            ("2", "April", "Louis", "Enabled", "09/05/2020"),
            ("3", "June", "Steve", "Disabled", "02/15/2001"),
            ("4", "October", "Marcus", "Enabled", "01/13/2002"),
            ("5", "December", "John", "Enabled", "12/28/2018"),
        
                ]

        #Limpiar tabla/documento
        self.table_user.clear()
        self.document.clear()


        html_dato =''
        item_widget=[]

        for d in data:
        #Imprimir datos en la tabla
            
            self.table_user.insertTopLevelItems(0,[QTreeWidgetItem(self.table_user, d)])    

            html_dato += "<tr> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td>  <td>%s</td> </tr>" %d
            item_widget.append(QTreeWidgetItem((str(d[0]), d[1], d[2], d[3], d[3])))

        

        html="""
        <!DOCTYPE html>
        <html>
        <head>
        <meta charset="UTF-8">
        <style>
        h3 {
            font-family: Helvetica-Bold;
            text-align: center;
        }
        table {
            font-family: arial, sans-serif;
            border-collapse: collapse;
            width: 100%;
            }
        td {
            text-align: left;
            padding-top: 4px;
            padding-right: 6px;
            padding-bottom: 2px;
            padding-left: 6px;
        }
        th {
            text-align: left;
            padding: 4px;
            background-color: black;
            color: white;
        }
        tr:nth-child(even) {
                            background-color: #dddddd;
                        }
        </style>
        </head>
        <body>
        <h3>LISTADO DE USUARIOS<br/></h3>
        <table align="left" width="100%" cellspacing="0">
        <tr>
            <th>Id_Usuario</th>
            <th>Mes</th>
            <th>Nombre</th>
            <th>Estatus</th>
            <th>Fecha de alta</th>
        </tr>
        [DATA]
        </table>
        </body>
        </html>
        """.replace("[DATA]", html_dato)


        qbyte = QByteArray()
        qbyte.append(str(html))
        #Ajuste
        codec = QTextCodec.codecForHtml(qbyte)
        unistr = codec.toUnicode(qbyte)

        if Qt.mightBeRichText(unistr):
            self.document.setHtml(unistr)
        else:
            self.document.setPlainText(unistr)
Esempio n. 5
0
    def Buscar(self):
        conexionDB = connect("Data/db_favan.db")
        cursor = conexionDB.cursor()

        cursor.execute(
            "SELECT ID_CLIENTE, NOM_CLIENTE, APE_CLIENTE, COR_CLIENTE FROM CLIENTE"
        )
        datosDB = cursor.fetchall()

        conexionDB.close()

        if datosDB:
            self.documento.clear()
            self.treeWidgetUsuarios.clear()

            datos = ""
            item_widget = []
            for dato in datosDB:
                datos += "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % dato
                item_widget.append(
                    QTreeWidgetItem((str(dato[0]), dato[1], dato[2], dato[3])))

            reporteHtml = """
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
h3 {
    font-family: Helvetica-Bold;
    text-align: center;
   }
table {
       font-family: arial, sans-serif;
       border-collapse: collapse;
       width: 100%;
      }
td {
    text-align: left;
    padding-top: 4px;
    padding-right: 6px;
    padding-bottom: 2px;
    padding-left: 6px;
   }
th {
    text-align: left;
    padding: 4px;
    background-color: purple;
    color: white;
   }
tr:nth-child(even) {
                    background-color: #dddddd;
                   }
</style>
</head>
<body>
<h3>LISTADO DE USUARIOS<br/></h3>
<table align="left" width="100%" cellspacing="0">
  <tr>
    <th>D.N.I</th>
    <th>NOMBRE</th>
    <th>APELLIDO</th>
    <th>FECHA DE NACIMIENTO</th>
  </tr>
  [DATOS]
</table>
</body>
</html>
""".replace("[DATOS]", datos)

            datos = QByteArray()
            datos.append(str(reporteHtml))
            codec = QTextCodec.codecForHtml(datos)
            unistr = codec.toUnicode(datos)

            if Qt.mightBeRichText(unistr):
                self.documento.setHtml(unistr)
            else:
                self.documento.setPlainText(unistr)

            self.treeWidgetUsuarios.addTopLevelItems(item_widget)
        else:
            QMessageBox.information(self, "Buscar usuarios",
                                    "No se encontraron resultados.      ",
                                    QMessageBox.Ok)
Esempio n. 6
0
    def Buscar(self):
        conexionDB = connect("DB_SIACLE/DB_SIACLE.db")
        cursor = conexionDB.cursor()

        cursor.execute("SELECT NOMBRE, APELLIDO, SEXO, FECHA_NACIMIENTO, PAIS, TELEFONO_CELULAR FROM CLIENTES ")
        datosDB = cursor.fetchall()

        conexionDB.close()

        if datosDB:
            self.documento.clear()
            self.treeWidgetUsuarios.clear()

            datos = ""
            item_widget = []
            for dato in datosDB:
                datos += "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % dato
                item_widget.append(QTreeWidgetItem((str(dato[0]), dato[1], dato[2], dato[3], dato[4], dato[5])))

            reporteHtml = """
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
h3 {
    font-family: Helvetica-Bold;
    text-align: center;
   }

table {
       font-family: arial, sans-serif;
       border-collapse: collapse;
       width: 100%;
      }

td {
    text-align: left;
    padding-top: 4px;
    padding-right: 6px;
    padding-bottom: 2px;
    padding-left: 6px;
   }

th {
    text-align: left;
    padding: 4px;
    background-color: black;
    color: white;
   }

tr:nth-child(even) {
                    background-color: #dddddd;
                   }
</style>
</head>
<body>

<h3>Клиенты<br/></h3>

<table align="left" width="100%" cellspacing="0">
  <tr>
    <th>Имя</th>
    <th>Фамилия</th>
    <th>Пол</th>
    <th>Дата рождения</th>
    <th>Страна</th>
    <th>Телефон</th>
  </tr>
  [DATOS]
</table>

</body>
</html>
""".replace("[DATOS]", datos)

            datos = QByteArray()
            datos.append(str(reporteHtml))
            codec = QTextCodec.codecForHtml(datos)
            unistr = codec.toUnicode(datos)

            if Qt.mightBeRichText(unistr):
                self.documento.setHtml(unistr)
            else:
                self.documento.setPlainText(unistr)

            self.treeWidgetUsuarios.addTopLevelItems(item_widget)
        else:
            QMessageBox.information(self, "Найти пользователей", "Результатов не найдено.      ",
                                    QMessageBox.Ok)