[PyQt] Trying insert image into QTableWidget

2011-08-04 Thread Tony Peña
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 listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Trying insert image into QTableWidget

2011-08-04 Thread Luca Beltrame
In data giovedì 04 agosto 2011 11:36:14, Tony Peña ha scritto:

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

Did you try using a QLabel without text as item and setting a pixmap there
through setPixmap?

--
Luca Beltrame - KDE Forums team
KDE Science supporter
GPG key ID: 6E1A4E79


signature.asc
Description: This is a digitally signed message part.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Trying insert image into QTableWidget

2011-08-04 Thread Vincent Vande Vyvre


  
  
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 listPyQt@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 listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Trying insert image into QTableWidget

2011-08-04 Thread Tony Peña
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.vandevy...@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@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+7https://launchpad.net/qarte+7.
 PaQager https://launchpad.net/paqager

 ___
 PyQt mailing listPyQt@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
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Trying insert image into QTableWidget

2011-08-04 Thread Tony Peña
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...@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.vandevy...@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@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+7https://launchpad.net/qarte+7.
 PaQager https://launchpad.net/paqager

 ___
 PyQt mailing listPyQt@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
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Trying insert image into QTableWidget

2011-08-04 Thread Hans-Peter Jansen
On Thursday 04 August 2011, 21:45:01 Tony Peña wrote:
 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???

From a cursory look, you seem to forgot to hold a reference to your 
label. Try:

airline = QtGui.QLabel(self)
pixmap = QtGui.QPixmap(airlineCodePath)
airline.setPixmap(pixmap)

Vincent questioned your catch all exception handler already..
It's hard to make some sense from your snippets. Try to provide a 
minimum runnable example, if you're after substantial help.

Pete
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt