コード例 #1
0
 def validarCierreAnual(self):
     try:
         query=QSqlQuery()
         q=u"""
         SELECT d.iddocumento 
         FROM documentos d 
         WHERE d.idtipodoc=%d  
         AND YEAR(d.fechacreacion)=%s""" %(constantes.IDCIERREMENSUAL,self.fecha.toString( "yyyy" ))
         query.prepare(q)
         
         if not query.exec_():
             raise Exception( "No se pudo ejecutar la consulta para determinar si se cerraron todos los meses del año" )
         
         if query.size()<12 and query.size()>0:
             raise UserWarning( "No se han cerrado todos los meses del Ejercicio" )
         return True
         
     except UserWarning as inst:
         logging.error( unicode( inst ) )
         QMessageBox.critical( self, qApp.applicationName(), unicode( inst ) )
         self.toolBar.removeAction( self.actionSave )
         return False
         
     except Exception as inst:
         logging.critical( unicode( inst ) )
         self.toolBar.removeAction( self.actionSave )
         QMessageBox.warning( self,
          qApp.organizationName(),unicode(inst))
         return False   
コード例 #2
0
ファイル: img2gifWidget.py プロジェクト: Liung/QAeroData
 def itemAdd(self):
     fileNames = QFileDialog.getOpenFileNames(None, u"{0} -- {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                                              '.', u'所有文件(*.*);;BMP文件(*.bmp);;PNG文件(*.png);;JPG文件(*.jpg *.jpeg)')
     for fn in fileNames:
         f = QFileInfo(fn)
         if unicode(f.suffix().toLower()) in ['jpg', 'png', 'bmp', 'jpeg']:
             self.listWidget.addItem(fn)
コード例 #3
0
ファイル: img2gifWidget.py プロジェクト: Liung/QAeroData
    def makeGif(self):

        imgs = [unicode(self.listWidget.item(i).text()) for i in range(self.listWidget.count())]
        if len(imgs) <= 1:
            QMessageBox.warning(self, u"{0} - {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                                u"GIF动画文件必须要给定大于一张图片。")
            return
        if not self.updateGifPath():
            return
        durations = self.spbTime.value()
        loops = self.spbLoop.value()
        ok, msg = img2gif.images2gif(imgs, self.txtGifPath.text(), durations=durations, loops=loops)
        if ok:
            QMessageBox.about(self, u"{0} - {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                              u"Succeed!\n{0}".format(msg))
            qApp.processEvents()
        else:
            QMessageBox.about(u"{0} - {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                              u"sorry! Failed to generate the {0}".format(unicode(self.txtGifPath)))
コード例 #4
0
ファイル: user.py プロジェクト: armonge/EsquipulasPy
    def setupUi( self, _parent ):


        self.setWindowTitle( "%s : %s" % ( qApp.organizationName(),
                                            qApp.applicationName() ) )

        self.txtOldPassword = QLineEdit()
        self.txtOldPassword.setEchoMode( QLineEdit.Password )

        self.txtNewPassword = QLineEdit()
        self.txtNewPassword.setEchoMode( QLineEdit.Password )

        self.txtRepeatPassword = QLineEdit()
        self.txtRepeatPassword.setEchoMode( QLineEdit.Password )

        self.form = QFormLayout()
        self.form.addRow( u"Contraseña anterior", self.txtOldPassword )
        self.form.addRow( u"Nueva contraseña", self.txtNewPassword )
        self.form.addRow( u"Repita la nueva contraseña",
                          self.txtRepeatPassword )

        self.bar = QProgressBar()
        self.bar.setMinimum( 0 )
        self.bar.setMaximum( 5 )

        self.layout = QVBoxLayout()
        self.buttonBox = QDialogButtonBox( QDialogButtonBox.Ok |
                                           QDialogButtonBox.Cancel )

        self.lblError = QLabel()
        self.lblError.setAlignment( Qt.AlignHCenter )
        self.lblError.setProperty( "error", True )
        self.lblError.setVisible( False )

        self.layout.addLayout( self.form )
        self.layout.addWidget( self.lblError )
        self.layout.addWidget( self.bar )
        self.layout.addWidget( self.buttonBox )

        self.setLayout( self.layout )
コード例 #5
0
ファイル: img2gifWidget.py プロジェクト: Liung/QAeroData
 def setGifPath(self):
     filename = QFileDialog.getSaveFileName(self, u"{0} -- {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                                            ".", "Gif(*.gif)")
     self.txtGifPath.setText(filename)
コード例 #6
0
ファイル: user.py プロジェクト: armonge/EsquipulasPy
    def setupUi( self ):
        super( dlgUserLogin, self ).setupUi()

        #No mostrar el marco de la ventana
        self.setWindowFlags( Qt.FramelessWindowHint )

        self.resize( 519, 311 )
        self.setMinimumSize( QSize( 519, 311 ) )
        self.setMaximumSize( QSize( 519, 311 ) )

        horizontal_layout = QHBoxLayout( self )
        horizontal_layout.setMargin( 0 )

        frame = QFrame( self )
        frame.setFrameShape( QFrame.NoFrame )
        frame.setFrameShadow( QFrame.Plain )

        grid_layout = QGridLayout( frame )
        grid_layout.setMargin( 0 )

        spacerItem = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding )
        grid_layout.addItem( spacerItem, 0, 0, 1, 6 )



        sizePolicy = QSizePolicy( QSizePolicy.Preferred,
                                  QSizePolicy.Maximum )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth( self.txtApplication.sizePolicy().hasHeightForWidth() )
        self.txtApplication.setSizePolicy( sizePolicy )

        font = QFont()
        font.setPointSize( 16 )
        font.setWeight( 75 )
        font.setBold( True )
        self.txtApplication.setFont( font )
        self.txtApplication.setAutoFillBackground( False )
        self.txtApplication.setAlignment( Qt.AlignCenter )

        grid_layout.addWidget( self.txtApplication, 1, 0, 1, 5 )
        spacer_item_1 = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                   QSizePolicy.Expanding )
        grid_layout.addItem( spacer_item_1, 2, 0, 1, 6 )
        spacer_item_2 = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                   QSizePolicy.Expanding )
        grid_layout.addItem( spacer_item_2, 3, 0, 1, 6 )
        spacer_item_3 = QSpacerItem( 60, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_3, 5, 0, 1, 1 )
        spacer_item_4 = QSpacerItem( 40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_4, 5, 1, 1, 1 )
        spacer_item_6 = QSpacerItem( 40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_6, 5, 2, 1, 1 )


        self.label = QLabel()

        self.txtBd = QLineEdit()

        self.formLayout.addRow( u"Base de datos", self.txtBd )
        self.formLayout.setFieldGrowthPolicy( QFormLayout.ExpandingFieldsGrow )

        grid_layout.addLayout( self.formLayout, 5, 3, 1, 1 )
        spacer_item_6 = QSpacerItem( 40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_6, 5, 4, 1, 1 )
        spacer_item_7 = QSpacerItem( 40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum )
        grid_layout.addItem( spacer_item_7, 5, 5, 1, 1 )
        self.lblError = QLabel( frame )
        self.lblError.setProperty( "error", True )
        grid_layout.addWidget( self.lblError, 6, 3, 1, 2 )
        spacer_item_8 = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                   QSizePolicy.Expanding )
        grid_layout.addItem( spacer_item_8, 7, 0, 1, 6 )
        self.buttonbox = QDialogButtonBox( frame )
        self.buttonbox.setOrientation( Qt.Horizontal )
        self.buttonbox.setStandardButtons( QDialogButtonBox.Cancel |
                                           QDialogButtonBox.Ok )
        grid_layout.addWidget( self.buttonbox, 8, 0, 1, 5 )
        spacer_item_9 = QSpacerItem( 20, 40, QSizePolicy.Minimum,
                                   QSizePolicy.Expanding )
        grid_layout.addItem( spacer_item_9, 9, 0, 1, 6 )
        horizontal_layout.addWidget( frame )


        self.txtApplication.setText( "%s : %s" % ( qApp.organizationName(),
                                                qApp.applicationName() ) )
        self.lblError.setVisible( False )

        #Centrar el dialogo en la pantalla
        desktop_widget = QDesktopWidget()
        geometry = desktop_widget.screenGeometry()
        self.setGeometry( ( geometry.width() - 519 ) / 2,
                           ( geometry.height() - 311 ) / 2  ,
                            519, 311 )

        #mostrar redondeado el dialogo
        pixmap = QPixmap( ":/images/res/passwd-bg.png" )
        self.setMask( pixmap.mask() )
コード例 #7
0
 def updateModels( self):
     try:
         if not QSqlDatabase.database().isOpen():
             if not QSqlDatabase.database().open():
                 raise UserWarning( "No se pudo conectar con la base de datos" )
         query = QSqlQuery()
         if self.tipocierre=="Mensual":         
             'Lista de documentos para cierre mensual'
             q = u"""
             SELECT
                 iddocumento,
                 ndocimpreso as 'No. Documento',
                 td.descripcion as TipoDocumento,
                 format(total ,4)as Total,
                 date_format(fechacreacion,'%s') as Fecha,
                 observacion as Observaciones,
                 estados.descripcion as Estado
             FROM documentos d
             JOIN estadosdocumento estados ON estados.idestado=d.idestado
             JOIN tiposdoc td ON d.idtipodoc=td.idtipodoc
             WHERE MONTH(d.fechacreacion)= %s  AND d.idtipodoc!=%d and d.idtipodoc!= %d
             """ % ( "%d/%m/%Y", self.fecha.toString( "MM" ), +constantes.IDAPERTURA , constantes.IDCIERREMENSUAL )
     
             self.navmodel.setQuery( q )  
                
         else:
             q=u"""
             SELECT 
                 iddocumento,
                 ndocimpreso as 'No. Documento',
                 td.descripcion as TipoDocumento,
                 format(total ,4)as Total,
                 date_format(fechacreacion,'%s') as Fecha,
                 observacion as Observaciones,
                 estados.descripcion as Estado
             FROM documentos d
             JOIN estadosdocumento estados ON estados.idestado=d.idestado
             JOIN tiposdoc td ON d.idtipodoc=td.idtipodoc
             WHERE d.idtipodoc=%d  
             AND YEAR(d.fechacreacion)=%s""" %("%d/%m/%Y",constantes.IDCIERREMENSUAL,self.fecha.toString( "yyyy" ))              
             self.navmodel.setQuery( q )            
         
         'Verifico si hay documentos'
         if self.navmodel.rowCount() == 0:
             self.toolBar.removeAction( self.actionSave )
         else:
             self.toolBar.addActions( [
             self.actionSave] )
             self.actionSave.triggered.connect( self.save )
 
         self.tabledetails.setModel( self.navproxymodel )
         self.tabledetails.setColumnHidden( 0, True )
         self.tabledetails.resizeColumnsToContents()
     
     except UserWarning as inst:
         logging.error( unicode( inst ) )
         QMessageBox.critical( self, qApp.applicationName(), unicode( inst ) )
         self.toolBar.removeAction( self.actionSave )
         
     except Exception as inst:
         logging.critical( unicode( inst ) )
         self.toolBar.removeAction( self.actionSave )
         QMessageBox.critical( self, qApp.organizationName(),
                                u"Hubo un error al actualizar la tabla" )