[PyQt] Trying insert image into QTableWidget

Tony Peña emperor.cu at gmail.com
Thu Aug 4 20:45:01 BST 2011


ok nothing yet
i refresh the code again here with QLabel now.. :|

            airlineCodePath = './airlines/%s.gif' % code_airline
            try:
                if os.path.exists(airlineCodePath) is True:
                    airline = QtGui.QLabel()
                    Pixmap = QtGui.QPixmap(airlineCodePath)
                    airline.fileName = airlineCodePath
                    col_airline = QtGui.QLabel.setPixmap(Pixmap)
                    self.ui.PILOT_FullList.setItem(startrow, 0, col_airline)
                else:
                    code_airline = '-'
                    col_airline = QtGui.QTableWidgetItem(code_airline, 0)
                    self.ui.PILOT_FullList.setItem(startrow, 0, col_airline)

            except:
                pass

someone can made simple table 1x1 with a simple .gif, .png or .jpg
example???

regards

2011/8/4 Tony Peña <emperor.cu at gmail.com>

> 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
>



-- 
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/6e0b4986/attachment-0001.html>


More information about the PyQt mailing list