| 1 | # QtAwesome |
| 2 | |
| 3 | [](./LICENSE) |
| 4 | [](https://pypi.org/project/qtawesome/) |
| 5 | [](https://www.anaconda.com/download/) |
| 6 | [](https://www.anaconda.com/download/) |
| 7 | [](#backers) |
| 8 | [](https://gitter.im/spyder-ide/public)<br> |
| 9 | [](https://github.com/spyder-ide/qtawesome) |
| 10 | [](https://github.com/spyder-ide/qtawesome/actions) |
| 11 | [](https://github.com/spyder-ide/qtawesome/actions) |
| 12 | [](https://github.com/spyder-ide/qtawesome/actions) |
| 13 | [](https://qtawesome.readthedocs.io/en/latest/?badge=latest) |
| 14 | [](https://codecov.io/gh/spyder-ide/qtawesome) |
| 15 | |
| 16 | *Copyright © 2015- Spyder Project Contributors* |
| 17 | |
| 18 | |
| 19 | ## Description |
| 20 | |
| 21 | QtAwesome enables iconic fonts such as Font Awesome and Elusive Icons |
| 22 | in PyQt and PySide applications. |
| 23 | |
| 24 | It started as a Python port of the [QtAwesome]( |
| 25 | https://github.com/Gamecreature/qtawesome) |
| 26 | C++ library by Rick Blommers. |
| 27 | |
| 28 | |
| 29 | ## Installation |
| 30 | |
| 31 | Using `conda`: |
| 32 | |
| 33 | ``` |
| 34 | conda install qtawesome |
| 35 | ``` |
| 36 | |
| 37 | or using `pip` (only if you don't have conda installed): |
| 38 | |
| 39 | ``` |
| 40 | pip install qtawesome |
| 41 | ``` |
| 42 | |
| 43 | |
| 44 | ## Usage |
| 45 | |
| 46 | ### Supported Fonts |
| 47 | |
| 48 | QtAwesome identifies icons by their **prefix** and their **icon name**, separated by a *period* (`.`) character. |
| 49 | |
| 50 | The following prefixes are currently available to use: |
| 51 | |
| 52 | - [**FontAwesome**](https://fontawesome.com): |
| 53 | |
| 54 | - FA 6.7.2 features 2,060 free icons in different styles: |
| 55 | |
| 56 | - `fa6` prefix has [163 icons in the "**regular**" style.](https://fontawesome.com/v6/search?o=r&ic=free&s=regular) |
| 57 | - `fa6s` prefix has [1402 icons in the "**solid**" style.](https://fontawesome.com/v6/search?o=r&ic=free&s=solid) |
| 58 | - `fa6b` prefix has [495 icons of various **brands**.](https://fontawesome.com/v6/search?o=r&ic=free&ip=brands) |
| 59 | |
| 60 | - FA 5.15.4 features 1,608 free icons in different styles: |
| 61 | |
| 62 | - `fa5` prefix has [151 icons in the "**regular**" style.](https://fontawesome.com/v5/search?o=r&ic=free&s=regular) |
| 63 | - `fa5s` prefix has [1001 icons in the "**solid**" style.](https://fontawesome.com/v5/search?o=r&ic=free&s=solid) |
| 64 | - `fa5b` prefix has [456 icons of various **brands**.](https://fontawesome.com/v5/search?ic=brands) |
| 65 | |
| 66 | - `ei` prefix holds [**Elusive Icons** 2.0 with its 304 icons](http://elusiveicons.com/icons/). |
| 67 | |
| 68 | - [**Material Design Icons**](https://pictogrammers.com/library/mdi/) |
| 69 | |
| 70 | - `mdi6` prefix holds [**Material Design Icons** 6.9.96 with its 6997 icons.](https://cdn.materialdesignicons.com/6.9.96/) |
| 71 | |
| 72 | - `mdi` prefix holds [**Material Design Icons** 5.9.55 with its 5955 icons.](https://cdn.materialdesignicons.com/5.9.55/) |
| 73 | |
| 74 | - `ph` prefix holds [**Phosphor** 1.3.0 with its 4470 icons (894 icons * 5 weights: Thin, Light, Regular, Bold and Fill).](https://github.com/phosphor-icons/phosphor-icons) |
| 75 | |
| 76 | - `ri` prefix holds [**Remix Icon** 2.5.0 with its 2271 icons.](https://github.com/Remix-Design/RemixIcon) |
| 77 | |
| 78 | - `msc` prefix holds Microsoft's [**Codicons** 0.0.36 with its 569 icons.](https://github.com/microsoft/vscode-codicons) |
| 79 | |
| 80 | ### Examples |
| 81 | |
| 82 | ```python |
| 83 | import qtawesome as qta |
| 84 | ``` |
| 85 | |
| 86 | - Use Font Awesome, Elusive Icons, Material Design Icons, Phosphor, Remix Icon or Microsoft's Codicons. |
| 87 | |
| 88 | ```python |
| 89 | # Get FontAwesome 6.x icons by name in various styles: |
| 90 | fa6_icon = qta.icon('fa6.flag') |
| 91 | fa6_button = QtWidgets.QPushButton(fa6_icon, 'Font Awesome 6! (regular)') |
| 92 | fa6s_icon = qta.icon('fa6s.flag') |
| 93 | fa6s_button = QtWidgets.QPushButton(fa6s_icon, 'Font Awesome 6! (solid)') |
| 94 | fa6b_icon = qta.icon('fa6b.github') |
| 95 | fa6b_button = QtWidgets.QPushButton(fa6b_icon, 'Font Awesome 6! (brands)') |
| 96 | |
| 97 | # or FontAwesome 5.x icons by name in various styles: |
| 98 | fa5_icon = qta.icon('fa5.flag') |
| 99 | fa5_button = QtWidgets.QPushButton(fa5_icon, 'Font Awesome 5! (regular)') |
| 100 | fa5s_icon = qta.icon('fa5s.flag') |
| 101 | fa5s_button = QtWidgets.QPushButton(fa5s_icon, 'Font Awesome 5! (solid)') |
| 102 | fa5b_icon = qta.icon('fa5b.github') |
| 103 | fa5b_button = QtWidgets.QPushButton(fa5b_icon, 'Font Awesome 5! (brands)') |
| 104 | |
| 105 | # or Elusive Icons: |
| 106 | asl_icon = qta.icon('ei.asl') |
| 107 | elusive_button = QtWidgets.QPushButton(asl_icon, 'Elusive Icons!') |
| 108 | |
| 109 | # or Material Design Icons: |
| 110 | apn_icon = qta.icon('mdi6.access-point-network') |
| 111 | mdi6_button = QtWidgets.QPushButton(apn_icon, 'Material Design Icons!') |
| 112 | |
| 113 | # or Phosphor: |
| 114 | mic_icon = qta.icon('ph.microphone-fill') |
| 115 | ph_button = QtWidgets.QPushButton(mic_icon, 'Phosphor!') |
| 116 | |
| 117 | # or Remix Icon: |
| 118 | truck_icon = qta.icon('ri.truck-fill') |
| 119 | ri_button = QtWidgets.QPushButton(truck_icon, 'Remix Icon!') |
| 120 | |
| 121 | # or Microsoft's Codicons: |
| 122 | squirrel_icon = qta.icon('msc.squirrel') |
| 123 | msc_button = QtWidgets.QPushButton(squirrel_icon, 'Codicons!') |
| 124 | |
| 125 | ``` |
| 126 | |
| 127 | - Apply some styling |
| 128 | |
| 129 | ```python |
| 130 | # Styling icons |
| 131 | styling_icon = qta.icon('fa5s.music', |
| 132 | active='fa5s.balance-scale', |
| 133 | color='blue', |
| 134 | color_active='orange') |
| 135 | music_button = QtWidgets.QPushButton(styling_icon, 'Styling') |
| 136 | ``` |
| 137 | |
| 138 | - Set alpha in colors |
| 139 | |
| 140 | ```python |
| 141 | # Setting an alpha of 120 to the color of this icon. Alpha must be a number |
| 142 | # between 0 and 255. |
| 143 | icon_with_alpha = qta.icon('mdi.heart', |
| 144 | color=('red', 120)) |
| 145 | heart_button = QtWidgets.QPushButton(icon_with_alpha, 'Setting alpha') |
| 146 | ``` |
| 147 | |
| 148 | - Stack multiple icons |
| 149 | |
| 150 | ```python |
| 151 | # Stacking icons |
| 152 | camera_ban = qta.icon('fa5s.camera', 'fa5s.ban', |
| 153 | options=[{'scale_factor': 0.5, |
| 154 | 'active': 'fa5s.balance-scale'}, |
| 155 | {'color': 'red'}]) |
| 156 | stack_button = QtWidgets.QPushButton(camera_ban, 'Stack') |
| 157 | stack_button.setIconSize(QtCore.QSize(32, 32)) |
| 158 | ``` |
| 159 | |
| 160 | - Define the way to draw icons (`text`- default for icons without animation, `path` - default for icons with animations, `glyphrun` and `image`) |
| 161 | |
| 162 | ```python |
| 163 | # Icon drawn with the `image` option |
| 164 | drawn_image_icon = qta.icon('ri.truck-fill', |
| 165 | options=[{'draw': 'image'}]) |
| 166 | drawn_image_button = QtWidgets.QPushButton(drawn_image_icon, |
| 167 | 'Icon drawn as an image') |
| 168 | ``` |
| 169 | |
| 170 | - Animations |
| 171 | |
| 172 | ```python |
| 173 | # Spining icons |
| 174 | spin_button = QtWidgets.QPushButton(' Spinning icon') |
| 175 | animation = qta.Spin(spin_button) |
| 176 | spin_icon = qta.icon('fa5s.spinner', color='red', animation=animation) |
| 177 | spin_button.setIcon(spin_icon) |
| 178 | |
| 179 | # Stop the animation when needed |
| 180 | animation.stop() |
| 181 | ``` |
| 182 | |
| 183 | - Display Icon as a widget |
| 184 | |
| 185 | ```python |
| 186 | # Spining icon widget |
| 187 | spin_widget = qta.IconWidget() |
| 188 | animation = qta.Spin(spin_widget, autostart=False) |
| 189 | spin_icon = qta.icon('mdi.loading', color='red', animation=animation) |
| 190 | spin_widget.setIcon(spin_icon) |
| 191 | |
| 192 | # Simple icon widget |
| 193 | simple_widget = qta.IconWidget('mdi.web', color='blue', |
| 194 | size=QtCore.QSize(16, 16)) |
| 195 | |
| 196 | # Start and stop the animation when needed |
| 197 | animation.start() |
| 198 | animation.stop() |
| 199 | ``` |
| 200 | |
| 201 | - Screenshot |
| 202 | |
| 203 |  |
| 204 | |
| 205 | |
| 206 | To check these options you can launch the `example.py` script and pass to it the options as arguments. For example, to test how the icons could look using the `glyphrun` draw option, you can run something like: |
| 207 | |
| 208 | ``` |
| 209 | python example.py draw=glyphrun |
| 210 | ``` |
| 211 | |
| 212 | ## Other features |
| 213 | |
| 214 | - QtAwesome comes bundled with _Font Awesome_, _Elusive Icons_, _Material Design_ |
| 215 | _Icons_, _Phosphor_, _Remix Icon_ and Microsoft's _Codicons_ |
| 216 | but it can also be used with other iconic fonts. The `load_font` |
| 217 | function allows to load other fonts dynamically. |
| 218 | - QtAwesome relies on the [QtPy](https://github.com/spyder-ide/qtpy.git) |
| 219 | project as a compatibility layer on the top ot PyQt or PySide. |
| 220 | |
| 221 | ### Icon Browser |
| 222 | |
| 223 | QtAwesome ships with a browser that displays all the available icons. You can |
| 224 | use this to search for an icon that suits your requirements and then copy the |
| 225 | name that should be used to create that icon! |
| 226 | |
| 227 | Once installed, run `qta-browser` from a shell to start the browser. |
| 228 | |
| 229 |  |
| 230 | |
| 231 | |
| 232 | ## License |
| 233 | |
| 234 | MIT License. Copyright 2015 - The Spyder development team. |
| 235 | See the [LICENSE](LICENSE) file for details. |
| 236 | |
| 237 | The [Font Awesome](https://github.com/FortAwesome/Font-Awesome/blob/master/LICENSE.txt) and [Elusive Icons](http://elusiveicons.com/license/) fonts are licensed under the [SIL Open Font License](http://scripts.sil.org/OFL). |
| 238 | |
| 239 | The Phosphor font is licensed under the [MIT License](https://github.com/phosphor-icons/phosphor-icons/blob/master/LICENSE). |
| 240 | |
| 241 | The [Material Design Icons](https://github.com/Templarian/MaterialDesign/blob/master/LICENSE) font is licensed under the [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). |
| 242 | |
| 243 | The Remix Icon font is licensed under the [Apache License Version 2.0](https://github.com/Remix-Design/remixicon/blob/master/License). |
| 244 | |
| 245 | Microsoft's Codicons are licensed under a [Creative Commons Attribution 4.0 International Public License](https://github.com/microsoft/vscode-codicons/blob/master/LICENSE). |
| 246 | |
| 247 | ## Sponsors |
| 248 | |
| 249 | Spyder and its subprojects are funded thanks to the generous support of |
| 250 | |
| 251 | [](https://www.quansight.com/)[](https://numfocus.org/) |
| 252 | |
| 253 | and the donations we have received from our users around the world through [Open Collective](https://opencollective.com/spyder/): |
| 254 | |
| 255 | [](https://opencollective.com/spyder#support) |