Last active
November 2, 2025 22:07
-
-
Save centaurialpha/cfd7de48cb3e4d8e0d17f475b7ad3118 to your computer and use it in GitHub Desktop.
Show all standard Qt 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
| from PyQt5.QtWidgets import QApplication | |
| from PyQt5.QtWidgets import QWidget | |
| from PyQt5.QtWidgets import QPushButton | |
| from PyQt5.QtWidgets import QGridLayout | |
| from PyQt5.QtWidgets import QStyle | |
| COL_SIZE = 4 | |
| class Widget(QWidget): | |
| def __init__(self, parent=None): | |
| super().__init__(parent) | |
| self.setWindowTitle('Standard Icons') | |
| layout = QGridLayout(self) | |
| count = 0 | |
| for attr in dir(QStyle): | |
| if attr.startswith('SP_'): | |
| icon_attr = getattr(QStyle, attr) | |
| btn = QPushButton(attr) | |
| btn.setIcon(self.style().standardIcon(icon_attr)) | |
| layout.addWidget(btn, count // COL_SIZE, count % COL_SIZE) | |
| count += 1 | |
| if __name__ == '__main__': | |
| app = QApplication([]) | |
| w = Widget() | |
| w.show() | |
| app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adapted for QT6 plus bonus - copy icon name on click