Le 04/08/11 18:06, Tony Peña a écrit :
Hi i trying set logoimage into cell of QtableWidget

all code runs ok but can't see the image in the table

i try with .gif and .png files

any idea?

heres the code:

./airlines/ (many logosfiles in ABC.gif and ABC.png)
if exist show up ifnot just say the code of aircraft

            code_airline = row[0][:3]
            airlineCodePath = './airlines/%s.png' % code_airline
            try:
                if os.path.exists(airlineCodePath) is True:
                    image = QtGui.QIcon(QtGui.QPixmap(airlineCodePath))
                    airline = QtGui.QTableWidgetItem(image)
                    airline.setIcon(image)
                    col_airline = QtGui.QTableWidgetItem(airline, 0)
                    self.ui.PILOT_FullList.Seti(startrow, 1, code_airline)    
                else:
                    code_airline = '-'
                    col_airline = QtGui.QTableWidgetItem(code_airline, 0)
                    self.ui.PILOT_FullList.setItem(startrow, 0, col_airline)   
            except:
                pass         

thanxs any way by all


--
Antonio Peña
Secure email with PGP 0x8B021001 available at http://pgp.mit.edu
Fingerprint: 74E6 2974 B090 366D CE71  7BB2 6476 FA09 8B02 1001
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Hi,

Your construction is not exact

        icon = QtGui.QIcon(QtGui.QPixmap("image_path"))
        item = QtGui.QTableWidgetItem(icon, "")        # Second argument (required !) is text
        self.tableWidget.setItem(0, 0, item)

Normaly you should have errors but with your "try: except: pass" ...

--
Vincent V.V.
Oqapy . Qarte+7 . PaQager


_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to