Re: PySide version getting an error when field_attributes try to set background color

80 views
Skip to first unread message

Erik Janssens

unread,
Apr 17, 2013, 5:41:41 PM4/17/13
to project...@googlegroups.com
Hello Tim,

are you sure you're not mixing PySide and PyQt in the same application

it looks like the QColor class would be imported from PyQt, and then
passed to a PySide version of Camelot.

Cheers,

Erik

On Wednesday, April 17, 2013 8:19:13 AM UTC+2, Tim Hoffman wrote:
Hi

Love Camelot.

However found a wart when running under pyside .  (Ubuntu 12.10, latest pyside etc..)
I have field attributes defined to set the background color on fields based on certain calculations (ie warning) this works great with PyQt.

However I get lots of errors when running under pyside e.g. and any cell which I set the background color , doesn't show (actually the text is there but can only be seen if you select the text, ie white text on white backgound)

File "/usr/local/lib/python2.7/dist-packages/Camelot-12.06.29-py2.7.egg/camelot/view/controls/delegates/delegatemanager.py", line 76, in paint
    delegate.paint(painter, option, index)
  File "/usr/local/lib/python2.7/dist-packages/Camelot-12.06.29-py2.7.egg/camelot/view/controls/delegates/floatdelegate.py", line 75, in paint
    self.paint_text( painter, option, index, value_str, horizontal_align=Qt.AlignRight )
  File "/usr/local/lib/python2.7/dist-packages/Camelot-12.06.29-py2.7.egg/camelot/view/controls/delegates/customdelegate.py", line 239, in paint_text
    painter.fillRect(rect, background_color or option.palette.base() )
TypeError: arguments did not match any overloaded call:
  QPainter.fillRect(QRectF, QBrush): argument 1 has unexpected type 'QRect'
  QPainter.fillRect(QRect, QBrush): argument 2 has unexpected type 'PySide.QtGui.QColor'
  QPainter.fillRect(int, int, int, int, QBrush): argument 1 has unexpected type 'QRect'
  QPainter.fillRect(QRectF, QColor): argument 1 has unexpected type 'QRect'
  QPainter.fillRect(QRect, QColor): argument 2 has unexpected type 'PySide.QtGui.QColor'
  QPainter.fillRect(int, int, int, int, QColor): argument 1 has unexpected type 'QRect'
  QPainter.fillRect(int, int, int, int, Qt.GlobalColor): argument 1 has unexpected type 'QRect'
  QPainter.fillRect(QRect, Qt.GlobalColor): argument 2 has unexpected type 'PySide.QtGui.QColor'
  QPainter.fillRect(QRectF, Qt.GlobalColor): argument 1 has unexpected type 'QRect'
  QPainter.fillRect(int, int, int, int, Qt.BrushStyle): argument 1 has unexpected type 'QRect'
  QPainter.fillRect(QRect, Qt.BrushStyle): argument 2 has unexpected type 'PySide.QtGui.QColor'
  QPainter.fillRect(QRectF, Qt.BrushStyle): argument 1 has unexpected type 'QRect'


My field attributes for a view are defined such as 

field_attributes = {
        'new_rrp':{'background_color':has_rrp_changed},
}
 and the code looks like 

def has_rrp_changed(product):
    if product.new_rrp != product.current_rrp:
        return QColor('red')
    else:
        return QColor('white')

I also tried with RGB values.

If I remove the field_attributes altogether then things render correctly.  Am I doing something wrong here ;-)

Cheers

Tim

Tim Hoffman

unread,
Apr 18, 2013, 4:55:16 AM4/18/13
to project...@googlegroups.com
Hi Erik

The code I am running is as a result of using camelot_admin  to_pyside option.

The new code has been translated so its importing QColor from pyside  i.e. it is now 

from PySide.QtGui import QColor

I have had a look around at the translated code and I can't see any reference to PyQt anywhere.

Cheers

Tim

Erik Janssens

unread,
Apr 18, 2013, 4:55:37 PM4/18/13
to project...@googlegroups.com
the translated code is probably fine

I suspect it's the code that creates the field attribute that imports PyQt instead
of PySide

the QColor in this part probably comes from PyQt :


def has_rrp_changed(product):
    if product.new_rrp != product.current_rrp:
        return QColor('red')
    else:
        return QColor('white')


--
--
You received this message because you are subscribed to the "Project Camelot" group.
Visit www.python-camelot.com for more information
 
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to
project-camel...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/project-camelot?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Project Camelot" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-camel...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tim Hoffman

unread,
Apr 18, 2013, 8:54:13 PM4/18/13
to project...@googlegroups.com, erik.j...@conceptive.be
OK, now sort of understand what is going on.

I am actually running Camelot from an ppa install on Ubuntu.

The 'to_pyside' only translated my code but obviously left the installed egg untouched - why didn't I look at the core code ;-)

So of course in all the actual Camleot code it's still using PyQt

So how is one supposed to use the to_pysde option of camelot_admin, should I have be developing in a source tree that includes all of camelot 
source so it all gets translated?

I hadn't really thought through what the few lines in the docs said you can do.

Cheers

Tim 

Erik Janssens

unread,
Apr 23, 2013, 12:21:07 AM4/23/13
to project...@googlegroups.com
yes, both the Camelot code and the application code need to use either PyQt or PySide

you can download the PySide version from :

https://bitbucket.org/conceptive/camelot/downloads

alternatively, you can download a source tarball and run the to_pyside command manual

Tim Hoffman

unread,
Apr 23, 2013, 1:46:10 AM4/23/13
to project...@googlegroups.com, erik.j...@conceptive.be
Ok, missed that step ;-) cheers. 

 If I had of engadged brain I would have realized.
Reply all
Reply to author
Forward
0 new messages