Icons

Applications and widgets commonly need icons to represent standard actions, applications, places, or states such as “open a file”, “desktop”, or “preferences”.

Qt (and therefore, Taurus) supports theme icons for many common cases. You can access them via the standard QIcon.fromTheme() method. Using theme icons helps your application integrate with the rest of the system. Keep in mind that different people will see the icons differently depending on their default theme (so do not use a theme icon for something not related to its specification just because in your theme it happens to look like what you want).

Apart from theme icons, Taurus provides its own icon collections, and additional collections can be registered (see taurus.qt.qtgui.icon). The paths containing these collections are automatically added to QDir’s search paths under various prefixes when you import taurus.qt.qtgui (or any of its submodules).

The following example shows how to use theme and non-theme icons in your application:

from taurus.external.qt import Qt
from taurus.qt.qtgui.application import TaurusApplication


class MyGUI(Qt.QMainWindow):
    def __init__(self, parent=None):
        Qt.QMainWindow.__init__(self, parent)
        toolbar = self.addToolBar("Tools")

        # get icon from theme
        icon1 = Qt.QIcon.fromTheme("document-open")

        # get icon using prefix + filename
        icon2 = Qt.QIcon("actions:exit.svg")

        toolbar.addAction(icon1, "Open HDF5", self.open_file)
        toolbar.addAction(icon2, "Exit", self.close)

    def open_file(self):
        pass  # do something


if __name__ == "__main__":
    import sys

    app = TaurusApplication(cmd_line_parser=None)
    gui = MyGUI()
    gui.show()
    sys.exit(app.exec_())

Taurus icon catalog

To explore the icon collections provided by Taurus, use the taurus icons command.

../_images/taurusiconcatalog-01.png

By clicking on an icon of the catalog, you will obtain a larger view of the icon as well as detailed information on how to access it from your application.

../_images/taurusiconcatalog-details01.png