Taurus icon guide

Usually the application/widget you are developing will require some icons. Some of these icons will be used to represent a standard actions, applications, places or status like “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 will make your application be more integrated with the rest of the system, but 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 as what you want)

Apart from the theme icons, Taurus provides some collections of icons (and you can add more (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

In order to explore the icon collections provided by Taurus, you can use the taurus icons application, which will let you browse the icons.

../_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