[PyQt] Trying insert image into QTableWidget

Tony Peña emperor.cu at gmail.com
Thu Aug 4 17:54:51 BST 2011


Ohh.. about errors.. ok it is for try excep pass.. sorry for that..
and yes i have use Qlabel with Pixmap in other QWIdgetTab
and works.. i try it with QLabel again

thanxs

2011/8/4 Vincent Vande Vyvre <vincent.vandevyvre at swing.be>

> **
> 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 at riverbankcomputing.comhttp://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 <https://launchpad.net/oqapy> . Qarte+7<https://launchpad.net/qarte+7>.
> PaQager <https://launchpad.net/paqager>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110804/6645e1e8/attachment.html>


More information about the PyQt mailing list