Salut je veut afficher des données depuis postgres dans QtableWidget

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import psycopg2
from PyQt4 import QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
class MyPopup(QTableWidget):
 
    def __init__(self,*args):
        QTableWidget.__init__(self)
        self.setmydata()
    def setmydata(self):
        conn = psycopg2.connect(database="sammy", user="postgres", password="a", host="localhost", port="5432")
        patientTable = QtGui.QTableWidget()
        cur = conn.cursor()
        cur.execute("SELECT * from conn")
        row = 0
        while True:
           forma = cur.fetchall()
           if forma == None:
                break
           for column, item in enumerate(forma):
               self.patientTable.setItem(row, column, QtGui.QTableWidgetItem(str(item)))
               row += 1
 
if __name__ == "__main__":
    app = QtGui.QTableWidget(sys.argv)
    main_window = MyPopup()
    main_window.show()
    sys.exit(app.exec_())

Code d'erreur

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
Traceback (most recent call last):
 File "3.py", line 51, in <module>
app = QtGui.QTableWidget(sys.argv)
TypeError: arguments did not match any overloaded call:
QTableWidget(QWidget parent=None): argument 1 has unexpected type 'list'
QTableWidget(int, int, QWidget parent=None): argument 1 has unexpected type 'list'