[PyKDE] Stock icons? (Newbie question)
David Boddie
david at boddie.org.uk
Fri Feb 9 21:46:41 GMT 2007
On Friday 09 February 2007 10:06:56 +0000, Richard Taylor wrote:
> Just working on my first PyQt application.
>
> I was wondering if there are meant to be "stock" icons for use in the
> toolbar, for things like Open/New/Close/Save etc. I can't find any
> reference to them in the documentation anywhere.
The style for the platform you are using provides the standard images (or
pixmaps) that are needed for dialogs and other GUI elements.
Take a look at QStyle's standardPixmap() method:
http://www.riverbankcomputing.com/Docs/PyQt4/html/qstyle.html#standardPixmap
# For example
style = qApp.style()
so = QStyleOption()
so.initFrom(widget) # perhaps a toolbar
so.rect = QRect(0, 0, width, height)
icon = QIcon(style.standardPixmap(QStyle.StandardPixmap(i), so)
This will allow you to retrieve some icons, but may not include the ones
you need. Similarly, you can examine the contents of Qt's resource system
to find images that are built into Qt, but I'm not sure if these are present
on all platforms:
# For example
d = QDir(":/trolltech/styles/commonstyle/images/")
map(str, d.entryList())
These seem to be more varied (on KDE, at least) but may not include the icons
you want. You may need to look around to find suitably-licensed icons for
certain actions.
David
More information about the PyQt
mailing list