[PyKDE] custom style problem

Phil Thompson phil at riverbankcomputing.co.uk
Thu Jul 8 16:31:00 BST 2004


On Thursday 08 July 2004 13:45, Vicent Mas wrote:
> Hi,
> I'm trying to create a simple custom style (newbie with styles) but I
> cannot to make it work, so I need some help. This is what I've done.
>
> customstyle script
> -------------------------
> from qt import *
>
> class CustomStyle(QWindowsStyle):
> 	def __init__(self) :
> 		apply(QWindowsStyle.__init__m (self,))
>
> 	def drawControl(self, celem, painter, widget, rect, colorGroup, flags,
> opt) : print "I'm here"
> 		if celem ==QStyle.CE_PushButtonLabel :
> 			# do something
> 		else :
> 			QWindowsStyle(self, celem, painter, widget, rect, colorGroup, flags,
> opt)
>
> main script:
> ----------------
> from customstyle import *
> ...
> app = QApplication(args)
> app.setStyle(customStyle())
> ...
>
> I expected that when the application draws the label (pixmap or iconset
> with text) of any QPushButton some actions would be executed, but nothing
> happens. In fact the string <I'm here> is never printed.
> I really don't know what is wrong. Please, could you tell me where are the
> mistakes?

Works for me - once all the syntax errors in the above fragment are fixed (and 
the incorrect call to the QWindowsStyle ctor is replaced by a call to 
QWindows.drawControl()).

It's always better to post a complete script - like the attached.

Phil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: style.py
Type: application/x-python
Size: 393 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20040708/a4c3fb8d/style.bin


More information about the PyQt mailing list