|
1 | 1 | Icons Tips |
2 | 2 | ========== |
3 | 3 |
|
4 | | -The icons used in the application are mostly standard system icons. They can be found under QtGui.QStyle, e.g. QtGui.QStyle.SP_MediaPlay. |
| 4 | +The icons used in the application are mostly standard system icons. They can be found under `QtGui.QStyle`, e.g. `QtGui.QStyle.SP_MediaPlay`. |
5 | 5 | A list of icons is available [here](https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/PySide/QtGui/QStyle.html?highlight=qstyle#PySide.QtGui.PySide.QtGui.QStyle.StandardPixmap). |
6 | 6 |
|
7 | 7 | To view them quickly, you can run the following code (taken from [here](https://joekuan.wordpress.com/2015/09/23/list-of-qt-icons/)): |
| 8 | +``` |
| 9 | +import sys |
| 10 | +from PyQt4.QtCore import * |
| 11 | +from PyQt4.QtGui import * |
| 12 | +# from PyQt4.QtWidgets import * |
| 13 | +
|
| 14 | +
|
| 15 | +class Widget(QWidget): |
| 16 | + def __init__(self, parent=None): |
| 17 | + super(Widget, self).__init__() |
| 18 | +
|
| 19 | + icons = [ |
| 20 | + 'SP_ArrowBack', |
| 21 | + 'SP_ArrowDown', |
| 22 | + 'SP_ArrowForward', |
| 23 | + 'SP_ArrowLeft', |
| 24 | + 'SP_ArrowRight', |
| 25 | + 'SP_ArrowUp', |
| 26 | + 'SP_BrowserReload', |
| 27 | + 'SP_BrowserStop', |
| 28 | + 'SP_CommandLink', |
| 29 | + 'SP_ComputerIcon', |
| 30 | + 'SP_CustomBase', |
| 31 | + 'SP_DesktopIcon', |
| 32 | + 'SP_DialogApplyButton', |
| 33 | + 'SP_DialogCancelButton', |
| 34 | + 'SP_DialogCloseButton', |
| 35 | + 'SP_DialogDiscardButton', |
| 36 | + 'SP_DialogHelpButton', |
| 37 | + 'SP_DialogNoButton', |
| 38 | + 'SP_DialogOkButton', |
| 39 | + 'SP_DialogOpenButton', |
| 40 | + 'SP_DialogResetButton', |
| 41 | + 'SP_DialogSaveButton', |
| 42 | + 'SP_DialogYesButton', |
| 43 | + 'SP_DirClosedIcon', |
| 44 | + 'SP_DirHomeIcon', |
| 45 | + 'SP_DirIcon', |
| 46 | + 'SP_DirLinkIcon', |
| 47 | + 'SP_DirOpenIcon', |
| 48 | + 'SP_DockWidgetCloseButton', |
| 49 | + 'SP_DriveCDIcon', |
| 50 | + 'SP_DriveDVDIcon', |
| 51 | + 'SP_DriveFDIcon', |
| 52 | + 'SP_DriveHDIcon', |
| 53 | + 'SP_DriveNetIcon', |
| 54 | + 'SP_FileDialogBack', |
| 55 | + 'SP_FileDialogContentsView', |
| 56 | + 'SP_FileDialogDetailedView', |
| 57 | + 'SP_FileDialogEnd', |
| 58 | + 'SP_FileDialogInfoView', |
| 59 | + 'SP_FileDialogListView', |
| 60 | + 'SP_FileDialogNewFolder', |
| 61 | + 'SP_FileDialogStart', |
| 62 | + 'SP_FileDialogToParent', |
| 63 | + 'SP_FileIcon', |
| 64 | + 'SP_FileLinkIcon', |
| 65 | + 'SP_MediaPause', |
| 66 | + 'SP_MediaPlay', |
| 67 | + 'SP_MediaSeekBackward', |
| 68 | + 'SP_MediaSeekForward', |
| 69 | + 'SP_MediaSkipBackward', |
| 70 | + 'SP_MediaSkipForward', |
| 71 | + 'SP_MediaStop', |
| 72 | + 'SP_MediaVolume', |
| 73 | + 'SP_MediaVolumeMuted', |
| 74 | + 'SP_MessageBoxCritical', |
| 75 | + 'SP_MessageBoxInformation', |
| 76 | + 'SP_MessageBoxQuestion', |
| 77 | + 'SP_MessageBoxWarning', |
| 78 | + 'SP_TitleBarCloseButton', |
| 79 | + 'SP_TitleBarContextHelpButton', |
| 80 | + 'SP_TitleBarMaxButton', |
| 81 | + 'SP_TitleBarMenuButton', |
| 82 | + 'SP_TitleBarMinButton', |
| 83 | + 'SP_TitleBarNormalButton', |
| 84 | + 'SP_TitleBarShadeButton', |
| 85 | + 'SP_TitleBarUnshadeButton', |
| 86 | + 'SP_ToolBarHorizontalExtensionButton', |
| 87 | + 'SP_ToolBarVerticalExtensionButton', |
| 88 | + 'SP_TrashIcon', |
| 89 | + 'SP_VistaShield' |
| 90 | + ] |
| 91 | +
|
| 92 | + colSize = 4 |
| 93 | +
|
| 94 | + layout = QGridLayout() |
| 95 | +
|
| 96 | + count = 0 |
| 97 | + for i in icons: |
| 98 | + btn = QPushButton(i) |
| 99 | + btn.setIcon(self.style().standardIcon(getattr(QStyle, i))) |
| 100 | +
|
| 101 | + layout.addWidget(btn, count / colSize, count % colSize) |
| 102 | + count += 1 |
| 103 | +
|
| 104 | + self.setLayout(layout) |
| 105 | +
|
| 106 | +
|
| 107 | +if __name__ == '__main__': |
| 108 | + app = QApplication(sys.argv) |
| 109 | +
|
| 110 | + dialog = Widget() |
| 111 | + dialog.show() |
| 112 | +
|
| 113 | + app.exec_() |
| 114 | +``` |
8 | 115 |
|
0 commit comments