Created
August 15, 2025 17:28
-
-
Save 5j9/6f01384fbb3e378283f6b529d03b1450 to your computer and use it in GitHub Desktop.
PyQt6 List of Standard Icons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A fork of https://joekuan.wordpress.com/2015/09/23/list-of-qt-icons/ | |
| # Modified to work with PyQt6 and also avoids using a hardcoded list. | |
| # of icons. | |
| from PyQt6.QtWidgets import ( | |
| QApplication, | |
| QGridLayout, | |
| QPushButton, | |
| QStyle, | |
| QWidget, | |
| ) | |
| class Widget(QWidget): | |
| def __init__(self, parent=None): | |
| super().__init__() | |
| colSize = 4 | |
| layout = QGridLayout() | |
| count = 0 | |
| for icon in QStyle.StandardPixmap: | |
| btn = QPushButton(icon.name) | |
| style = self.style() | |
| assert style is not None | |
| btn.setIcon(style.standardIcon(icon)) | |
| layout.addWidget(btn, count // colSize, count % colSize) | |
| count += 1 | |
| self.setLayout(layout) | |
| if __name__ == '__main__': | |
| app = QApplication([]) | |
| dialog = Widget() | |
| dialog.show() | |
| app.exec() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment