Пример #1
0
 def fset(self, value):
     if type(value) == str:
         self.__connection = dburl_to_qsqldb(value)
     elif type(value) == QSqlDatabase:
         self.__connection == value
     else:
         raise TypeError("%s is not either QSqlDatabase nor a DB url" % value)
Пример #2
0
 def fset(self, value):
     if type(value) == str:
         self.__connection = dburl_to_qsqldb(value)
     elif type(value) == QSqlDatabase:
         self.__connection == value
     else:
         raise TypeError("%s is not either QSqlDatabase nor a DB url" %
                         value)
Пример #3
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        #        layout = QVBoxLayout(self)
        layout = QGridLayout()
        layout.addWidget(
            QLabel("Configuracion calles para %s" % str(self.parent()), self))

        db = dburl_to_qsqldb('mysql://*****:*****@localhost:3306/dsem')
        print db

        #        iduc = parent.history[0].uc
        iduc = 0

        sqlmodel = QSqlQueryModel()

        sqlmodel.setQuery(
            QSqlQuery('SELECT can_movi FROM UC WHERE id = %' % iduc, db))

        print "Error?", model.lastError().databaseText() or "Sim error :)"

        value = sqlmodel.record(0).value(0)
        print value

        self.model = QStandardItemModel(2, 3)
        self.table = QTableView()
        self.table.setModel(self.model)
        layout.addWidget(self.table, 1, 0, 2, 3)

        self.scene = parent.history[parent.current_step - 1].scene
        self.scene.estado = EsquinaGraphicsScene.STATE_EDICION_SEMAFOROS
        self.esquinaConfigView = EsquinaGraphicsView(self.scene)
        self.esquinaConfigView.setScene(self.scene)

        layout.setRowMinimumHeight(3, 300)
        layout.addWidget(self.esquinaConfigView, 3, 0, 5, 2)
        #        layout.setRowStretch(3, 3)
        self.setLayout(layout)
Пример #4
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
#        layout = QVBoxLayout(self)
        layout = QGridLayout()
        layout.addWidget(QLabel("Configuracion calles para %s" %
                                str(self.parent())
                                , self))
        
        db = dburl_to_qsqldb('mysql://*****:*****@localhost:3306/dsem')
        print db
    
#        iduc = parent.history[0].uc
        iduc = 0
        
        sqlmodel = QSqlQueryModel()
        
        sqlmodel.setQuery( QSqlQuery('SELECT can_movi FROM UC WHERE id = %'% iduc, db) )
        
        print "Error?", model.lastError().databaseText() or "Sim error :)"

        value = sqlmodel.record(0).value(0)
        print value
        
        self.model = QStandardItemModel(2,3)
        self.table = QTableView()
        self.table.setModel(self.model)
        layout.addWidget(self.table,1,0,2,3)
        
        self.scene = parent.history[parent.current_step - 1].scene
        self.scene.estado = EsquinaGraphicsScene.STATE_EDICION_SEMAFOROS 
        self.esquinaConfigView = EsquinaGraphicsView(self.scene)
        self.esquinaConfigView.setScene(self.scene)
        
        layout.setRowMinimumHeight(3, 300)
        layout.addWidget(self.esquinaConfigView,3,0,5,2)
#        layout.setRowStretch(3, 3)
        self.setLayout(layout)
Пример #5
0
                # Atendido y no reparado
                return QVariant(self.COLOR_ATENDIDO)
            else:
                return QVariant(self.COLOR_REPARADO)
            
        return value
    
    
if __name__ == '__main__':
    import sys
    sys.path += ('..', '../..')
    app = QApplication(sys.argv)
    from pyscada.gui.qt_dbhelp import dburl_to_qsqldb
    try:
        # Se lo chantamos así nomás
        qApp.db_con = dburl_to_qsqldb('mysql://*****:*****@localhost:3306/dsem')
        q = QSqlQuery("SET NAMES 'utf8'", qApp.db_con)
        print q.exec_()
        
    except Exception, e:
        import traceback
        QMessageBox.critical(None, "Error", u"<h2>%s</h2></pre>%s</pre>" %
                             (type(e), traceback.format_exc()))
        sys.exit()
    import data_rc #@UnresolvedImport
    #QTextCodec.setCodecForLocale ( QTextCodec.codecForName ( "UTF-8" ) ) 

    # Edior de calles WIP
    #win = EditorCalles()
    
    
Пример #6
0
                # Atendido y no reparado
                return QVariant(self.COLOR_ATENDIDO)
            else:
                return QVariant(self.COLOR_REPARADO)

        return value


if __name__ == '__main__':
    import sys
    sys.path += ('..', '../..')
    app = QApplication(sys.argv)
    from pyscada.gui.qt_dbhelp import dburl_to_qsqldb
    try:
        # Se lo chantamos así nomás
        qApp.db_con = dburl_to_qsqldb(
            'mysql://*****:*****@localhost:3306/dsem')
        q = QSqlQuery("SET NAMES 'utf8'", qApp.db_con)
        print q.exec_()

    except Exception, e:
        import traceback
        QMessageBox.critical(
            None, "Error",
            u"<h2>%s</h2></pre>%s</pre>" % (type(e), traceback.format_exc()))
        sys.exit()
    import data_rc  #@UnresolvedImport
    #QTextCodec.setCodecForLocale ( QTextCodec.codecForName ( "UTF-8" ) )

    # Edior de calles WIP
    #win = EditorCalles()