def get_std_icon(name, size=None): """Get standard platform icon Call 'show_std_icons()' for details""" if not name.startswith('SP_'): name = 'SP_'+name icon = QWidget().style().standardIcon( getattr(QStyle, name) ) if size is None: return icon else: return QIcon( icon.pixmap(size, size) )
def get_icon(name, default=None, resample=False): """Return image inside a QIcon object default: default image name or icon resample: if True, manually resample icon pixmaps for usual sizes (16, 24, 32, 48, 96, 128, 256). This is recommended for QMainWindow icons created from SVG images on non-Windows platforms due to a Qt bug (see Issue 1314).""" if default is None: icon = QIcon(get_image_path(name)) elif isinstance(default, QIcon): icon_path = get_image_path(name, default=None) icon = default if icon_path is None else QIcon(icon_path) else: icon = QIcon(get_image_path(name, default)) if resample: icon0 = QIcon() for size in (16, 24, 32, 48, 96, 128, 256, 512): icon0.addPixmap(icon.pixmap(size, size)) return icon0 else: return icon
def context_menu_requested(self, event): """ """ pos = QPoint(event.x(), event.y()) menu = QMenu(self) actions = [] action_title = create_action(self, _('Go to step: '), icon=QIcon()) action_title.setDisabled(True) actions.append(action_title) # actions.append(create_action(self, _(': '), icon=QIcon())) add_actions(menu, actions) menu.popup(self.mapToGlobal(pos))
def icon(name, resample=False): theme = CONF.get('main', 'icon_theme') if theme == 'spyder 3': if not _resource['loaded']: qta.load_font('spyder', 'spyder.ttf', 'spyder-charmap.json', directory=_resource['directory']) _resource['loaded'] = True args, kwargs = _qtaargs[name] return qta.icon(*args, **kwargs) elif theme == 'spyder 2': icon = get_icon(name + '.png', resample=resample) return icon if icon is not None else QIcon()
def get_python_symbol_icons(oedata): """Return a list of icons for oedata of a python file.""" class_icon = ima.icon('class') method_icon = ima.icon('method') function_icon = ima.icon('function') private_icon = ima.icon('private1') super_private_icon = ima.icon('private2') symbols = process_python_symbol_data(oedata) # line - 1, name, fold level fold_levels = sorted(list(set([s[2] for s in symbols]))) parents = [None] * len(symbols) icons = [None] * len(symbols) indexes = [] parent = None for level in fold_levels: for index, item in enumerate(symbols): line, name, fold_level, token = item if index in indexes: continue if fold_level == level: indexes.append(index) parent = item else: parents[index] = parent for index, item in enumerate(symbols): parent = parents[index] if item[-1] == 'def': icons[index] = function_icon elif item[-1] == 'class': icons[index] = class_icon else: icons[index] = QIcon() if parent is not None: if parent[-1] == 'class': if item[-1] == 'def' and item[1].startswith('__'): icons[index] = super_private_icon elif item[-1] == 'def' and item[1].startswith('_'): icons[index] = private_icon else: icons[index] = method_icon return icons
def _icon_by_painter(self, painter, options): """Returns the icon corresponding to the given painter""" engine = CharIconEngine(self, painter, options) return QIcon(engine)