def buttonToolBar(self, info): toolbarItems = info['toolbarItems'] label = 'Show Reference Viewer' identifier = 'ReferenceViewer' filename = 'ReferenceIcon.pdf' callback = self.buttonStartCallback index = -2 imagePath = os.path.join(self.base_path, 'resources', filename) image = NSImage.alloc().initByReferencingFile_(imagePath) view = ToolbarGlyphTools( (30, 25), [dict(image=image, toolTip=label)], trackingMode="one" ) newItem = dict( itemIdentifier = identifier, label = label, callback = callback, view = view ) toolbarItems.insert(index, newItem)
def addOverlapToolbarItem(self, info): toolbarItems = info['toolbarItems'] label = 'Add Overlap w/ UI' identifier = 'addOverlapUI' filename = 'AddOverlapButtonUI.pdf' callback = self.addOverlap index = -2 imagePath = os.path.join(self.base_path, 'resources', filename) image = NSImage.alloc().initByReferencingFile_(imagePath) view = ToolbarGlyphTools((30, 25), [dict(image=image, toolTip=label)], trackingMode="one") for item in list(toolbarItems): if item['itemIdentifier'] == identifier: toolbarItems.remove(item) newItem = dict(itemIdentifier=identifier, label=label, callback=callback, view=view) toolbarItems.insert(index, newItem)
def addToolbarItem(self, toolbarItems, label, identifier, filename, callback, index=-1): imagePath = os.path.join(self.base_path, 'resources', filename) image = NSImage.alloc().initByReferencingFile_(imagePath) if identifier is 'roboToDoGlyph': view = ToolbarGlyphTools((30, 25), [dict(image=image, toolTip="To-Do")], trackingMode="one") newItem = dict(itemIdentifier=identifier, label=label, callback=callback, view=view) else: newItem = dict(itemIdentifier=identifier, label=label, imageObject=image, callback=callback) toolbarItems.insert(index, newItem)
def glyphEditorWantsToolbarItems(self, info): toolbarItems = info['itemDescriptions'] label = 'Add Overlap' identifier = 'addOverlap' callback = self.addOverlap index = -2 bundle = ExtensionBundle("AddOverlap") icon = bundle.getResourceImage("AddOverlapButton") view = ToolbarGlyphTools((30, 25), [dict(image=icon, toolTip=label)], trackingMode="one") newItem = dict(itemIdentifier=identifier, label=label, callback=callback, view=view) toolbarItems.insert(index, newItem)