Previous topic

qarbon.qt.gui.groupbox

Next topic

qarbon.qt.gui.input

This Page

qarbon.qt.gui.icon

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.
qarbon.qt.gui.icon.getThemeIcon(icon_name)[source]

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
qarbon.qt.gui.icon.getThemePixmap(pixmap_name, width, height=None, mode=0, state=1)[source]

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:
  • pixmap_name (str) – pixmap name
  • width (int) – pixmap width
  • height (int) – pixmap height [default: None meaning use given width]
  • mode (QtGui.QIcon.Mode) – icon mode
  • state (QtGui.QIcon.State) – icon state
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

qarbon.qt.gui.icon.getStandardIcon(icon_id)[source]

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
qarbon.qt.gui.icon.getStandardPixmap(pixmap_id, width, height=None, mode=0, state=1)[source]

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:
  • pixmap_id (QtGui.QStyle.SP) – pixmap name
  • width (int) – pixmap width
  • height (int) – pixmap height [default: None meaning use given width]
  • mode (QtGui.QIcon.Mode) – icon mode
  • state (QtGui.QIcon.State) – icon state
Returns:

the QPixmap corresponding to the given id. If the standard ID doesn’t exist it returns a Null QPixmap

Return type:

QtGui.QPixmap

qarbon.qt.gui.icon.getQarbonIcon(icon_name)[source]

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
qarbon.qt.gui.icon.getQarbonPixmap(pixmap_name, width, height=None, mode=0, state=1)[source]

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:
  • pixmap_name (str) – pixmap name
  • width (int) – pixmap width
  • height (int) – pixmap height [default: None meaning use given width]
  • mode (QtGui.QIcon.Mode) – icon mode
  • state (QtGui.QIcon.State) – icon state
Returns:

the QPixmap corresponding to the given id. If the standard ID doesn’t exist it returns a Null QPixmap

Return type:

QtGui.QPixmap

qarbon.qt.gui.icon.getIcon(icon)[source]

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
qarbon.qt.gui.icon.getPixmap(pixmap, width, height=None, mode=0, state=1)[source]

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:
  • pixmap (str or int) – pixmap name or ID
  • width (int) – pixmap width
  • height (int) – pixmap height [default: None meaning use given width]
  • mode (QtGui.QIcon.Mode) – icon mode
  • state (QtGui.QIcon.State) – icon state
Returns:

the QPixmap corresponding to the given pixmap. If the pixmap doesn’t exist it returns a Null QPixmap

Return type:

QtGui.QPixmap

qarbon.qt.gui.icon.Icon(obj)[source]

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
qarbon.qt.gui.icon.Pixmap(obj, width, height=None, mode=0, state=1)[source]

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:
  • pixmap (str or int) – pixmap name or ID
  • width (int) – pixmap width
  • height (int) – pixmap height [default: None meaning use given width]
  • mode (QtGui.QIcon.Mode) – icon mode
  • state (QtGui.QIcon.State) – icon state
Returns:

the QPixmap corresponding to the given pixmap. If the pixmap doesn’t exist it returns a Null QPixmap

Return type:

QtGui.QPixmap