How to make my button "Insert data" loop because when i clicked it once the button state will be disable how to make it like infinite loop button so i can clicked anytime i want



  • import sys
    import os
    from PyQt4 import QtGui, QtCore
    from PyQt4.QtGui import *
    from PyQt4.QtCore import *
    from PyQt4.QtCore import SIGNAL
    from PyQt4.QtSql import *

    class Window(QtGui.QMainWindow):

    def __init__(self):
        super(Window,self).__init__()
        self.setGeometry(50,50,0,0)
        self.setFixedSize(1250,700)
        self.setWindowTitle("IMS Delta EarthMoving Incorporated")
        self.setWindowIcon(QtGui.QIcon('Pictures/delta.png'))
        self.home()
        self.database()
    
    def home(self):
        btn = QtGui.QPushButton("Insert data",self)
        btn.isChecked()
        btn.clicked.connect(self.import_application)
    
        btn.resize(btn.minimumSizeHint())
        btn.move(0,0)
    
        self.show()
    
    def import_application(self):
        choice = QtGui.QMessageBox.question(self,'IMS',"Check Query before Submiting",QtGui.QMessageBox.Ok)
        if choice == QtGui.QMessageBox.Ok:
            import QtInputDelta
    
        
    def database(self): #Table data view
        table 	= QTableWidget(self)
        db 	= QSqlDatabase.addDatabase("QMYSQL")
    
        db.setHostName("localhost")
        db.setDatabaseName("test")
        db.setUserName("root")
        db.setPassword("admingelo")
    
        if (db.open()==False):     
            QMessageBox.critical(None, "Database Error",
    		    db.lastError().text())   
    		    
        query = QSqlQuery ("SELECT * FROM sfo")   
    
        table.setColumnCount(query.record().count())
        table.setRowCount(query.size())
    
        index=0
        while (query.next()):
                table.setItem(index,0,QTableWidgetItem(query.value(0).toString()))
                table.setItem(index,1,QTableWidgetItem(query.value(1).toString()))
                table.setItem(index,2,QTableWidgetItem(query.value(2).toString()))
                table.setItem(index,3,QTableWidgetItem(query.value(3).toString()))
                table.setItem(index,4,QTableWidgetItem(query.value(4).toString()))
                table.setItem(index,5,QTableWidgetItem(query.value(5).toString()))
                index = index+1
    
        table.show()
        table.resize(1230,615)
        table.move(10,75)
    

    def run():
    app = QtGui.QApplication(sys.argv)
    GUI = Window()
    sys.exit(app.exec_())
    run()


  • Lifetime Qt Champion

    Hi,

    Can you explain exactly what you are trying to achieve ?

    By the way, why not use a QTableView with a QSqlTableModel ?



  • @SGaist can you give an example of QSqlTableModel?


  • Lifetime Qt Champion

    Seriously: did you even take the time to read the documentation I linked to ? At the end of the detailed description there are several links to examples using that class.



  • @SGaist sorry thank you for the late reply thank you for helping me


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.