def symbol_icon(symbol, color=None): bm = QtGui.QBitmap(icon_path(POINT_ICONS.get(symbol, 'glue_circle'))) if color is not None: return QtGui.QIcon(tint_pixmap(bm, color)) return QtGui.QIcon(bm)
def add_tool(self, tool): self.tools[tool.tool_id] = tool self.tools_data = { **self.tools_data, tool.tool_id: { 'tooltip': tool.tool_tip, 'img': read_icon(icon_path(tool.icon), 'svg') } }
def layer_artist_icon(artist): """Create a QtGui.QIcon for a LayerArtist instance""" # TODO: need a test for this from glue.viewers.image.layer_artist import ImageLayerArtist if not artist.enabled: bm = QtGui.QBitmap(icon_path('glue_delete')) elif isinstance(artist, ImageLayerArtist): bm = QtGui.QBitmap(icon_path('glue_image')) else: bm = QtGui.QBitmap(icon_path(POINT_ICONS.get(artist.layer.style.marker, 'glue_circle_point'))) color = mpl_to_qt4_color(artist.layer.style.color) pm = tint_pixmap(bm, color) return QtGui.QIcon(pm)
def add_tool(self, tool): self.tools[tool.tool_id] = tool icon = Image.from_file(icon_path(tool.icon, icon_format='svg'), width=ICON_WIDTH) button = ToggleButton(children=[icon], value=tool.tool_id) if self.children is None: self.children = (button, ) else: self.children = tuple(self.children) + (button, )
def layer_artist_icon(artist): """Create a QtGui.QIcon for a LayerArtist instance""" # TODO: need a test for this from glue.viewers.scatter.layer_artist import ScatterLayerArtist color = artist.get_layer_color() if isinstance(color, Colormap): pm = cmap2pixmap(color) else: if isinstance(artist, ScatterLayerArtist): bm = QtGui.QBitmap(icon_path(POINT_ICONS.get(artist.layer.style.marker, 'glue_circle_point'))) else: bm = QtGui.QBitmap(icon_path('glue_box_point')) color = mpl_to_qt4_color(color) pm = tint_pixmap(bm, color) return QtGui.QIcon(pm)
def add_tool(self, tool): self.tools[tool.tool_id] = tool icon = Image.from_file(icon_path(tool.icon, icon_format='svg'), width=ICON_WIDTH) button = v.Btn(v_on="tooltip.on", icon=True, children=[icon], value=tool.tool_id) annotated = v.Tooltip( bottom=True, v_slots=[{ 'name': 'activator', 'variable': 'tooltip', 'children': button}], children=[tool.tool_tip]) self.children = list(self.children) + [annotated]
def layer_artist_icon(artist): """Create a QtGui.QIcon for a LayerArtist instance""" # TODO: need a test for this from glue.viewers.scatter.layer_artist import ScatterLayerArtist color = artist.get_layer_color() if isinstance(color, Colormap): pm = cmap2pixmap(color) else: if isinstance(artist, ScatterLayerArtist): bm = QtGui.QBitmap(icon_path(POINT_ICONS.get(artist.layer.style.marker, 'glue_circle_point'))) else: bm = QtGui.QBitmap(icon_path('glue_box_point')) color = mpl_to_qt_color(color) pm = tint_pixmap(bm, color) return QtGui.QIcon(pm)
def add_tool(self, tool): self.tools[tool.tool_id] = tool # TODO: we should ideally just incorporate this check into icon_path directly. if os.path.exists(tool.icon): path = tool.icon else: path = icon_path(tool.icon, icon_format='svg') self.tools_data = { **self.tools_data, tool.tool_id: { 'tooltip': tool.tool_tip, 'img': read_icon(path, 'svg+xml') } }
def layer_icon(layer): """Create a QtGui.QIcon for a Data or Subset instance :type layer: :class:`~glue.core.data.Data`, :class:`~glue.core.subset.Subset`, or object with a .style attribute :rtype: QtGui.QIcon """ icon = POINT_ICONS.get(layer.style.marker, 'circle_point') bm = QtGui.QBitmap(icon_path(icon)) color = mpl_to_qt4_color(layer.style.color) pm = tint_pixmap(bm, color) return QtGui.QIcon(pm)
def get_icon(icon_name): """ Build a QtGui.QIcon from an image name Parameters ---------- icon_name : str Name of image file. Assumed to be a png file in glue/qt/icons Do not include the extension Returns ------- A QtGui.QIcon object """ return QtGui.QIcon(icon_path(icon_name))
import ipyvuetify as v import ipywidgets as widgets import glue.core.message as msg from glue.icons import icon_path from glue.core.edit_subset_mode import OrMode, AndNotMode, AndMode, XorMode, ReplaceMode from glue.core.hub import HubListener from glue.utils.decorators import avoid_circular from glue_jupyter.utils import nullcontext __all__ = ['SelectionModeMenu'] ICON_WIDTH = 20 icon_replace = widgets.Image.from_file(icon_path("glue_replace", icon_format="svg"), width=ICON_WIDTH) icon_or = widgets.Image.from_file(icon_path("glue_or", icon_format="svg"), width=ICON_WIDTH) icon_and = widgets.Image.from_file(icon_path("glue_and", icon_format="svg"), width=ICON_WIDTH) icon_xor = widgets.Image.from_file(icon_path("glue_xor", icon_format="svg"), width=ICON_WIDTH) icon_andnot = widgets.Image.from_file(icon_path("glue_andnot", icon_format="svg"), width=ICON_WIDTH) class SelectionModeMenu(v.Menu, HubListener): def __init__(self, session=None, output_widget=None): self.output = output_widget