Helper functions to handle icons and pixmaps
Most common use cases are:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import Icon
app = Application()
# get a theme icon
icon = Icon("folder-open")
button = QtGui.QPushButton(icon, "Open file...")
button.show()
app.exec_()
or in a label:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import Icon
app = Application()
# get a theme pixmap
pixmap = Pixmap("folder-open")
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
Functions
| Icon | Returns a QIcon for the given icon. |
| Pixmap | Returns a QPixmap for the given pixmap. |
| getIcon | Returns a QIcon for the given icon. |
| getPixmap | Returns a QPixmap for the given pixmap. |
| getQarbonIcon | Returns a QIcon for the given qarbon icon name. |
| getQarbonPixmap | Returns a QPixmap for the given pixmap name. |
| getStandardIcon | Returns a QIcon for the given icon ID (QtGui.QStyle.SP_*). |
| getStandardPixmap | Returns a QPixmap for the given icon ID (QtGui.QStyle.SP_*). |
| getStateIcon | Returns a QIcon for the given State. |
| getThemeIcon | Returns a QIcon for the given theme icon name. |
| getThemePixmap | Returns a QPixmap for the given theme pixmap name. |
Returns a QIcon for the given theme icon name.
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getThemeIcon
app = Application()
icon = getThemeIcon("folder-open")
button = QtGui.QPushButton(icon, "Open folder")
button.show()
app.exec_()
| Parameters: | icon_name (str) – icon name |
|---|---|
| Returns: | the QIcon corresponding to the given theme name. If the theme icon doesn’t exist it returns a Null icon |
| Return type: | QtGui.QIcon |
Returns a QPixmap for the given theme pixmap name.
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getThemePixmap
app = Application()
pixmap = getThemePixmap("folder-open", 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
| Parameters: | |
|---|---|
| Returns: | the QPixmap corresponding to the given theme name. If the theme icon doesn’t exist it returns a Null pixmap |
| Return type: | QtGui.QPixmap |
Returns a QIcon for the given icon ID (QtGui.QStyle.SP_*).
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getStandardIcon
app = Application()
icon = getStandardIcon(QtGui.QStyle.SP_MessageBoxWarning)
button = QtGui.QPushButton(icon, "Open hutch")
button.show()
app.exec_()
| Parameters: | icon_id (QtGui.QStyle.SP) – icon name |
|---|---|
| Returns: | the QIcon corresponding to the given id. If the standard ID doesn’t exist it returns a Null icon |
| Return type: | QtGui.QIcon |
Returns a QPixmap for the given icon ID (QtGui.QStyle.SP_*).
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getStandardPixmap
app = Application()
pixmap = getStandardPixmap(QtGui.QStyle.SP_MessageBoxWarning, 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
| Parameters: | |
|---|---|
| Returns: | the QPixmap corresponding to the given id. If the standard ID doesn’t exist it returns a Null QPixmap |
| Return type: | QtGui.QPixmap |
Returns a QIcon for the given qarbon icon name.
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getQarbonIcon
app = Application()
icon = getQarbonIcon(":/controls/collapse.png")
button = QtGui.QPushButton(icon, "Collapse")
button.show()
app.exec_()
| Parameters: | icon_name (str) – icon name |
|---|---|
| Returns: | the QIcon corresponding to the given qarbon name. If the icon doesn’t exist it returns a Null icon |
| Return type: | QtGui.QIcon |
Returns a QPixmap for the given pixmap name.
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getQarbonPixmap
app = Application()
pixmap = getQarbonPixmap(":/controls/collapse.png", 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
| Parameters: | |
|---|---|
| Returns: | the QPixmap corresponding to the given id. If the standard ID doesn’t exist it returns a Null QPixmap |
| Return type: | QtGui.QPixmap |
Returns a QIcon for the given icon.
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getIcon
app = Application()
# == getThemeIcon("folder-open")
icon = getIcon("folder-open")
# == getQarbonIcon(":/controls/collapse.png")
icon = getIcon(":/controls/collapse.png")
# == Qt.QIcon("MyResource:/bla.png")
icon = getIcon("MyResource:/bla.png")
# == getStandardIcon(QtGui.QStyle.SP_MessageBoxWarning)
icon = getIcon(QtGui.QStyle.SP_MessageBoxWarning)
button = QtGui.QPushButton(icon, "Something")
button.show()
app.exec_()
| Parameters: | icon (str or int) – icon name or ID |
|---|---|
| Returns: | the QIcon corresponding to the given icon. If the icon doesn’t exist it returns a Null icon |
| Return type: | QtGui.QIcon |
Returns a QPixmap for the given pixmap.
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getPixmap
app = Application()
# == getThemePixmap("folder-open", 32)
pixmap = getPixmap("folder-open", 32)
# == getQarbonPixmap(":/controls/collapse.png", 32)
pixmap = getPixmap(":/controls/collapse.png", 32)
# == QtGui.QPixmap("MyResource:/bla.png")
pixmap = getPixmap("MyResource:/bla.png", 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
| Parameters: | |
|---|---|
| Returns: | the QPixmap corresponding to the given pixmap. If the pixmap doesn’t exist it returns a Null QPixmap |
| Return type: | QtGui.QPixmap |
Returns a QIcon for the given icon.
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import Icon
app = Application()
# == getThemeIcon("folder-open")
icon = Icon("folder-open")
# == getQarbonIcon(":/controls/collapse.png")
icon = Icon(":/controls/collapse.png")
# == Qt.QIcon("MyResource:/bla.png")
icon = Icon("MyResource:/bla.png")
# == getStandardIcon(QtGui.QStyle.SP_MessageBoxWarning)
icon = Icon(QtGui.QStyle.SP_MessageBoxWarning)
button = QtGui.QPushButton(icon, "Something")
button.show()
app.exec_()
| Parameters: | icon (str or int) – icon name or ID |
|---|---|
| Returns: | the QIcon corresponding to the given icon. If the icon doesn’t exist it returns a Null icon |
| Return type: | QtGui.QIcon |
Returns a QPixmap for the given pixmap.
Example:
from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import Pixmap
app = Application()
# == getThemePixmap("folder-open", 32)
pixmap = Pixmap("folder-open", 32)
# == getQarbonPixmap(":/controls/collapse.png", 32)
pixmap = Pixmap(":/controls/collapse.png", 32)
# == QtGui.QPixmap("MyResource:/bla.png")
pixmap = Pixmap("MyResource:/bla.png", 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
| Parameters: | |
|---|---|
| Returns: | the QPixmap corresponding to the given pixmap. If the pixmap doesn’t exist it returns a Null QPixmap |
| Return type: | QtGui.QPixmap |